diff options
| author | songyanchao <[email protected]> | 2023-04-13 10:50:21 +0000 |
|---|---|---|
| committer | songyanchao <[email protected]> | 2023-04-13 10:50:21 +0000 |
| commit | 873551c3285354394578eff59cccf4ce30752953 (patch) | |
| tree | ba455202b9794de407262cc9ebd72903826296cb /test | |
| parent | 2743c62081f827f94bbc2fd129080ddd40138290 (diff) | |
🧪 test(DPISDN-6): 添加bfd、classifier等测试用例
添加bfd、classifier等测试用例
Diffstat (limited to 'test')
| -rw-r--r-- | test/CMakeLists.txt | 58 | ||||
| -rw-r--r-- | test/bfd_test.py | 199 | ||||
| -rw-r--r-- | test/bridge_test.py | 258 | ||||
| -rw-r--r-- | test/classifier_test.py | 611 | ||||
| -rw-r--r-- | test/common_pkt.py | 59 | ||||
| -rw-r--r-- | test/etherfabric_test.py | 105 | ||||
| -rw-r--r-- | test/health_check_test.py | 113 | ||||
| -rw-r--r-- | test/load_balance_test.py | 261 | ||||
| -rw-r--r-- | test/mrzcpd.py | 12 | ||||
| -rw-r--r-- | test/vwire_test.py (renamed from test/demo_test.py) | 77 |
10 files changed, 1718 insertions, 35 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3412f6d..1712ae9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -26,10 +26,60 @@ endif() # for i in range(0, 24): # print(f"--interface {i}@veth{i}-ptf{i}", end=" ") -# Add ptf demo test + +# Add vwire test add_test( - NAME ptf_demo_test - COMMAND python3 /usr/local/bin/ptf --test-dir ${CMAKE_SOURCE_DIR}/test + NAME vwire_test + COMMAND /usr/local/bin/ptf --test-dir ${CMAKE_SOURCE_DIR}/test --interface 0@veth0-ptf0 --interface 1@veth1-ptf1 --interface 2@veth2-ptf2 --interface 3@veth3-ptf3 --interface 4@veth4-ptf4 --interface 5@veth5-ptf5 --interface 6@veth6-ptf6 --interface 7@veth7-ptf7 --interface 8@veth8-ptf8 --interface 9@veth9-ptf9 --interface 10@veth10-ptf10 --interface 11@veth11-ptf11 --interface 12@veth12-ptf12 --interface 13@veth13-ptf13 --interface 14@veth14-ptf14 --interface 15@veth15-ptf15 --interface 16@veth16-ptf16 --interface 17@veth17-ptf17 --interface 18@veth18-ptf18 --interface 19@veth19-ptf19 --interface 20@veth20-ptf20 --interface 21@veth21-ptf21 --interface 22@veth22-ptf22 --interface 23@veth23-ptf23 - demo_test --test-params "source_dir='${CMAKE_SOURCE_DIR}'" + vwire_test --test-params "source_dir='${CMAKE_SOURCE_DIR}'" +) + +# Add bfd test +add_test( + NAME bfd_test + COMMAND /usr/local/bin/ptf --test-dir ${CMAKE_SOURCE_DIR}/test + --interface 0@veth0-ptf0 + etherfabric_test bfdd_test --test-params "source_dir='${CMAKE_SOURCE_DIR}'" +) + +# Add bridge test +add_test( + NAME bridge_test + COMMAND /usr/local/bin/ptf --test-dir ${CMAKE_SOURCE_DIR}/test + --interface 0@veth0-ptf0 --interface 1@veth1-ptf1 --interface 2@veth2-ptf2 --interface 3@veth3-ptf3 + unicast_test broadcast_test master_device_test --test-params "source_dir='${CMAKE_SOURCE_DIR}'" +) + + +# Add classifier test +add_test( + NAME classifier_test + COMMAND /usr/local/bin/ptf --test-dir ${CMAKE_SOURCE_DIR}/test + --interface 0@veth0-ptf0 --interface 1@veth1-ptf1 --interface 2@veth2-ptf2 --interface 3@veth3-ptf3 --interface 4@veth4-ptf4 + classfier_base_test priority_test full_field_match_test --test-params "source_dir='${CMAKE_SOURCE_DIR}'" +) + +# Add etherfabric test +add_test( + NAME etherfabric_test + COMMAND /usr/local/bin/ptf --test-dir ${CMAKE_SOURCE_DIR}/test + --interface 0@veth0-ptf0 + etherfabric_base_test --test-params "source_dir='${CMAKE_SOURCE_DIR}'" +) + +# Add health_check test +add_test( + NAME health_check + COMMAND /usr/local/bin/ptf --test-dir ${CMAKE_SOURCE_DIR}/test + --interface 0@veth0-ptf0 + health_check_base_test --test-params "source_dir='${CMAKE_SOURCE_DIR}'" +) + +# Add load_balance test +add_test( + NAME load_balance + COMMAND /usr/local/bin/ptf --test-dir ${CMAKE_SOURCE_DIR}/test + --interface 0@veth0-ptf0 --interface 1@veth1-ptf1 --interface 2@veth2-ptf2 --interface 3@veth3-ptf3 --interface 4@veth4-ptf4 + lb_base_test --test-params "source_dir='${CMAKE_SOURCE_DIR}'" ) diff --git a/test/bfd_test.py b/test/bfd_test.py new file mode 100644 index 0000000..d75c9d1 --- /dev/null +++ b/test/bfd_test.py @@ -0,0 +1,199 @@ +import ptf +from ptf.base_tests import BaseTest +from ptf.testutils import * +from scapy.all import * +from mrzcpd import Mrzcpd +from common_pkt import * +import ptf.mask as mask + +bfd_conf = """ +[device] +device = veth0 +sz_tunnel = 8192 +sz_buffer = 0 + +[device:veth0] +in_addr=10.254.60.1 +in_mask=255.255.255.0 +gateway=10.10.1.40 +promisc = 1 +mtu = 1500 +driver = 2 +role = 3 + +[service] +iocore = 1 +distmode = 2 +hashmode = 0 + +[eal] +virtaddr = 0x600000000000 +loglevel = 7 +nohuge = 1 +mem = 65535 + +[keepalive] +check_spinlock = 1 + +[ctrlzone] +ctrlzone0 = tunnat, 64 +ctrlzone1 = vsys, 64 + +[pool] +create_mode = 3 +sz_direct_pktmbuf = 4096 +sz_indirect_pktmbuf = 4096 +sz_cache = 256 +sz_data = 3000 + +[ctrlmsg] +listen_addr = 0.0.0.0 +listen_port = 46789 + +[rpc] +addr = 127.0.0.1 +port = 56789 + +# sid +[etherfabric_adapters] +sid_range_start=100 +sid_range_end=200 +max_rules=256 + +[vwires] +sid_range_start=300 +sid_range_end=400 +max_rules=256 + +[service_lb] +sid_range_start=1000 +sid_range_end=2000 + +""" + + +@group("etherfabric_test") +class TestForEtherfabric(BaseTest): + def setUp(self): + self.dataplane = ptf.dataplane_instance + + def __init__(self): + BaseTest.__init__(self) + + def runTest(self): + try: + # Init & Start mrzcpd + mrzcpd = Mrzcpd(bfd_conf) + mrzcpd.start() + + # Create packet + send_bfd_pkt = simple_bfd_packet(eth_dst="10:70:fd:03:c0:bd", eth_src="0a:0a:0a:0a:01:28", + ip_src="10.10.1.40", ip_dst="10.254.60.1", + sta=0, my_discriminator=1111, your_discriminator=0) + + verify_bfd_pkt = mask.Mask( + simple_bfd_packet(eth_dst="0a:0a:0a:0a:01:28", eth_src="10:70:fd:03:c0:bd", + ip_src="10.254.60.1", ip_dst="10.10.1.40", sta=3, your_discriminator=1111)) + + verify_bfd_pkt.set_do_not_care_scapy(UDP, "chksum") + verify_bfd_pkt.set_do_not_care_scapy(BFD, "flags") + verify_bfd_pkt.set_do_not_care_scapy(BFD, "my_discriminator") + + send_packet(self, 0, send_bfd_pkt) + verify_packets(self, verify_bfd_pkt, [0]) + finally: + mrzcpd.stop() + + +""" + +--------------------------+ + | PTF | + +------+------------+------+ + | Send | | Recv | + +------+ +------+ + | Down | <--> | Init | + +------+ +------+ + | Init | <--> | Up | + +------+ +------+ + | Up | <--> | Up | + +------+ +------+ +""" + + +@group("bfdd_test") +class TestForBfdd(BaseTest): + def setUp(self): + self.dataplane = ptf.dataplane_instance + + def __init__(self): + BaseTest.__init__(self) + + def runTest(self): + try: + # Init & Start mrzcpd + mrzcpd = Mrzcpd(bfd_conf) + mrzcpd.start() + + """ + +------+ +------+ + | Down | <--> | Init | + +------+ +------+ + """ + # Create bfd down packet + bfd_pkt_down = simple_bfd_packet(eth_dst="10:70:fd:03:c0:bd", eth_src="0a:0a:0a:0a:01:28", + ip_src="10.10.1.40", ip_dst="10.254.60.1", + sta=1, my_discriminator=1111, your_discriminator=0) + + verify_bfd_pkt_init = mask.Mask( + simple_bfd_packet(eth_dst="0a:0a:0a:0a:01:28", eth_src="10:70:fd:03:c0:bd", + ip_src="10.254.60.1", ip_dst="10.10.1.40", sta=2, your_discriminator=1111)) + + verify_bfd_pkt_init.set_do_not_care_scapy(UDP, "chksum") + verify_bfd_pkt_init.set_do_not_care_scapy(BFD, "flags") + verify_bfd_pkt_init.set_do_not_care_scapy(BFD, "my_discriminator") + + send_packet(self, 0, bfd_pkt_down) + verify_packets(self, verify_bfd_pkt_init, [0]) + + """ + +------+ +------+ + | Init | <--> | Up | + +------+ +------+ + """ + # Create bfd up packet + bfd_pkt_init = simple_bfd_packet(eth_dst="10:70:fd:03:c0:bd", eth_src="0a:0a:0a:0a:01:28", + ip_src="10.10.1.40", ip_dst="10.254.60.1", + sta=2, my_discriminator=1111, your_discriminator=0) + + verify_bfd_pkt_up = mask.Mask( + simple_bfd_packet(eth_dst="0a:0a:0a:0a:01:28", eth_src="10:70:fd:03:c0:bd", + ip_src="10.254.60.1", ip_dst="10.10.1.40", sta=3, your_discriminator=1111)) + + verify_bfd_pkt_up.set_do_not_care_scapy(UDP, "chksum") + verify_bfd_pkt_up.set_do_not_care_scapy(BFD, "flags") + verify_bfd_pkt_up.set_do_not_care_scapy(BFD, "my_discriminator") + + send_packet(self, 0, bfd_pkt_init) + verify_packets(self, verify_bfd_pkt_up, [0]) + + """ + +------+ +------+ + | Up | <--> | Up | + +------+ +------+ + """ + # Create bfd up packet + bfd_pkt_up = simple_bfd_packet(eth_dst="10:70:fd:03:c0:bd", eth_src="0a:0a:0a:0a:01:28", + ip_src="10.10.1.40", ip_dst="10.254.60.1", + sta=3, my_discriminator=1111, your_discriminator=0) + verify_bfd_pkt_up = mask.Mask( + simple_bfd_packet(eth_dst="0a:0a:0a:0a:01:28", eth_src="10:70:fd:03:c0:bd", + ip_src="10.254.60.1", ip_dst="10.10.1.40", sta=3, your_discriminator=1111)) + + verify_bfd_pkt_up.set_do_not_care_scapy(UDP, "chksum") + verify_bfd_pkt_up.set_do_not_care_scapy(BFD, "flags") + verify_bfd_pkt_up.set_do_not_care_scapy(BFD, "my_discriminator") + + send_packet(self, 0, bfd_pkt_up) + verify_packets(self, verify_bfd_pkt_up, [0]) + finally: + mrzcpd.stop() diff --git a/test/bridge_test.py b/test/bridge_test.py new file mode 100644 index 0000000..b8e912c --- /dev/null +++ b/test/bridge_test.py @@ -0,0 +1,258 @@ +import ptf +from ptf.base_tests import BaseTest +from ptf.testutils import * +from scapy.all import * +from mrzcpd import Mrzcpd +from common_pkt import * +import ptf.mask as mask + +bridge_conf = """ +[device] +device=veth0,veth1,veth2,veth3,veth4,veth5,veth6,veth7,veth8,veth9,veth10,veth11,veth12,veth13,veth14,veth15,veth16,veth17,veth18,veth19,veth20,veth21,veth22,veth23 +sz_tunnel=8192 +sz_buffer=0 + +[device:veth0] +ether=aa:aa:aa:aa:aa:a0 +promisc=1 +mtu=1500 +driver=2 +role=3 + +[device:veth1] +ether=aa:aa:aa:aa:aa:a1 +promisc=1 +mtu=1500 +driver=2 +role=3 + +[device:veth2] +ether=aa:aa:aa:aa:aa:a2 +promisc=1 +mtu=1500 +driver=2 +role=3 + +[device:veth3] +ether=aa:aa:aa:aa:aa:a3 +promisc=1 +mtu=1500 +driver=2 +role=3 + +[service] +iocore=1 +distmode=2 +hashmode=0 + +[eal] +virtaddr=0x600000000000 +loglevel=7 +nohuge=1 +mem=65535 + +[keepalive] +check_spinlock=1 + +[ctrlzone] +ctrlzone0=tunnat, 64 +ctrlzone1=vsys, 64 + +[pool] +create_mode=3 +sz_direct_pktmbuf=4096 +sz_indirect_pktmbuf=4096 +sz_cache=256 +sz_data=3000 + +[ctrlmsg] +listen_addr=0.0.0.0 +listen_port=46789 + +[rpc] +addr=127.0.0.1 +port=56789 + +# sid +[etherfabric_adapters] +sid_range_start=100 +sid_range_end=200 +max_rules=256 + +[vwires] +sid_range_start=300 +sid_range_end=400 +max_rules=256 + +[service_lb] +sid_range_start=1000 +sid_range_end=2000 + +# bridge +[bridge:0] +master_device=veth3 +devices=veth0,veth1,veth2,veth3 + +""" + +""" + +----------------------------------------------------------------------------------------------+ + | Name | veth0 | veth1 | veth2 | veth3 (master) | + +----------------------------------------------------------------------------------------------+ + | Mac | aa:aa:aa:aa:aa:a0 | aa:aa:aa:aa:aa:a1 | aa:aa:aa:aa:aa:a2 | aa:aa:aa:aa:aa:a3 | + +----------------------------------------------------------------------------------------------+ +""" + + +@group("unicast_test") +class TestForUnicastPkt(BaseTest): + + def setUp(self): + self.dataplane = ptf.dataplane_instance + + def __init__(self): + BaseTest.__init__(self) + + def runTest(self): + try: + # Init & Start mrzcpd + mrzcpd = Mrzcpd(bridge_conf) + mrzcpd.start() + + """ + +-------+ +-------+ + | veth3 | ---> | veth0 | + +-------+ +-------+ + """ + # Create packet + send_pkt = simple_tcp_packet(eth_dst='aa:aa:aa:aa:aa:a0', + eth_src='bb:bb:bb:bb:bb:b0') + verify_pkt = simple_tcp_packet(eth_dst='aa:aa:aa:aa:aa:a0', + eth_src='bb:bb:bb:bb:bb:b0') + send_packet(self, 3, send_pkt) + verify_packets(self, verify_pkt, [0]) + + """ + +-------+ +-------+ + | veth0 | ---> | veth1 | + +-------+ +-------+ + """ + # Create packet + send_pkt = simple_tcp_packet(eth_dst='aa:aa:aa:aa:aa:a1', + eth_src='bb:bb:bb:bb:bb:b0') + verify_pkt = simple_tcp_packet(eth_dst='aa:aa:aa:aa:aa:a1', + eth_src='bb:bb:bb:bb:bb:b0') + send_packet(self, 0, send_pkt) + verify_packets(self, verify_pkt, [1]) + + """ + +-------+ +-------+ + | veth1 | ---> | veth2 | + +-------+ +-------+ + """ + # Create packet + send_pkt = simple_tcp_packet(eth_dst='aa:aa:aa:aa:aa:a2', + eth_src='bb:bb:bb:bb:bb:b0') + verify_pkt = simple_tcp_packet(eth_dst='aa:aa:aa:aa:aa:a2', + eth_src='bb:bb:bb:bb:bb:b0') + send_packet(self, 1, send_pkt) + verify_packets(self, verify_pkt, [2]) + + """ + +-------+ +-------+ + | veth2 | ---> | veth3 | + +-------+ +-------+ + """ + # Create packet + send_pkt = simple_tcp_packet(eth_dst='aa:aa:aa:aa:aa:a3', + eth_src='bb:bb:bb:bb:bb:b0') + verify_pkt = simple_tcp_packet(eth_dst='aa:aa:aa:aa:aa:a3', + eth_src='bb:bb:bb:bb:bb:b0') + send_packet(self, 2, send_pkt) + verify_packets(self, verify_pkt, [3]) + + finally: + mrzcpd.stop() + + +""" + +-------+ + |---> | veth0 | + | +-------+ + | ++-------------------+ | +-------+ +| veth3 (broadcast) | -----|---> | veth1 | ++-------------------+ | +-------+ + | + | +-------+ + |---> | veth2 | + +-------+ +""" + + +@group("broadcast_test") +class TestForBroadcastPkt(BaseTest): + + def setUp(self): + self.dataplane = ptf.dataplane_instance + + def __init__(self): + BaseTest.__init__(self) + + def runTest(self): + try: + # Init & Start mrzcpd + mrzcpd = Mrzcpd(bridge_conf) + mrzcpd.start() + + # Create packet + send_pkt = simple_tcp_packet(eth_dst='ff:ff:ff:ff:ff:ff', + eth_src='bb:bb:bb:bb:bb:b0') + verify_pkt = simple_tcp_packet(eth_dst='ff:ff:ff:ff:ff:ff', + eth_src='bb:bb:bb:bb:bb:b0') + send_packet(self, 3, send_pkt) + verify_packets(self, verify_pkt, [0, 1, 2]) + + finally: + mrzcpd.stop() + + +""" + +-------+ + | veth1 | + +-------+ + ++--------------------------+ +-------+ +| veth0 (unknown dst mac ) | ---| | veth2 | ++--------------------------+ | +-------+ + | + | +----------------+ + |---> | veth3 (master) | + +----------------+ +""" + + +@group("master_device_test") +class TestForMasterDevice(BaseTest): + def setUp(self): + self.dataplane = ptf.dataplane_instance + + def __init__(self): + BaseTest.__init__(self) + + def runTest(self): + try: + # Init & Start mrzcpd + mrzcpd = Mrzcpd(bridge_conf) + mrzcpd.start() + + # Create packet + send_pkt = simple_tcp_packet(eth_dst='11:11:11:11:11:11', + eth_src='bb:bb:bb:bb:bb:b0') + verify_pkt = simple_tcp_packet(eth_dst='11:11:11:11:11:11', + eth_src='bb:bb:bb:bb:bb:b0') + send_packet(self, 0, send_pkt) + verify_packets(self, verify_pkt, [3]) + + finally: + mrzcpd.stop() diff --git a/test/classifier_test.py b/test/classifier_test.py new file mode 100644 index 0000000..5bfe379 --- /dev/null +++ b/test/classifier_test.py @@ -0,0 +1,611 @@ +import ptf +from ptf.base_tests import BaseTest +from ptf.testutils import * +from scapy.all import * +from mrzcpd import Mrzcpd +from common_pkt import * + +base_conf = """ +[device] +device=veth0,veth1,veth2,veth3,veth4 +sz_tunnel=8192 +sz_buffer=0 + +[device:veth0] +promisc=1 +mtu=1500 +driver=2 +role=1 + +[device:veth1] +promisc=1 +mtu=1500 +driver=2 +role=1 + +[device:veth2] +promisc=1 +mtu=1500 +driver=2 +role=1 + +[device:veth3] +promisc=1 +mtu=1500 +driver=2 +role=1 + +[device:veth4] +promisc=1 +mtu=1500 +driver=2 +role=1 + +[service] +iocore=1 +distmode=2 +hashmode=0 + +[eal] +virtaddr=0x600000000000 +loglevel=7 +nohuge=1 +mem=65535 + +[keepalive] +check_spinlock=1 + +[ctrlzone] +ctrlzone0=tunnat, 64 +ctrlzone1=vsys, 64 + +[pool] +create_mode=3 +sz_direct_pktmbuf=4096 +sz_indirect_pktmbuf=4096 +sz_cache=256 +sz_data=3000 + +[ctrlmsg] +listen_addr=0.0.0.0 +listen_port=46789 + +[rpc] +addr=127.0.0.1 +port=56789 + +# sid +[etherfabric_adapters] +sid_range_start=100 +sid_range_end=200 +max_rules=256 + +[vwires] +sid_range_start=300 +sid_range_end=400 +max_rules=256 + +# vwire +[vwire:0] +interface_int=veth3 +interface_ext=veth4 + +[service_lb] +sid_range_start=1000 +sid_range_end=2000 + +# load banlance +[load_balance:0] +mode=balance +devices=veth0,normal + +[load_balance:1] +mode=balance +devices=veth1,normal + +[load_balance:2] +mode=balance +devices=veth2,normal + +[classifier_rule:0] +rule_id=1 +dst_ip_addr_v4=172.17.2.100 +dst_ip_mask_v4=32 +action=nf_steering +priority=1 +category=0 +sid=1000 +vwire_id=0 + +[classifier_rule:1] +rule_id=2 +src_ip_addr_v4=172.17.2.100 +src_ip_mask_v4=32 +action=nf_steering +priority=1 +category=0 +sid=1000 +vwire_id=0 + +[classifier_rule:2] +rule_id=3 +dst_ip_addr_v4=172.17.2.101 +dst_ip_mask_v4=32 +action=nf_steering +priority=1 +category=0 +sid=1001 +vwire_id=0 + +[classifier_rule:3] +rule_id=4 +src_ip_addr_v4=172.17.2.101 +src_ip_mask_v4=32 +action=nf_steering +priority=1 +category=0 +sid=1001 +vwire_id=0 + +[classifier_rule:4] +rule_id=5 +dst_ip_addr_v4=172.17.2.102 +dst_ip_mask_v4=32 +action=nf_steering +priority=1 +category=0 +sid=1002 +vwire_id=0 + +[classifier_rule:5] +rule_id=6 +src_ip_addr_v4=172.17.2.102 +src_ip_mask_v4=32 +action=nf_steering +priority=1 +category=0 +sid=1002 +vwire_id=0 +""" +""" + +----------------------+ +----------------------+ + | DstIP=172.17.2.100 | | DstIP=172.17.2.101 | + +----------------------+ +----------------------+ + | | + V V + +-------------------------------------------------+ + | Classifier Table | + +-------------------------------------------------+ + | | + V V + +---------------------+ +---------------------+ + | ClassifierRuleID1 | | ClassifierRuleID2 | + +---------------------+ +---------------------+ + | | + V V + +------------------------------------------------+ + | Forwarding | + +------------------------------------------------+ + | | + V V + +-------------------+ +-------------------+ + | veth0 port | | veth1 port | + +-------------------+ +-------------------+ +""" + + +@group("classfier_base_test") +class TestForBase(BaseTest): + def setUp(self): + self.dataplane = ptf.dataplane_instance + + def __init__(self): + BaseTest.__init__(self) + + def runTest(self): + try: + # Init & Start mrzcpd + mrzcpd = Mrzcpd(base_conf) + mrzcpd.start() + + # Check classifier rule id 1 - 3 + for i in range(0, 3): + # Create packet for classifier rule id + send_pkt = simple_tcp_packet( + ip_src="172.17.1.100", ip_dst="172.17.2." + str(100 + i)) + verify_pkt = simple_tcp_packet( + ip_src="172.17.1.100", ip_dst="172.17.2." + str(100 + i)) + send_packet(self, 3, send_pkt) + verify_packets(self, verify_pkt, [i]) + + # Check classifier rule id 4 - 6 + for i in range(0, 3): + # Create packet for classifier rule id + send_pkt = simple_tcp_packet( + ip_src="172.17.2." + str(100 + i), ip_dst="172.17.1.100") + verify_pkt = simple_tcp_packet(ip_src="172.17.2." + str(100 + i), + ip_dst="172.17.1.100") + send_packet(self, 4, send_pkt) + verify_packets(self, verify_pkt, [i]) + + # Check miss packet + send_pkt = simple_tcp_packet( + ip_src="172.17.3.100", ip_dst="172.17.1.100") + verify_pkt = simple_tcp_packet( + ip_src="172.17.3.100", ip_dst="172.17.1.100") + send_packet(self, 4, send_pkt) + verify_packets(self, verify_pkt, [3]) + + finally: + mrzcpd.stop() + + +priority_conf = """ +[device] +device=veth0,veth1,veth2,veth3 +sz_tunnel=8192 +sz_buffer=0 + +[device:veth0] +promisc=1 +mtu=1500 +driver=2 +role=1 + +[device:veth1] +promisc=1 +mtu=1500 +driver=2 +role=1 + +[device:veth2] +promisc=1 +mtu=1500 +driver=2 +role=1 + +[device:veth3] +promisc=1 +mtu=1500 +driver=2 +role=1 + +[service] +iocore=1 +distmode=2 +hashmode=0 + +[eal] +virtaddr=0x600000000000 +loglevel=7 +nohuge=1 +mem=65535 + +[keepalive] +check_spinlock=1 + +[ctrlzone] +ctrlzone0=tunnat, 64 +ctrlzone1=vsys, 64 + +[pool] +create_mode=3 +sz_direct_pktmbuf=4096 +sz_indirect_pktmbuf=4096 +sz_cache=256 +sz_data=3000 + +[ctrlmsg] +listen_addr=0.0.0.0 +listen_port=46789 + +[rpc] +addr=127.0.0.1 +port=56789 + +# sid +[etherfabric_adapters] +sid_range_start=100 +sid_range_end=200 +max_rules=256 + +[vwires] +sid_range_start=300 +sid_range_end=400 +max_rules=256 + +# vwire +[vwire:0] +interface_int=veth2 +interface_ext=veth3 + +[service_lb] +sid_range_start=1000 +sid_range_end=2000 + +# load banlance +[load_balance:0] +mode=balance +devices=veth0,normal + +[load_balance:1] +mode=balance +devices=veth1,normal + +[classifier_rule:0] +rule_id=1 +dst_ip_addr_v4=172.17.2.100 +dst_ip_mask_v4=32 +action=nf_steering +priority=100 +category=0 +sid=1000 +vwire_id=0 + +[classifier_rule:2] +rule_id=3 +dst_ip_addr_v4=172.17.2.100 +dst_ip_mask_v4=32 +action=nf_steering +priority=200 +category=0 +sid=1001 +vwire_id=0 +""" +""" + +----------------------+ + | DstIP=172.17.2.100 | + +----------------------+ + | + V + +-------------------------------------------------+ + | Classifier Table | + +-------------------------------------------------+ + | | + V V + +---------------------+ +---------------------+ + | ClassifierRuleID1 | | ClassifierRuleID2 | + | Priority=100 | | Priority=200 | + +---------------------+ +---------------------+ + | + V + +------------------------------------------------+ + | Forwarding | + +------------------------------------------------+ + | + V + +-------------------+ +-------------------+ + | veth0 port | | veth1 port | + +-------------------+ +-------------------+ +""" + + +@group("priority_test") +class TestForPriority(BaseTest): + def setUp(self): + self.dataplane = ptf.dataplane_instance + + def __init__(self): + BaseTest.__init__(self) + + def runTest(self): + try: + # Init & Start mrzcpd + mrzcpd = Mrzcpd(priority_conf) + mrzcpd.start() + + # Create packet + send_pkt = simple_tcp_packet( + ip_src="172.17.1.100", ip_dst="172.17.2.100") + verify_pkt = simple_tcp_packet( + ip_src="172.17.1.100", ip_dst="172.17.2.100") + send_packet(self, 2, send_pkt) + verify_packets(self, verify_pkt, [1]) + finally: + mrzcpd.stop() + + +category_conf = """Current not support category""" + +full_field_match_conf = """ +[device] +device=veth0,veth1,veth2,veth3 +sz_tunnel=8192 +sz_buffer=0 + +[device:veth0] +promisc=1 +mtu=1500 +driver=2 +role=1 + +[device:veth1] +promisc=1 +mtu=1500 +driver=2 +role=1 + +[device:veth2] +promisc=1 +mtu=1500 +driver=2 +role=1 + +[device:veth3] +promisc=1 +mtu=1500 +driver=2 +role=1 + +[service] +iocore=1 +distmode=2 +hashmode=0 + +[eal] +virtaddr=0x600000000000 +loglevel=7 +nohuge=1 +mem=65535 + +[keepalive] +check_spinlock=1 + +[ctrlzone] +ctrlzone0=tunnat, 64 +ctrlzone1=vsys, 64 + +[pool] +create_mode=3 +sz_direct_pktmbuf=4096 +sz_indirect_pktmbuf=4096 +sz_cache=256 +sz_data=3000 + +[ctrlmsg] +listen_addr=0.0.0.0 +listen_port=46789 + +[rpc] +addr=127.0.0.1 +port=56789 + +# sid +[etherfabric_adapters] +sid_range_start=100 +sid_range_end=200 +max_rules=256 + +[vwires] +sid_range_start=300 +sid_range_end=400 +max_rules=256 + +# vwire +[vwire:0] +interface_int=veth2 +interface_ext=veth3 + +[service_lb] +sid_range_start=1000 +sid_range_end=2000 + +# load banlance +[load_balance:0] +mode=balance +devices=veth0,normal + +[load_balance:1] +mode=balance +devices=veth1,normal + +[classifier_rule:0] +rule_id=1 +src_ip_addr_v4=172.17.1.100 +src_ip_mask_v4=32 +dst_ip_addr_v4=172.17.2.100 +dst_ip_mask_v4=32 +src_port_range_start=1000 +src_port_range_end=1000 +dst_port_range_start=80 +dst_port_range_end=80 +proto=tcp +priority=1 +sid=1000 +category=0 +vwire_id=0 +action=nf_steering + +[classifier_rule:1] +rule_id=2 +src_ip_addr_v6=1111::8888 +src_ip_mask_v6=128 +dst_ip_addr_v6=2222::9999 +dst_ip_mask_v6=128 +src_port_range_start=1000 +src_port_range_end=1000 +dst_port_range_start=80 +dst_port_range_end=80 +proto=udp +priority=1 +sid=1001 +category=0 +vwire_id=0 +action=nf_steering + +""" +""" + +----------------------+ +----------------------+ + | IPv4=172.17.2.100 | | IPv6=2222::9999 | + +----------------------+ +----------------------+ + | | + V V + +-------------------------------------------------+ + | Classifier Table | + +-------------------------------------------------+ + | | + V V + +---------------------+ +---------------------+ + | ClassifierRuleID1 | | ClassifierRuleID2 | + +---------------------+ +---------------------+ + | | + V V + +------------------------------------------------+ + | Forwarding | + +------------------------------------------------+ + | | + V V + +-------------------+ +-------------------+ + | veth0 port | | veth1 port | + +-------------------+ +-------------------+ +""" + + +@group("full_field_match_test") +class TestForFullFieldMatch(BaseTest): + def setUp(self): + self.dataplane = ptf.dataplane_instance + + def __init__(self): + BaseTest.__init__(self) + + def runTest(self): + try: + # Init & Start mrzcpd + mrzcpd = Mrzcpd(full_field_match_conf) + mrzcpd.start() + + # Check IPv4 for miss + send_pkt = simple_tcp_packet( + ip_src="172.17.1.100", ip_dst="172.17.2.100", tcp_sport=1000, tcp_dport=1000) + verify_pkt = simple_tcp_packet( + ip_src="172.17.1.100", ip_dst="172.17.2.100", tcp_sport=1000, tcp_dport=1000) + send_packet(self, 3, send_pkt) + verify_packets(self, verify_pkt, [2]) + + # Check IPv4 for match + send_pkt = simple_tcp_packet( + ip_src="172.17.1.100", ip_dst="172.17.2.100", tcp_sport=1000, tcp_dport=80) + verify_pkt = simple_tcp_packet( + ip_src="172.17.1.100", ip_dst="172.17.2.100", tcp_sport=1000, tcp_dport=80) + send_packet(self, 3, send_pkt) + verify_packets(self, verify_pkt, [0]) + + # Check IPv6 for miss + send_pkt = simple_udpv6_packet( + ipv6_src="1111::8888", ipv6_dst="2222::9999", udp_sport=1000, udp_dport=1000) + verify_pkt = simple_udpv6_packet( + ipv6_src="1111::8888", ipv6_dst="2222::9999", udp_sport=1000, udp_dport=1000) + send_packet(self, 2, send_pkt) + verify_packets(self, verify_pkt, [3]) + + # Check IPv6 for match + send_pkt = simple_udpv6_packet( + ipv6_src="1111::8888", ipv6_dst="2222::9999", udp_sport=1000, udp_dport=80) + verify_pkt = simple_udpv6_packet( + ipv6_src="1111::8888", ipv6_dst="2222::9999", udp_sport=1000, udp_dport=80) + send_packet(self, 2, send_pkt) + verify_packets(self, verify_pkt, [1]) + + finally: + mrzcpd.stop() diff --git a/test/common_pkt.py b/test/common_pkt.py new file mode 100644 index 0000000..e999253 --- /dev/null +++ b/test/common_pkt.py @@ -0,0 +1,59 @@ +import ptf +import random +import ipaddress +from ptf.testutils import * +from ptf.thriftutils import * +from scapy.all import * +from scapy.contrib.bfd import BFD + + +def simple_bfd_packet( + eth_dst="10:70:fd:03:c0:bd", + eth_src="0a:0a:0a:0a:01:28", + ip_src="10.10.1.40", + ip_dst="10.254.60.1", + udp_sport=3784, + udp_dport=3784, + sta=0, + my_discriminator=1, + your_discriminator=2, +): + """ + Return a simple BFD packet + """ + bfd = BFD(sta=sta, my_discriminator=my_discriminator, + your_discriminator=your_discriminator) + + pkt = simple_udp_packet( + eth_dst=eth_dst, + eth_src=eth_src, + ip_src=ip_src, + ip_dst=ip_dst, + udp_sport=udp_sport, + udp_dport=udp_dport, + udp_payload=bfd + ) + return pkt + + +def generate_random_tcp_port(): + """ + 生成随机的 TCP 端口号 + """ + return random.randint(1024, 65535) + + +def generate_random_ipv4(): + """ + 生成随机的 IPv4 地址 + """ + # 随机生成四个 0-255 之间的数字 + octets = [str(random.randint(0, 255)) for _ in range(4)] + # 将四个数字组合成一个 IPv4 地址 + ip_addr = ".".join(octets) + # 将字符串类型的 IP 地址转换为 IPv4Address 对象 + return ipaddress.IPv4Address(ip_addr) + + +def get_port_packet_count(self, port): + return self.dataplane.rx_counters[port] diff --git a/test/etherfabric_test.py b/test/etherfabric_test.py new file mode 100644 index 0000000..3de47e6 --- /dev/null +++ b/test/etherfabric_test.py @@ -0,0 +1,105 @@ +import ptf +from ptf.base_tests import BaseTest +from ptf.testutils import * +from scapy.all import * +from mrzcpd import Mrzcpd +from common_pkt import * + +base_conf = """ +[device] +device=veth0 +sz_tunnel=8192 +sz_buffer=0 + +[device:veth0] +in_addr=10.254.60.1 +in_mask=255.255.255.0 +gateway=10.10.1.40 +promisc=1 +mtu=1500 +driver=2 +role=3 + +[service] +iocore=1 +distmode=2 +hashmode=0 + +[eal] +virtaddr=0x600000000000 +loglevel=7 +nohuge=1 +mem=65535 + +[keepalive] +check_spinlock=1 + +[ctrlzone] +ctrlzone0=tunnat, 64 +ctrlzone1=vsys, 64 + +[pool] +create_mode=3 +sz_direct_pktmbuf=4096 +sz_indirect_pktmbuf=4096 +sz_cache=256 +sz_data=3000 + +[ctrlmsg] +listen_addr=0.0.0.0 +listen_port=46789 + +[rpc] +addr=127.0.0.1 +port=56789 + +# sid +[etherfabric_adapters] +sid_range_start=100 +sid_range_end=200 +max_rules=256 + +[vwires] +sid_range_start=300 +sid_range_end=400 +max_rules=256 + +[service_lb] +sid_range_start=1000 +sid_range_end=2000 + +[etherfabric_adapters] +sid_range_start=100 +sid_range_end=200 +max_rules=256 + +[etherfabric_adapter:0] +mode=virtual-wire +listen_device=veth0 +""" + + +@group("etherfabric_base_test") +class TestForBase(BaseTest): + def setUp(self): + self.dataplane = ptf.dataplane_instance + + def __init__(self): + BaseTest.__init__(self) + + def runTest(self): + try: + # Init & Start mrzcpd + mrzcpd = Mrzcpd(base_conf) + mrzcpd.start() + + send_pkt = simple_vxlan_packet( + eth_src='0a:0a:0a:0a:01:28', eth_dst='10:70:fd:03:c0:bd', + ip_src='10.254.50.1', ip_dst='10.254.60.1', vxlan_vni=32) + verify_pkt = simple_vxlan_packet( + eth_src='10:70:fd:03:c0:bd', eth_dst='0a:0a:0a:0a:01:28', + ip_src='10.254.60.1', ip_dst='10.254.50.1', vxlan_vni=32) + send_packet(self, 0, send_pkt) + verify_packets(self, verify_pkt, [0]) + finally: + mrzcpd.stop() diff --git a/test/health_check_test.py b/test/health_check_test.py new file mode 100644 index 0000000..d99357e --- /dev/null +++ b/test/health_check_test.py @@ -0,0 +1,113 @@ +import ptf +from ptf.base_tests import BaseTest +from ptf.testutils import * +from scapy.all import * +from mrzcpd import Mrzcpd +from common_pkt import * +import ptf.mask as mask + +base_conf = """ +[device] +device=veth0 +sz_tunnel=8192 +sz_buffer=0 + +[device:veth0] +promisc=1 +mtu=1500 +driver=2 +role=1 + +[service] +iocore=1 +distmode=2 +hashmode=0 + +[eal] +virtaddr=0x600000000000 +loglevel=7 +nohuge=1 +mem=65535 + +[keepalive] +check_spinlock=1 + +[ctrlzone] +ctrlzone0=tunnat, 64 +ctrlzone1=vsys, 64 + +[pool] +create_mode=3 +sz_direct_pktmbuf=4096 +sz_indirect_pktmbuf=4096 +sz_cache=256 +sz_data=3000 + +[ctrlmsg] +listen_addr=0.0.0.0 +listen_port=46789 + +[rpc] +addr=127.0.0.1 +port=56789 + +# sid +[etherfabric_adapters] +sid_range_start=100 +sid_range_end=200 +max_rules=256 + +[vwires] +sid_range_start=300 +sid_range_end=400 +max_rules=256 + +# health check +[health_check:0] +name=veth0_health_check +device=veth0 +method=private +multiplier=20 +interval=10 + +[service_lb] +sid_range_start=1000 +sid_range_end=2000 + +# load banlance +[load_balance:0] +mode=balance +devices=veth0,normal +health_check_sessions=veth0_health_check + +""" + + +@group("health_check_base_test") +class HealthCheckBaseTest(BaseTest): + def setUp(self): + self.dataplane = ptf.dataplane_instance + + def __init__(self): + BaseTest.__init__(self) + + def runTest(self): + try: + # Init & Start mrzcpd + mrzcpd = Mrzcpd(base_conf) + mrzcpd.start() + + (_, _, rcv_pkt, _) = dp_poll( + self, device_number=0, port_number=0, timeout=20 + ) + + verify_health_check_pkt = mask.Mask( + simple_eth_packet(eth_type=0xaaaa, pktlen=22)) + verify_health_check_pkt.set_do_not_care(0, 12*8) + verify_health_check_pkt.set_do_not_care(14*8, 8*8) + + send_packet(self, 0, rcv_pkt) + verify_packet(self, verify_health_check_pkt, 0) + + finally: + mrzcpd.stop() diff --git a/test/load_balance_test.py b/test/load_balance_test.py new file mode 100644 index 0000000..36c513a --- /dev/null +++ b/test/load_balance_test.py @@ -0,0 +1,261 @@ +import ptf +from ptf.base_tests import BaseTest +from ptf.testutils import * +from scapy.all import * +from mrzcpd import Mrzcpd +from common_pkt import * +import ptf.mask as mask + +lb_base_conf = """ +[device] +device=veth0,veth1,veth2,veth3,veth4 +sz_tunnel=8192 +sz_buffer=0 + +[device:veth0] +promisc=1 +mtu=1500 +driver=2 +role=1 + +[device:veth1] +promisc=1 +mtu=1500 +driver=2 +role=1 + +[device:veth2] +promisc=1 +mtu=1500 +driver=2 +role=1 + +[device:veth3] +promisc=1 +mtu=1500 +driver=2 +role=1 + +[device:veth4] +promisc=1 +mtu=1500 +driver=2 +role=1 + +[service] +iocore=1 +distmode=2 +hashmode=0 + +[eal] +virtaddr=0x600000000000 +loglevel=7 +nohuge=1 +mem=65535 + +[keepalive] +check_spinlock=1 + +[ctrlzone] +ctrlzone0=tunnat, 64 +ctrlzone1=vsys, 64 + +[pool] +create_mode=3 +sz_direct_pktmbuf=4096 +sz_indirect_pktmbuf=4096 +sz_cache=256 +sz_data=3000 + +[ctrlmsg] +listen_addr=0.0.0.0 +listen_port=46789 + +[rpc] +addr=127.0.0.1 +port=56789 + +# sid +[etherfabric_adapters] +sid_range_start=100 +sid_range_end=200 +max_rules=256 + +[vwires] +sid_range_start=300 +sid_range_end=400 +max_rules=256 + +# vwire +[vwire:0] +interface_int=veth3 +interface_ext=veth4 + +[service_lb] +sid_range_start=1000 +sid_range_end=2000 + +# load banlance +[load_balance:0] +mode=balance +devices=veth0,normal,veth1,normal,veth2,normal + +[classifier_rule:0] +rule_id=1 +action=nf_steering +priority=1 +category=0 +sid=1000 +vwire_id=0 +""" + +""" + +-------+ +-------+ +------------+ + | Vwire | | LB | | PTF | + +-------+ +-------+ 100 +------------+ + | veth3 | | veth0 | ----> | veth0-ptf0 | + +-------+ 300 +-------+ 100 +------------+ + | veth4 | ----> | veth1 | ----> | veth1-ptf1 | + +-------+ +-------+ 100 +------------+ + | veth2 | ----> | veth2-ptf2 | + +-------+ +------------+ +""" + + +@group("lb_base_test") +class TestForBase(BaseTest): + def setUp(self): + self.dataplane = ptf.dataplane_instance + + def __init__(self): + BaseTest.__init__(self) + + def runTest(self): + try: + # Init & Start mrzcpd + mrzcpd = Mrzcpd(lb_base_conf) + mrzcpd.start() + + # Create packet list + send_pkt_list = PacketList() + + # Create send packet + for port in range(0, 300): + pkt = simple_tcp_packet(ip_src=generate_random_ipv4(), ip_dst=generate_random_ipv4( + ), tcp_sport=generate_random_tcp_port(), tcp_dport=generate_random_tcp_port()) + send_pkt_list.append(pkt) + + # Send packet + for pkt in send_pkt_list: + send_packet(self, 4, pkt) + + # Create verify packet + tcp_pkt = simple_tcp_packet() + verify_pkt = mask.Mask(tcp_pkt) + verify_pkt.set_do_not_care(0, len(tcp_pkt) * 8) + + # Wait for a while to ensure enough packets arrive + time.sleep(3) + + # Get packet count for each port + packet_counts = [] + for port in range(0, 3): + packet_count = get_port_packet_count(self, (0, port)) + print("port {} packet count: {}".format(port, packet_count)) + packet_counts.append(packet_count) + + # Calculate average packet count + average_packet_count = sum(packet_counts) / len(packet_counts) + + # Set tolerance + tolerance = 0.15 * average_packet_count + + # Check if packet count is abnormal + for port in range(0, 3): + if abs(packet_counts[port] - average_packet_count) > tolerance: + self.fail("Port %d has an abnormal packet count: %d (average is %d)" % ( + port, packet_counts[port], average_packet_count)) + + finally: + mrzcpd.stop() + + +""" + +-------+ +--------------+ +------------+ + | Vwire | | LB | | PTF | + +-------+ +--------------+ 150 +------------+ + | veth3 | | veth0 | ----> | veth0-ptf0 | + +-------+ 300 +--------------+ 150 +------------+ + | veth4 | ----> | veth1 | ----> | veth1-ptf1 | + +-------+ +--------------+ 0 +------------+ + | veth2 (down) | ----> | veth2-ptf2 | + +--------------+ +------------+ +""" + + +# The test current is invalid,because 'ifconfig veth2 down' can't affect the mrzcpd link status. +@group("lb_one_dev_down_test") +class TestForOneDevDown(BaseTest): + def setUp(self): + self.dataplane = ptf.dataplane_instance + + def __init__(self): + BaseTest.__init__(self) + + def runTest(self): + try: + # Init & Start mrzcpd + mrzcpd = Mrzcpd(lb_base_conf) + mrzcpd.start() + + # Set veth2 down + os.system("ifconfig veth2 down") + + # Create packet list + send_pkt_list = PacketList() + + # Create send packet + for port in range(0, 300): + pkt = simple_tcp_packet(ip_src=generate_random_ipv4(), ip_dst=generate_random_ipv4( + ), tcp_sport=generate_random_tcp_port(), tcp_dport=generate_random_tcp_port()) + send_pkt_list.append(pkt) + + # Send packet + for pkt in send_pkt_list: + send_packet(self, 4, pkt) + + # Create verify packet + tcp_pkt = simple_tcp_packet() + verify_pkt = mask.Mask(tcp_pkt) + verify_pkt.set_do_not_care(0, len(tcp_pkt) * 8) + + # Wait for a while to ensure enough packets arrive + time.sleep(3) + + # Get packet count for each port + packet_counts = [] + for port in range(0, 2): + packet_count = get_port_packet_count(self, (0, port)) + print("port {} packet count: {}".format(port, packet_count)) + packet_counts.append(packet_count) + + # Calculate average packet count + average_packet_count = sum(packet_counts) / len(packet_counts) + + # Set tolerance + tolerance = 0.15 * average_packet_count + + # Check veth2 rx packet count + if get_port_packet_count(self, (0, 2)) != 0: + self.fail("veth2 is down, but rx packet count is not 0") + + # Check if packet count is abnormal + for port in range(0, 2): + if abs(packet_counts[port] - average_packet_count) > tolerance: + self.fail("Port %d has an abnormal packet count: %d (average is %d)" % ( + port, packet_counts[port], average_packet_count)) + + finally: + # Set veth2 up + os.system("ifconfig veth2 up") + mrzcpd.stop() diff --git a/test/mrzcpd.py b/test/mrzcpd.py index dbb2455..19382e2 100644 --- a/test/mrzcpd.py +++ b/test/mrzcpd.py @@ -4,7 +4,6 @@ import os import signal import subprocess import shutil -from subprocess import Popen, PIPE mrzcpd_run_dir = "/var/run/mrzcpd" @@ -27,7 +26,7 @@ class Mrzcpd: os.makedirs(mrzcpd_run_dir) # Start mrzcpd - mrzcpd_process = Popen( + self.mrzcpd_process = subprocess.Popen( [self.mrzcpd_path, "-c", self.conf_path], stdout=subprocess.PIPE) # Check mrzcpd status @@ -39,11 +38,6 @@ class Mrzcpd: time.sleep(1) start_timeout = start_timeout - 1 - # Save mrzcpd pid - self.pid = mrzcpd_process.pid - print("start mrzcpd,pid is:", self.pid) - def stop(self): - print("stop mrzcpd,pid is:", self.pid) - os.kill(self.pid, signal.SIGKILL) - os.waitpid(self.pid, 0) + self.mrzcpd_process.terminate() + self.mrzcpd_process.wait() diff --git a/test/demo_test.py b/test/vwire_test.py index e99a26c..79ca7ff 100644 --- a/test/demo_test.py +++ b/test/vwire_test.py @@ -5,7 +5,7 @@ from ptf.testutils import * from scapy.all import * from mrzcpd import Mrzcpd -conf_demo = """ +vwire_conf = """ [device] device = veth0,veth1,veth2,veth3,veth4,veth5,veth6,veth7,veth8,veth9,veth10,veth11,veth12,veth13,veth14,veth15,veth16,veth17,veth18,veth19,veth20,veth21,veth22,veth23 sz_tunnel = 8192 @@ -202,47 +202,79 @@ max_rules=256 [service_lb] sid_range_start=1000 sid_range_end=2000 + # vwire [vwire:0] interface_int = veth0 interface_ext = veth1 + [vwire:1] interface_int = veth2 interface_ext = veth3 + [vwire:2] interface_int = veth4 interface_ext = veth5 + [vwire:3] interface_int = veth6 interface_ext = veth7 + [vwire:4] interface_int = veth8 interface_ext = veth9 + [vwire:5] interface_int = veth10 interface_ext = veth11 + [vwire:6] interface_int = veth12 interface_ext = veth13 + [vwire:7] interface_int = veth14 interface_ext = veth15 + [vwire:8] interface_int = veth16 interface_ext = veth17 + [vwire:9] interface_int = veth18 interface_ext = veth19 + [vwire:10] interface_int = veth20 interface_ext = veth21 + [vwire:11] interface_int = veth22 interface_ext = veth23 """ +""" + +--------------+ +----------+ + | PTF | | Mrzcpd | + +--------------+ +----------+ + | veth0-ptf0 | ---> | veth0 | + +--------------+ +----------+ + | veth1-ptf1 | <--- | veth1 | + +--------------+ +----------+ + | veth2-ptf2 | ---> | veth2 | + +--------------+ +----------+ + | veth3-ptf3 | <--- | veth3 | + +--------------+ +----------+ + | ... ... | ... | ... | + +--------------+ +----------+ + | veth22-ptf22 | ---> | veth22 | + +--------------+ +----------+ + | veth23-ptf23 | <--- | veth23 | + +--------------+ +----------+ +""" + -@group("demo_test") +@group("vwire_test") class TestSendAndReceive(BaseTest): # Base test init def __init__(self): @@ -254,23 +286,24 @@ class TestSendAndReceive(BaseTest): # Run test def runTest(self): - # Init & Start mrzcpd - mrzcpd = Mrzcpd(conf_demo) - mrzcpd.start() - - # Create packet - pkt = simple_tcp_packet(eth_dst='00:11:11:11:11:11', - eth_src='00:22:22:22:22:22', - ip_dst='10.0.0.1', - ip_id=101, - ip_ttl=64) - - # Traverse all ports - for i in range(0, 24, 2): - # Send pkt for the port - send_packet(self, i, pkt) - # Verify pkt for specified port - verify_packets(self, pkt, [i+1]) - - # Stop mrzcpd end test - mrzcpd.stop() + try: + # Init & Start mrzcpd + mrzcpd = Mrzcpd(vwire_conf) + mrzcpd.start() + + # Create packet + pkt = simple_tcp_packet(eth_dst='00:11:11:11:11:11', + eth_src='00:22:22:22:22:22', + ip_dst='10.0.0.1', + ip_id=101, + ip_ttl=64) + + # Traverse all ports + for i in range(0, 24, 2): + # Send pkt for the port + send_packet(self, i, pkt) + # Verify pkt for specified port + verify_packets(self, pkt, [i+1]) + + finally: + mrzcpd.stop() |
