def test_vlan_basic(self): with self.assertRaises(Exception): STLHltStream(l2_encap = 'ethernet_ii', vlan_id = 'sdfgsdgf') test_stream = STLHltStream(l2_encap = 'ethernet_ii') assert ':802.1Q:' not in test_stream.get_pkt_type(), 'Default packet should not include dot1q' test_stream = STLHltStream(name = 'test_vlan_basic', l2_encap = 'ethernet_ii_vlan') assert ':802.1Q:' in test_stream.get_pkt_type(), 'No dot1q in packet with encap ethernet_ii_vlan' self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location()) self.golden_yaml = '''
def test_vlan_vm(self): test_stream = STLHltStream(name = 'test_vlan_vm', frame_size = 100, vlan_id = '1 2 1000 4 5', # 5 vlans vlan_id_mode = 'increment fixed decrement random', # 5th vlan will be default fixed vlan_id_step = 2, # 1st vlan step will be 2, others - default 1 vlan_id_count = [4, 1, 10], # 4th independent on count, 5th will be fixed ) pkt_layers = test_stream.get_pkt_type() self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location()) assert '802.1Q:' * 5 in pkt_layers, 'No five dot1q layers in packet: %s' % pkt_layers self.golden_yaml = '''
def test_vlan_multiple(self): # default frame size should be not enough with self.assertRaises(Exception): STLHltStream(vlan_id = [1, 2, 3, 4]) test_stream = STLHltStream(name = 'test_vlan_multiple', frame_size = 100, vlan_id = [1, 2, 3, 4], # can be either array or string separated by spaces vlan_protocol_tag_id = '8100 0x8100') pkt_layers = test_stream.get_pkt_type() assert '802.1Q:' * 4 in pkt_layers, 'No four dot1q layers in packet: %s' % pkt_layers self.test_yaml = test_stream.dump_to_yaml(self.yaml_save_location()) self.golden_yaml = '''