Less strict check on end of warmup state in Stateful API (96% of expected) 25/5325/1
authorYaroslav Brustinov <[email protected]>
Thu, 22 Dec 2016 15:54:38 +0000 (17:54 +0200)
committerYaroslav Brustinov <[email protected]>
Thu, 22 Dec 2016 15:54:38 +0000 (17:54 +0200)
Regression: (stateful) check that the BW is less than expected + 5%.

Change-Id: Ie181a970d81fbca30a17d17ee98d0228603db11c
Signed-off-by: Yaroslav Brustinov <[email protected]>
scripts/automation/regression/stateful_tests/trex_general_test.py
scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_client.py

index fe38ed3..088bd97 100755 (executable)
@@ -214,13 +214,25 @@ class CTRexGeneral_Test(unittest.TestCase):
     def check_general_scenario_results (self, trex_res, check_latency = True):
         
         try:
+            # check history size is enough
+            if len(trex_res._history) < 5:
+                self.fail('TRex results list is too short. Increase the test duration or check unexpected stopping.')
+
             # check if test is valid
             if not trex_res.is_done_warmup():
                 self.fail('TRex did not reach warm-up situtaion. Results are not valid.')
 
-            # check history size is enough
-            if len(trex_res._history) < 5:
-                self.fail('TRex results list is too short. Increase the test duration or check unexpected stopping.')
+            # check that BW is not much more than expected
+            trex_exp_bps = int(trex_res.get_expected_tx_rate().get('m_tx_expected_bps') / 1e6)
+            trex_cur_bps = int(max(trex_res.get_value_list('trex-global.data.m_tx_bps')) / 1e6)
+
+            if trex_exp_bps is None:
+                self.fail('Expected rate is None!')
+            if trex_cur_bps is None:
+                self.fail('Current rate is None!')
+
+            if trex_exp_bps * 1.05 < trex_cur_bps:
+                self.fail('Got BW (%sMbps) that is %s%% more than expected (%sMbps)!' % (trex_cur_bps, round(100.0 * trex_cur_bps / trex_exp_bps - 100, 2), trex_exp_bps))
 
             # check TRex number of drops
             trex_tx_pckt    = trex_res.get_last_value("trex-global.data.m_total_tx_pkts")
index 5d992c6..0977d2e 100755 (executable)
@@ -1371,7 +1371,7 @@ class CTRexResult(object):
 
         """
         # add latest dump to history
-        if latest_dump != {}:
+        if latest_dump:
             self._history.append(latest_dump)
             if not self.valid:
                 self.valid = True 
@@ -1383,8 +1383,8 @@ class CTRexResult(object):
 
             self._current_tx_rate = CTRexResult.__get_value_by_path(latest_dump, "trex-global.data", "m_tx_(?!expected_)\w+")
             if not self._done_warmup and self._expected_tx_rate is not None:
-                # check for up to 2% change between expected and actual
-                if (self._current_tx_rate['m_tx_bps'] > 0.98 * self._expected_tx_rate['m_tx_expected_bps']):
+                # check for up to 4% change between expected and actual
+                if (self._current_tx_rate['m_tx_bps'] > 0.96 * self._expected_tx_rate['m_tx_expected_bps']):
                     self._done_warmup = True
                     latest_dump['warmup_barrier'] = True