summaryrefslogtreecommitdiffstats
path: root/scripts/automation/regression
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-03-14 12:00:16 +0200
committerYaroslav Brustinov <ybrustin@cisco.com>2016-03-14 12:00:16 +0200
commit22e06f3c3532890ad336341c279012afc0710a9d (patch)
tree429b84bf6977c37c111bfc61834eb4ccb7f3709f /scripts/automation/regression
parente07322a708dabf6ba50abc32e7c5cc6f6491ba32 (diff)
regression: stl speedup (fix)
Diffstat (limited to 'scripts/automation/regression')
-rw-r--r--scripts/automation/regression/stateless_tests/stl_general_test.py56
1 files changed, 37 insertions, 19 deletions
diff --git a/scripts/automation/regression/stateless_tests/stl_general_test.py b/scripts/automation/regression/stateless_tests/stl_general_test.py
index 435c7eea..64e93510 100644
--- a/scripts/automation/regression/stateless_tests/stl_general_test.py
+++ b/scripts/automation/regression/stateless_tests/stl_general_test.py
@@ -21,18 +21,41 @@ class CStlGeneral_Test(CTRexGeneral_Test):
if CTRexScenario.stl_init_error:
self.skip(CTRexScenario.stl_init_error)
- @staticmethod
- def connect(timeout = 20):
+ def connect(self, timeout = 20):
sys.stdout.write('Connecting')
for i in range(timeout):
try:
sys.stdout.write('.')
sys.stdout.flush()
- CTRexScenario.stl_trex.connect()
- return
+ self.stl_trex.connect()
+ print ''
+ return True
except:
time.sleep(1)
- CTRexScenario.stl_trex.connect()
+ print ''
+ return False
+
+ def map_ports(self, timeout = 5):
+ sys.stdout.write('Mapping ports')
+ for i in range(timeout):
+ sys.stdout.write('.')
+ sys.stdout.flush()
+ CTRexScenario.stl_ports_map = stl_map_ports(self.stl_trex)
+ if self.verify_bidirectional(CTRexScenario.stl_ports_map):
+ print ''
+ return True
+ time.sleep(1)
+ print ''
+ return False
+
+ # verify all the ports are bidirectional
+ @staticmethod
+ def verify_bidirectional(mapping_dict):
+ if len(mapping_dict['unknown']):
+ return False
+ if len(mapping_dict['bi']) * 2 == len(mapping_dict['map']):
+ return True
+ return False
@staticmethod
def get_port_count():
@@ -51,18 +74,13 @@ class STLBasic_Test(CStlGeneral_Test):
CTRexScenario.router.configure_basic_interfaces()
CTRexScenario.router.config_pbr(mode = "config")
- CTRexScenario.stl_init_error = 'Client could not connect'
- self.connect()
- print ''
- try:
- stl_map_ports(CTRexScenario.stl_trex)
- except:
- pass
- time.sleep(5)
- CTRexScenario.stl_init_error = 'Client could not map ports'
- CTRexScenario.stl_ports_map = stl_map_ports(CTRexScenario.stl_trex)
- CTRexScenario.stl_init_error = 'Could not determine bidirectional ports'
- print 'Ports mapping: %s' % CTRexScenario.stl_ports_map
- if not len(CTRexScenario.stl_ports_map['bi']):
- raise STLError('No bidirectional ports')
+ err = 'Client could not connect'
+ CTRexScenario.stl_init_error = err
+ if not self.connect():
+ self.fail(err)
+ err = 'Client could not map ports'
+ CTRexScenario.stl_init_error = err
+ if not self.map_ports():
+ self.fail(err)
+ print 'Got ports mapping: %s' % CTRexScenario.stl_ports_map
CTRexScenario.stl_init_error = None