xena2544_verify_fix: Fix Xena verify options 27/38927/4
authorChristian Trautman <ctrautma@redhat.com>
Tue, 8 Aug 2017 18:09:53 +0000 (14:09 -0400)
committerChristian Trautman <ctrautma@redhat.com>
Tue, 8 Aug 2017 18:39:27 +0000 (14:39 -0400)
Fixes issue when running multiple packets sizes and using the Xena
verify option. Original values are restored to settings for each
new packet size or test case.

Also fixes a minor issue where if the test failed, the verify would
run regardless.

JIRA: VSPERF-515

Change-Id: I6b6ce5160b66e7ed4a3847711c4f05529ae8ca54
Signed-off-by: Christian Trautman <ctrautma@redhat.com>
tools/pkt_gen/xena/xena.py

index b72a59d..19b44f0 100755 (executable)
@@ -274,10 +274,11 @@ class Xena(ITrafficGenerator):
         enable the pairs topology
         :return: None
         """
+        # set duplex mode, this code is valid, pylint complaining with a
+        # warning that many have complained about online.
+        # pylint: disable=redefined-variable-type
+
         try:
-            # set duplex mode, this code is valid, pylint complaining with a
-            # warning that many have complained about online.
-            # pylint: disable=redefined-variable-type
             if self._params['traffic']['bidir'] == "True":
                 j_file = XenaJSONMesh()
             elif self._params['traffic']['bidir'] == "False":
@@ -635,12 +636,25 @@ class Xena(ITrafficGenerator):
         root = ET.parse(os.path.join(_CURR_DIR, "xena2544-report.xml")).getroot()
 
         if settings.getValue('TRAFFICGEN_XENA_RFC2544_VERIFY'):
+            # make sure we have a pass before even trying the verify. No need
+            # to run verify on a failed iteration.
+            root = ET.parse(
+                os.path.join(_CURR_DIR, "xena2544-report.xml")).getroot()
+            if root[0][1][0].get('TestState') == "FAIL":
+                self._logger.info('Test failed, skipping verify')
+                return Xena._create_throughput_result(root)
+
             # record the previous settings so we can revert to them if needed to
             # run the binary search again if the verify fails.
             old_tests = tests
             old_duration = self._duration
             old_min = settings.getValue('TRAFFICGEN_XENA_2544_TPUT_MIN_VALUE')
 
+            # record the original values to restore after execution
+            orig_min = settings.getValue('TRAFFICGEN_XENA_2544_TPUT_MIN_VALUE')
+            orig_max = settings.getValue('TRAFFICGEN_XENA_2544_TPUT_MAX_VALUE')
+            orig_init = settings.getValue('TRAFFICGEN_XENA_2544_TPUT_INIT_VALUE')
+
             for attempt in range(
                     1, settings.getValue(
                         'TRAFFICGEN_XENA_RFC2544_MAXIMUM_VERIFY_ATTEMPTS')+1):
@@ -708,6 +722,11 @@ class Xena(ITrafficGenerator):
                     self._logger.error(
                         'Maximum number of verify attempts reached. Reporting last result')
 
+            #restore original values
+            settings.setValue('TRAFFICGEN_XENA_2544_TPUT_MIN_VALUE', orig_min)
+            settings.setValue('TRAFFICGEN_XENA_2544_TPUT_MAX_VALUE', orig_max)
+            settings.setValue('TRAFFICGEN_XENA_2544_TPUT_INIT_VALUE', orig_init)
+
         return Xena._create_throughput_result(root)
 
     def start_rfc2544_throughput(self, traffic=None, tests=1, duration=20,