diff options
| author | songyanchao <[email protected]> | 2023-04-17 02:35:16 +0000 |
|---|---|---|
| committer | songyanchao <[email protected]> | 2023-04-17 02:35:16 +0000 |
| commit | ecbbdd7c731d799537cf9c22e672c4d11749466b (patch) | |
| tree | a666f67336b5d0965bea8220bf03173676e4268a /test | |
| parent | 873551c3285354394578eff59cccf4ce30752953 (diff) | |
🎈 perf: 优化Classifier test
优化Classifier test
Diffstat (limited to 'test')
| -rw-r--r-- | test/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | test/classifier_test.py | 167 |
2 files changed, 132 insertions, 38 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1712ae9..6bc5bb0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -26,7 +26,6 @@ endif() # for i in range(0, 24): # print(f"--interface {i}@veth{i}-ptf{i}", end=" ") - # Add vwire test add_test( NAME vwire_test @@ -56,7 +55,7 @@ add_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 + --interface 0@veth0-ptf0 --interface 1@veth1-ptf1 --interface 2@veth2-ptf2 --interface 3@veth3-ptf3 --interface 4@veth4-ptf4 --interface 5@veth5-ptf5 classfier_base_test priority_test full_field_match_test --test-params "source_dir='${CMAKE_SOURCE_DIR}'" ) diff --git a/test/classifier_test.py b/test/classifier_test.py index 5bfe379..8952601 100644 --- a/test/classifier_test.py +++ b/test/classifier_test.py @@ -7,7 +7,7 @@ from common_pkt import * base_conf = """ [device] -device=veth0,veth1,veth2,veth3,veth4 +device=veth0,veth1,veth2,veth3,veth4,veth5 sz_tunnel=8192 sz_buffer=0 @@ -41,6 +41,12 @@ mtu=1500 driver=2 role=1 +[device:veth5] +promisc=1 +mtu=1500 +driver=2 +role=1 + [service] iocore=1 distmode=2 @@ -87,8 +93,8 @@ max_rules=256 # vwire [vwire:0] -interface_int=veth3 -interface_ext=veth4 +interface_int=veth4 +interface_ext=veth5 [service_lb] sid_range_start=1000 @@ -107,6 +113,10 @@ devices=veth1,normal mode=balance devices=veth2,normal +[load_balance:3] +mode=balance +devices=veth3,normal + [classifier_rule:0] rule_id=1 dst_ip_addr_v4=172.17.2.100 @@ -119,53 +129,75 @@ vwire_id=0 [classifier_rule:1] rule_id=2 -src_ip_addr_v4=172.17.2.100 -src_ip_mask_v4=32 +dst_ip_addr_v4=172.17.2.101 +dst_ip_mask_v4=32 action=nf_steering priority=1 category=0 -sid=1000 +sid=1001 vwire_id=0 [classifier_rule:2] rule_id=3 -dst_ip_addr_v4=172.17.2.101 -dst_ip_mask_v4=32 +src_ip_addr_v4=172.17.2.102 +src_ip_mask_v4=32 action=nf_steering priority=1 category=0 -sid=1001 +sid=1002 vwire_id=0 [classifier_rule:3] rule_id=4 -src_ip_addr_v4=172.17.2.101 +src_ip_addr_v4=172.17.2.103 src_ip_mask_v4=32 action=nf_steering priority=1 category=0 -sid=1001 +sid=1003 vwire_id=0 [classifier_rule:4] rule_id=5 -dst_ip_addr_v4=172.17.2.102 -dst_ip_mask_v4=32 +dst_ip_addr_v6=2222::4 +dst_ip_mask_v6=128 action=nf_steering priority=1 category=0 -sid=1002 +sid=1000 vwire_id=0 [classifier_rule:5] rule_id=6 -src_ip_addr_v4=172.17.2.102 -src_ip_mask_v4=32 +dst_ip_addr_v6=2222::5 +dst_ip_mask_v6=128 +action=nf_steering +priority=1 +category=0 +sid=1001 +vwire_id=0 + +[classifier_rule:6] +rule_id=7 +src_ip_addr_v6=2222::6 +src_ip_mask_v6=128 action=nf_steering priority=1 category=0 sid=1002 vwire_id=0 + +[classifier_rule:7] +rule_id=8 +src_ip_addr_v6=2222::7 +src_ip_mask_v6=128 +action=nf_steering +priority=1 +category=0 +sid=1003 +vwire_id=0 + + """ """ +----------------------+ +----------------------+ @@ -208,33 +240,96 @@ class TestForBase(BaseTest): 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( + """ + +---------------------------+ +--------------------------------+ +--------------+ + | PTF | | MRZCPD | | PTF | + +---------------------------+ +--------------------------------+ +--------------+ + | Ipv4 DstIP=172.17.2.100 | ---> | RuleID=1, DstIP=172.17.2.100 | ---> | veth0-ptf0 | + +---------------------------+ +--------------------------------+ +--------------+ + | Ipv4 DstIP=172.17.2.101 | ---> | RuleID=2, DstIP=172.17.2.101 | ---> | veth1-ptf0 | + +---------------------------+ +--------------------------------+ +--------------+ + """ + + # Check classifier rule id 1 - 2, check ipv4 dst ip rule. + for i in range(0, 2): + # Create packet for classifier rule + verify_pkt = send_pkt = simple_tcp_packet( ip_src="172.17.1.100", ip_dst="172.17.2." + str(100 + i)) - send_packet(self, 3, send_pkt) + send_packet(self, 5, 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( + """ + +---------------------------+ +--------------------------------+ +--------------+ + | PTF | | MRZCPD | | PTF | + +---------------------------+ +--------------------------------+ +--------------+ + | Ipv4 SrcIP=172.17.2.102 | ---> | RuleID=3, SrcIP=172.17.2.102 | ---> | veth2-ptf2 | + +---------------------------+ +--------------------------------+ +--------------+ + | Ipv4 SrcIP=172.17.2.103 | ---> | RuleID=4, SrcIP=172.17.2.103 | ---> | veth3-ptf3 | + +---------------------------+ +--------------------------------+ +--------------+ + """ + + # Check classifier rule id 3 - 4, check ipv4 src ip rule. + for i in range(2, 4): + # Create packet for classifier rule + verify_pkt = 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) + + send_packet(self, 5, send_pkt) verify_packets(self, verify_pkt, [i]) + """ + +---------------------------+ +--------------------------------+ +--------------+ + | PTF | | MRZCPD | | PTF | + +---------------------------+ +--------------------------------+ +--------------+ + | Ipv6 DstIP= 2222::4 | ---> | RuleID=5, DstIP= 2222::4 | ---> | veth0-ptf0 | + +---------------------------+ +--------------------------------+ +--------------+ + | Ipv6 DstIP= 2222::5 | ---> | RuleID=6, DstIP= 2222::5 | ---> | veth1-ptf1 | + +---------------------------+ +--------------------------------+ +--------------+ + """ + + # Check classifier rule id 5 - 6, check ipv6 dst ip rule. + for i in range(4, 6): + # Create packet for classifier rule + verify_pkt = send_pkt = simple_tcpv6_packet( + ipv6_src="1111::8888", ipv6_dst="2222::" + str(i)) + + send_packet(self, 5, send_pkt) + verify_packets(self, verify_pkt, [i % 4]) + + """ + +---------------------------+ +--------------------------------+ +--------------+ + | PTF | | MRZCPD | | PTF | + +---------------------------+ +--------------------------------+ +--------------+ + | Ipv6 SrcIP= 2222::6 | ---> | RuleID=7, SrcIP= 2222::6 | ---> | veth2-ptf2 | + +---------------------------+ +--------------------------------+ +--------------+ + | Ipv6 SrcIP= 2222::7 | ---> | RuleID=8, SrcIP= 2222::7 | ---> | veth3-ptf3 | + +---------------------------+ +--------------------------------+ +--------------+ + """ + # Check classifier rule id 7 - 8, check ipv6 src ip rule. + for i in range(6, 8): + # Create packet for classifier rule + verify_pkt = send_pkt = simple_tcpv6_packet( + ipv6_src="2222::" + str(i), ipv6_dst="1111::8888") + + send_packet(self, 5, send_pkt) + verify_packets(self, verify_pkt, [i % 4]) + + """ + +---------------------------+ +---------+-----------------+---------+ +--------------+ + | PTF | | Vwire | Classifier | Vwire | | PTF | + +---------------------------+ +---------+-----------------+---------+ +--------------+ + | SrcIP=172.17.3.100 | | veth5 | No Match Rule | veth5 | ---> | veth5-ptf5 | + | DstIP=172.17.1.100 | ---> | veth4 | To Vwire | veth4 | | | + +---------------------------+ +---------+-----------------+---------+ +--------------+ + + """ + # 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( + verify_pkt = send_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]) + verify_packets(self, verify_pkt, [5]) finally: mrzcpd.stop() @@ -380,7 +475,7 @@ vwire_id=0 """ -@group("priority_test") +@ group("priority_test") class TestForPriority(BaseTest): def setUp(self): self.dataplane = ptf.dataplane_instance @@ -561,7 +656,7 @@ action=nf_steering """ -@group("full_field_match_test") +@ group("full_field_match_test") class TestForFullFieldMatch(BaseTest): def setUp(self): self.dataplane = ptf.dataplane_instance |
