xena: Back 2 Back implementation 39/12239/3
authorChristian Trautman <ctrautma@redhat.com>
Wed, 13 Apr 2016 17:02:00 +0000 (13:02 -0400)
committerMaryam Tahhan <maryam.tahhan@intel.com>
Tue, 19 Apr 2016 13:48:35 +0000 (13:48 +0000)
Allows for execution of back 2 back tests by enabling back to back
test scenario in json file when executing Xena2544.exe. Return
results are the number of frames. Results for test execution can
be found in the coresponding JIRA ticket.

- Disabled throughput by default in json file.
- Modified test params in baseconfig file for b2b test
- Modified create_result method to use data in resulting xml file
  over using inspect strategy to detect test type
- Added line to Xena installation guide for issue that was found
  locally after installation

JIRA: VSPERF-264

Change-Id: I0ecd6e1ce750613c53fe308aea3f5a55cca69c20
Signed-off-by: Christian Trautman <ctrautma@redhat.com>
docs/configguide/trafficgen.rst
tools/pkt_gen/xena/profiles/baseconfig.x2544
tools/pkt_gen/xena/xena.py

index 06503b3..41a48f6 100644 (file)
@@ -263,6 +263,13 @@ http://www.mono-project.com/docs/getting-started/install/linux/
     yum-config-manager --add-repo http://download.mono-project.com/repo/centos/
     yum -y install mono-complete
 
+To prevent gpg errors on future yum installation of packages the mono-project
+repo should be disabled once installed.
+
+.. code-block:: console
+
+    yum-config-manager --disable download.mono-project.com_repo_centos_
+
 Configuration
 ~~~~~~~~~~~~~
 
index 93c8fab..3ebe79d 100644 (file)
           "b"
         ],
         "TestType": "Throughput",
-        "Enabled": true,
+        "Enabled": false,
         "DurationType": "Seconds",
         "Duration": 1.0,
         "DurationFrames": 1,
       "Back2Back": {
         "$type": "XenaCommon.TestConfig.Xena2544.TestTypeOptions.Back2BackTestOptions, Xena2544",
         "RateSweepOptions": {
-          "StartValue": 50.0,
+          "StartValue": 100.0,
           "EndValue": 100.0,
           "StepValue": 50.0
         },
index 88dd370..969a5a8 100755 (executable)
@@ -23,7 +23,6 @@ Xena Traffic Generator Model
 """
 
 # python imports
-import inspect
 import logging
 import subprocess
 import sys
@@ -74,19 +73,10 @@ class Xena(ITrafficGenerator):
         :param root: root dictionary from xml import
         :return: Results Ordered dictionary based off ResultsConstants
         """
-        throughput_test = False
-        back2back_test = False
-        # get the calling method so we know how to return the stats
-        caller = inspect.stack()[1][3]
-        if 'throughput' in caller:
-            throughput_test = True
-        elif 'back2back' in caller:
-            back2back_test = True
-        else:
-            raise NotImplementedError(
-                "Unknown implementation for result return")
+        # get the test type from the report file
+        test_type = root[0][1].get('TestType')
 
-        if throughput_test:
+        if test_type == 'Throughput':
             results = OrderedDict()
             results[ResultsConstants.THROUGHPUT_RX_FPS] = int(
                 root[0][1][0][1].get('PortRxPps'))
@@ -122,8 +112,16 @@ class Xena(ITrafficGenerator):
                 # Stats for latency returned as N/A so just post them
                 results[ResultsConstants.AVG_LATENCY_NS] = root[0][1][0][0].get(
                     'AvgLatency')
-        elif back2back_test:
-            raise NotImplementedError('Back to back results not implemented')
+        elif test_type == 'Back2Back':
+            results = OrderedDict()
+
+            # Just mimic what Ixia does and only return the b2b frame count.
+            # This may change later once its decided the common results stats
+            # to be returned should be.
+            results[ResultsConstants.B2B_FRAMES] = root[0][1][0][0].get(
+                'TotalTxBurstFrames')
+        else:
+            raise NotImplementedError('Unknown test type in report file.')
 
         return results
 
@@ -176,7 +174,7 @@ class Xena(ITrafficGenerator):
                 flows=self._params['traffic']['multistream'],
                 multistream_layer=self._params['traffic']['stream_type'])
             # set duplex mode
-            if self._params['traffic']['bidir']:
+            if bool(self._params['traffic']['bidir']):
                 j_file.set_topology_mesh()
             else:
                 j_file.set_topology_blocks()
@@ -328,36 +326,58 @@ class Xena(ITrafficGenerator):
                                lossrate=0.0):
         """Send traffic per RFC2544 back2back test specifications.
 
-        Send packets at a fixed rate, using ``traffic``
-        configuration, until minimum time at which no packet loss is
-        detected is found.
+        See ITrafficGenerator for description
+        """
+        self._duration = duration
 
-        :param traffic: Detailed "traffic" spec, i.e. IP address, VLAN
-            tags
-        :param trials: Number of trials to execute
-        :param duration: Per iteration duration
-        :param lossrate: Acceptable loss percentage
+        self._params.clear()
+        self._params['traffic'] = self.traffic_defaults.copy()
+        if traffic:
+            self._params['traffic'] = merge_spec(self._params['traffic'],
+                                                 traffic)
 
-        :returns: Named tuple of Rx Throughput (fps), Rx Throughput (mbps),
-            Tx Rate (% linerate), Rx Rate (% linerate), Tx Count (frames),
-            Back to Back Count (frames), Frame Loss (frames), Frame Loss (%)
-        :rtype: :class:`Back2BackResult`
-        """
-        raise NotImplementedError('Xena back2back not implemented')
+        self._setup_json_config(trials, lossrate, '2544_b2b')
+
+        args = ["mono", "./tools/pkt_gen/xena/Xena2544.exe", "-c",
+                "./tools/pkt_gen/xena/profiles/2bUsed.x2544", "-e", "-r",
+                "./tools/pkt_gen/xena", "-u",
+                settings.getValue('TRAFFICGEN_XENA_USER')]
+        self.mono_pipe = subprocess.Popen(
+            args, stdout=sys.stdout)
+        self.mono_pipe.communicate()
+        root = ET.parse(r'./tools/pkt_gen/xena/xena2544-report.xml').getroot()
+        return Xena._create_throughput_result(root)
 
     def start_rfc2544_back2back(self, traffic=None, trials=1, duration=20,
                                 lossrate=0.0):
         """Non-blocking version of 'send_rfc2544_back2back'.
 
-        Start transmission and immediately return. Do not wait for
-        results.
+        See ITrafficGenerator for description
         """
-        raise NotImplementedError('Xena back2back not implemented')
+        self._duration = duration
+
+        self._params.clear()
+        self._params['traffic'] = self.traffic_defaults.copy()
+        if traffic:
+            self._params['traffic'] = merge_spec(self._params['traffic'],
+                                                 traffic)
+
+        self._setup_json_config(trials, lossrate, '2544_b2b')
+
+        args = ["mono", "./tools/pkt_gen/xena/Xena2544.exe", "-c",
+                "./tools/pkt_gen/xena/profiles/2bUsed.x2544", "-e", "-r",
+                "./tools/pkt_gen/xena", "-u",
+                settings.getValue('TRAFFICGEN_XENA_USER')]
+        self.mono_pipe = subprocess.Popen(
+            args, stdout=sys.stdout)
 
     def wait_rfc2544_back2back(self):
         """Wait and set results of RFC2544 test.
         """
-        raise NotImplementedError('Xena back2back not implemented')
+        self.mono_pipe.communicate()
+        sleep(2)
+        root = ET.parse(r'./tools/pkt_gen/xena/xena2544-report.xml').getroot()
+        return Xena._create_throughput_result(root)
 
 
 if __name__ == "__main__":