diff options
-rw-r--r-- | scripts/automation/regression/stateless_tests/stl_general_test.py | 56 | ||||
-rw-r--r-- | scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_std.py | 31 |
2 files changed, 53 insertions, 34 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 diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_std.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_std.py index d582b499..6c101fbb 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_std.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_std.py @@ -5,26 +5,15 @@ from trex_stl_packet_builder_scapy import * # will destroy all streams/data on the ports def stl_map_ports (client, ports = None): # by default use all ports - if ports == None: + if ports is None: ports = client.get_all_ports() - # reset the ports - client.reset(ports) - - # generate streams - base_pkt = CScapyTRexPktBuilder(pkt = Ether()/IP()) - - # send something initial to calm down switches with arps etc. - stream = STLStream(packet = base_pkt, - mode = STLTXSingleBurst(pps = 100000, total_pkts = 1)) - client.add_streams(stream, ports) - - client.start(ports, mult = "50%") - client.wait_on_traffic(ports) - client.reset(ports) + stl_send_3_pkts(client, ports) tx_pkts = {} pkts = 1 + base_pkt = CScapyTRexPktBuilder(pkt = Ether()/IP()) + for port in ports: tx_pkts[pkts] = port stream = STLStream(packet = base_pkt, @@ -75,3 +64,15 @@ def stl_map_ports (client, ports = None): return table +# reset ports and send 3 packets from each acquired port +def stl_send_3_pkts(client, ports = None): + + base_pkt = CScapyTRexPktBuilder(pkt = Ether()/IP()) + stream = STLStream(packet = base_pkt, + mode = STLTXSingleBurst(pps = 100000, total_pkts = 3)) + + client.reset(ports) + client.add_streams(stream, ports) + client.start(ports, mult = "50%") + client.wait_on_traffic(ports) + client.reset(ports) |