summaryrefslogtreecommitdiffstats
path: root/test/test_classifier_ip6.py
diff options
context:
space:
mode:
authorKlement Sekera <klement.sekera@gmail.com>2022-04-26 19:02:15 +0200
committerOle Tr�an <otroan@employees.org>2022-05-10 18:52:08 +0000
commitd9b0c6fbf7aa5bd9af84264105b39c82028a4a29 (patch)
tree4f786cfd8ebc2443cb11e11b74c8657204068898 /test/test_classifier_ip6.py
parentf90348bcb4afd0af2611cefc43b17ef3042b511c (diff)
tests: replace pycodestyle with black
Drop pycodestyle for code style checking in favor of black. Black is much faster, stable PEP8 compliant code style checker offering also automatic formatting. It aims to be very stable and produce smallest diffs. It's used by many small and big projects. Running checkstyle with black takes a few seconds with a terse output. Thus, test-checkstyle-diff is no longer necessary. Expand scope of checkstyle to all python files in the repo, replacing test-checkstyle with checkstyle-python. Also, fixstyle-python is now available for automatic style formatting. Note: python virtualenv has been consolidated in test/Makefile, test/requirements*.txt which will eventually be moved to a central location. This is required to simply the automated generation of docker executor images in the CI. Type: improvement Change-Id: I022a326603485f58585e879ac0f697fceefbc9c8 Signed-off-by: Klement Sekera <klement.sekera@gmail.com> Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Diffstat (limited to 'test/test_classifier_ip6.py')
-rw-r--r--test/test_classifier_ip6.py220
1 files changed, 113 insertions, 107 deletions
diff --git a/test/test_classifier_ip6.py b/test/test_classifier_ip6.py
index 211374b5ec6..7b5d41c3eef 100644
--- a/test/test_classifier_ip6.py
+++ b/test/test_classifier_ip6.py
@@ -14,7 +14,7 @@ from template_classifier import TestClassifier
class TestClassifierIP6(TestClassifier):
- """ Classifier IP6 Test Case """
+ """Classifier IP6 Test Case"""
@classmethod
def setUpClass(cls):
@@ -26,7 +26,7 @@ class TestClassifierIP6(TestClassifier):
super(TestClassifierIP6, cls).tearDownClass()
def test_iacl_src_ip(self):
- """ Source IP6 iACL test
+ """Source IP6 iACL test
Test scenario for basic IP ACL with source IP
- Create IPv6 stream for pg0 -> pg1 interface.
@@ -38,13 +38,13 @@ class TestClassifierIP6(TestClassifier):
pkts = self.create_stream(self.pg0, self.pg1, self.pg_if_packet_sizes)
self.pg0.add_stream(pkts)
- key = 'ip6_src'
+ key = "ip6_src"
self.create_classify_table(
- key,
- self.build_ip6_mask(src_ip='ffffffffffffffffffffffffffffffff'))
+ key, self.build_ip6_mask(src_ip="ffffffffffffffffffffffffffffffff")
+ )
self.create_classify_session(
- self.acl_tbl_idx.get(key),
- self.build_ip6_match(src_ip=self.pg0.remote_ip6))
+ self.acl_tbl_idx.get(key), self.build_ip6_match(src_ip=self.pg0.remote_ip6)
+ )
self.input_acl_set_interface(self.pg0, self.acl_tbl_idx.get(key))
self.acl_active_table = key
@@ -57,7 +57,7 @@ class TestClassifierIP6(TestClassifier):
self.pg2.assert_nothing_captured(remark="packets forwarded")
def test_iacl_dst_ip(self):
- """ Destination IP6 iACL test
+ """Destination IP6 iACL test
Test scenario for basic IP ACL with destination IP
- Create IPv6 stream for pg0 -> pg1 interface.
@@ -69,13 +69,13 @@ class TestClassifierIP6(TestClassifier):
pkts = self.create_stream(self.pg0, self.pg1, self.pg_if_packet_sizes)
self.pg0.add_stream(pkts)
- key = 'ip6_dst'
+ key = "ip6_dst"
self.create_classify_table(
- key,
- self.build_ip6_mask(dst_ip='ffffffffffffffffffffffffffffffff'))
+ key, self.build_ip6_mask(dst_ip="ffffffffffffffffffffffffffffffff")
+ )
self.create_classify_session(
- self.acl_tbl_idx.get(key),
- self.build_ip6_match(dst_ip=self.pg1.remote_ip6))
+ self.acl_tbl_idx.get(key), self.build_ip6_match(dst_ip=self.pg1.remote_ip6)
+ )
self.input_acl_set_interface(self.pg0, self.acl_tbl_idx.get(key))
self.acl_active_table = key
@@ -88,7 +88,7 @@ class TestClassifierIP6(TestClassifier):
self.pg2.assert_nothing_captured(remark="packets forwarded")
def test_iacl_src_dst_ip(self):
- """ Source and destination IP6 iACL test
+ """Source and destination IP6 iACL test
Test scenario for basic IP ACL with source and destination IP
- Create IPv4 stream for pg0 -> pg1 interface.
@@ -100,15 +100,20 @@ class TestClassifierIP6(TestClassifier):
pkts = self.create_stream(self.pg0, self.pg1, self.pg_if_packet_sizes)
self.pg0.add_stream(pkts)
- key = 'ip6'
+ key = "ip6"
self.create_classify_table(
key,
- self.build_ip6_mask(src_ip='ffffffffffffffffffffffffffffffff',
- dst_ip='ffffffffffffffffffffffffffffffff'))
+ self.build_ip6_mask(
+ src_ip="ffffffffffffffffffffffffffffffff",
+ dst_ip="ffffffffffffffffffffffffffffffff",
+ ),
+ )
self.create_classify_session(
self.acl_tbl_idx.get(key),
- self.build_ip6_match(src_ip=self.pg0.remote_ip6,
- dst_ip=self.pg1.remote_ip6))
+ self.build_ip6_match(
+ src_ip=self.pg0.remote_ip6, dst_ip=self.pg1.remote_ip6
+ ),
+ )
self.input_acl_set_interface(self.pg0, self.acl_tbl_idx.get(key))
self.acl_active_table = key
@@ -124,7 +129,7 @@ class TestClassifierIP6(TestClassifier):
# Tests split to different test case classes because of issue reported in
# ticket VPP-1336
class TestClassifierIP6UDP(TestClassifier):
- """ Classifier IP6 UDP proto Test Case """
+ """Classifier IP6 UDP proto Test Case"""
@classmethod
def setUpClass(cls):
@@ -132,7 +137,7 @@ class TestClassifierIP6UDP(TestClassifier):
cls.af = socket.AF_INET6
def test_iacl_proto_udp(self):
- """ IP6 UDP protocol iACL test
+ """IP6 UDP protocol iACL test
Test scenario for basic protocol ACL with UDP protocol
- Create IPv6 stream for pg0 -> pg1 interface.
@@ -144,11 +149,11 @@ class TestClassifierIP6UDP(TestClassifier):
pkts = self.create_stream(self.pg0, self.pg1, self.pg_if_packet_sizes)
self.pg0.add_stream(pkts)
- key = 'nh_udp'
- self.create_classify_table(key, self.build_ip6_mask(nh='ff'))
+ key = "nh_udp"
+ self.create_classify_table(key, self.build_ip6_mask(nh="ff"))
self.create_classify_session(
- self.acl_tbl_idx.get(key),
- self.build_ip6_match(nh=socket.IPPROTO_UDP))
+ self.acl_tbl_idx.get(key), self.build_ip6_match(nh=socket.IPPROTO_UDP)
+ )
self.input_acl_set_interface(self.pg0, self.acl_tbl_idx.get(key))
self.acl_active_table = key
@@ -161,7 +166,7 @@ class TestClassifierIP6UDP(TestClassifier):
self.pg2.assert_nothing_captured(remark="packets forwarded")
def test_iacl_proto_udp_sport(self):
- """ IP6 UDP source port iACL test
+ """IP6 UDP source port iACL test
Test scenario for basic protocol ACL with UDP and sport
- Create IPv6 stream for pg0 -> pg1 interface.
@@ -171,18 +176,18 @@ class TestClassifierIP6UDP(TestClassifier):
# Basic iACL testing with UDP and sport
sport = 38
- pkts = self.create_stream(self.pg0, self.pg1, self.pg_if_packet_sizes,
- UDP(sport=sport, dport=5678))
+ pkts = self.create_stream(
+ self.pg0, self.pg1, self.pg_if_packet_sizes, UDP(sport=sport, dport=5678)
+ )
self.pg0.add_stream(pkts)
- key = 'nh_udp_sport'
- self.create_classify_table(
- key, self.build_ip6_mask(nh='ff', src_port='ffff'))
+ key = "nh_udp_sport"
+ self.create_classify_table(key, self.build_ip6_mask(nh="ff", src_port="ffff"))
self.create_classify_session(
self.acl_tbl_idx.get(key),
- self.build_ip6_match(nh=socket.IPPROTO_UDP, src_port=sport))
- self.input_acl_set_interface(
- self.pg0, self.acl_tbl_idx.get(key))
+ self.build_ip6_match(nh=socket.IPPROTO_UDP, src_port=sport),
+ )
+ self.input_acl_set_interface(self.pg0, self.acl_tbl_idx.get(key))
self.acl_active_table = key
self.pg_enable_capture(self.pg_interfaces)
@@ -194,7 +199,7 @@ class TestClassifierIP6UDP(TestClassifier):
self.pg2.assert_nothing_captured(remark="packets forwarded")
def test_iacl_proto_udp_dport(self):
- """ IP6 UDP destination port iACL test
+ """IP6 UDP destination port iACL test
Test scenario for basic protocol ACL with UDP and dport
- Create IPv6 stream for pg0 -> pg1 interface.
@@ -204,18 +209,18 @@ class TestClassifierIP6UDP(TestClassifier):
# Basic iACL testing with UDP and dport
dport = 427
- pkts = self.create_stream(self.pg0, self.pg1, self.pg_if_packet_sizes,
- UDP(sport=1234, dport=dport))
+ pkts = self.create_stream(
+ self.pg0, self.pg1, self.pg_if_packet_sizes, UDP(sport=1234, dport=dport)
+ )
self.pg0.add_stream(pkts)
- key = 'nh_udp_dport'
- self.create_classify_table(
- key, self.build_ip6_mask(nh='ff', dst_port='ffff'))
+ key = "nh_udp_dport"
+ self.create_classify_table(key, self.build_ip6_mask(nh="ff", dst_port="ffff"))
self.create_classify_session(
self.acl_tbl_idx.get(key),
- self.build_ip6_match(nh=socket.IPPROTO_UDP, dst_port=dport))
- self.input_acl_set_interface(
- self.pg0, self.acl_tbl_idx.get(key))
+ self.build_ip6_match(nh=socket.IPPROTO_UDP, dst_port=dport),
+ )
+ self.input_acl_set_interface(self.pg0, self.acl_tbl_idx.get(key))
self.acl_active_table = key
self.pg_enable_capture(self.pg_interfaces)
@@ -227,7 +232,7 @@ class TestClassifierIP6UDP(TestClassifier):
self.pg2.assert_nothing_captured(remark="packets forwarded")
def test_iacl_proto_udp_sport_dport(self):
- """ IP6 UDP source and destination ports iACL test
+ """IP6 UDP source and destination ports iACL test
Test scenario for basic protocol ACL with UDP and sport and dport
- Create IPv6 stream for pg0 -> pg1 interface.
@@ -238,20 +243,20 @@ class TestClassifierIP6UDP(TestClassifier):
# Basic iACL testing with UDP and sport and dport
sport = 13720
dport = 9080
- pkts = self.create_stream(self.pg0, self.pg1, self.pg_if_packet_sizes,
- UDP(sport=sport, dport=dport))
+ pkts = self.create_stream(
+ self.pg0, self.pg1, self.pg_if_packet_sizes, UDP(sport=sport, dport=dport)
+ )
self.pg0.add_stream(pkts)
- key = 'nh_udp_ports'
+ key = "nh_udp_ports"
self.create_classify_table(
- key,
- self.build_ip6_mask(nh='ff', src_port='ffff', dst_port='ffff'))
+ key, self.build_ip6_mask(nh="ff", src_port="ffff", dst_port="ffff")
+ )
self.create_classify_session(
self.acl_tbl_idx.get(key),
- self.build_ip6_match(nh=socket.IPPROTO_UDP, src_port=sport,
- dst_port=dport))
- self.input_acl_set_interface(
- self.pg0, self.acl_tbl_idx.get(key))
+ self.build_ip6_match(nh=socket.IPPROTO_UDP, src_port=sport, dst_port=dport),
+ )
+ self.input_acl_set_interface(self.pg0, self.acl_tbl_idx.get(key))
self.acl_active_table = key
self.pg_enable_capture(self.pg_interfaces)
@@ -264,7 +269,7 @@ class TestClassifierIP6UDP(TestClassifier):
class TestClassifierIP6TCP(TestClassifier):
- """ Classifier IP6 TCP proto Test Case """
+ """Classifier IP6 TCP proto Test Case"""
@classmethod
def setUpClass(cls):
@@ -272,7 +277,7 @@ class TestClassifierIP6TCP(TestClassifier):
cls.af = socket.AF_INET6
def test_iacl_proto_tcp(self):
- """ IP6 TCP protocol iACL test
+ """IP6 TCP protocol iACL test
Test scenario for basic protocol ACL with TCP protocol
- Create IPv6 stream for pg0 -> pg1 interface.
@@ -281,17 +286,17 @@ class TestClassifierIP6TCP(TestClassifier):
"""
# Basic iACL testing with TCP protocol
- pkts = self.create_stream(self.pg0, self.pg1, self.pg_if_packet_sizes,
- TCP(sport=1234, dport=5678))
+ pkts = self.create_stream(
+ self.pg0, self.pg1, self.pg_if_packet_sizes, TCP(sport=1234, dport=5678)
+ )
self.pg0.add_stream(pkts)
- key = 'nh_tcp'
- self.create_classify_table(key, self.build_ip6_mask(nh='ff'))
+ key = "nh_tcp"
+ self.create_classify_table(key, self.build_ip6_mask(nh="ff"))
self.create_classify_session(
- self.acl_tbl_idx.get(key),
- self.build_ip6_match(nh=socket.IPPROTO_TCP))
- self.input_acl_set_interface(
- self.pg0, self.acl_tbl_idx.get(key))
+ self.acl_tbl_idx.get(key), self.build_ip6_match(nh=socket.IPPROTO_TCP)
+ )
+ self.input_acl_set_interface(self.pg0, self.acl_tbl_idx.get(key))
self.acl_active_table = key
self.pg_enable_capture(self.pg_interfaces)
@@ -303,7 +308,7 @@ class TestClassifierIP6TCP(TestClassifier):
self.pg2.assert_nothing_captured(remark="packets forwarded")
def test_iacl_proto_tcp_sport(self):
- """ IP6 TCP source port iACL test
+ """IP6 TCP source port iACL test
Test scenario for basic protocol ACL with TCP and sport
- Create IPv6 stream for pg0 -> pg1 interface.
@@ -313,18 +318,18 @@ class TestClassifierIP6TCP(TestClassifier):
# Basic iACL testing with TCP and sport
sport = 38
- pkts = self.create_stream(self.pg0, self.pg1, self.pg_if_packet_sizes,
- TCP(sport=sport, dport=5678))
+ pkts = self.create_stream(
+ self.pg0, self.pg1, self.pg_if_packet_sizes, TCP(sport=sport, dport=5678)
+ )
self.pg0.add_stream(pkts)
- key = 'nh_tcp_sport'
- self.create_classify_table(
- key, self.build_ip6_mask(nh='ff', src_port='ffff'))
+ key = "nh_tcp_sport"
+ self.create_classify_table(key, self.build_ip6_mask(nh="ff", src_port="ffff"))
self.create_classify_session(
self.acl_tbl_idx.get(key),
- self.build_ip6_match(nh=socket.IPPROTO_TCP, src_port=sport))
- self.input_acl_set_interface(
- self.pg0, self.acl_tbl_idx.get(key))
+ self.build_ip6_match(nh=socket.IPPROTO_TCP, src_port=sport),
+ )
+ self.input_acl_set_interface(self.pg0, self.acl_tbl_idx.get(key))
self.acl_active_table = key
self.pg_enable_capture(self.pg_interfaces)
@@ -336,7 +341,7 @@ class TestClassifierIP6TCP(TestClassifier):
self.pg2.assert_nothing_captured(remark="packets forwarded")
def test_iacl_proto_tcp_dport(self):
- """ IP6 TCP destination port iACL test
+ """IP6 TCP destination port iACL test
Test scenario for basic protocol ACL with TCP and dport
- Create IPv6 stream for pg0 -> pg1 interface.
@@ -346,18 +351,18 @@ class TestClassifierIP6TCP(TestClassifier):
# Basic iACL testing with TCP and dport
dport = 427
- pkts = self.create_stream(self.pg0, self.pg1, self.pg_if_packet_sizes,
- TCP(sport=1234, dport=dport))
+ pkts = self.create_stream(
+ self.pg0, self.pg1, self.pg_if_packet_sizes, TCP(sport=1234, dport=dport)
+ )
self.pg0.add_stream(pkts)
- key = 'nh_tcp_dport'
- self.create_classify_table(
- key, self.build_ip6_mask(nh='ff', dst_port='ffff'))
+ key = "nh_tcp_dport"
+ self.create_classify_table(key, self.build_ip6_mask(nh="ff", dst_port="ffff"))
self.create_classify_session(
self.acl_tbl_idx.get(key),
- self.build_ip6_match(nh=socket.IPPROTO_TCP, dst_port=dport))
- self.input_acl_set_interface(
- self.pg0, self.acl_tbl_idx.get(key))
+ self.build_ip6_match(nh=socket.IPPROTO_TCP, dst_port=dport),
+ )
+ self.input_acl_set_interface(self.pg0, self.acl_tbl_idx.get(key))
self.acl_active_table = key
self.pg_enable_capture(self.pg_interfaces)
@@ -369,7 +374,7 @@ class TestClassifierIP6TCP(TestClassifier):
self.pg2.assert_nothing_captured(remark="packets forwarded")
def test_iacl_proto_tcp_sport_dport(self):
- """ IP6 TCP source and destination ports iACL test
+ """IP6 TCP source and destination ports iACL test
Test scenario for basic protocol ACL with TCP and sport and dport
- Create IPv6 stream for pg0 -> pg1 interface.
@@ -380,20 +385,20 @@ class TestClassifierIP6TCP(TestClassifier):
# Basic iACL testing with TCP and sport and dport
sport = 13720
dport = 9080
- pkts = self.create_stream(self.pg0, self.pg1, self.pg_if_packet_sizes,
- TCP(sport=sport, dport=dport))
+ pkts = self.create_stream(
+ self.pg0, self.pg1, self.pg_if_packet_sizes, TCP(sport=sport, dport=dport)
+ )
self.pg0.add_stream(pkts)
- key = 'nh_tcp_ports'
+ key = "nh_tcp_ports"
self.create_classify_table(
- key,
- self.build_ip6_mask(nh='ff', src_port='ffff', dst_port='ffff'))
+ key, self.build_ip6_mask(nh="ff", src_port="ffff", dst_port="ffff")
+ )
self.create_classify_session(
self.acl_tbl_idx.get(key),
- self.build_ip6_match(nh=socket.IPPROTO_TCP, src_port=sport,
- dst_port=dport))
- self.input_acl_set_interface(
- self.pg0, self.acl_tbl_idx.get(key))
+ self.build_ip6_match(nh=socket.IPPROTO_TCP, src_port=sport, dst_port=dport),
+ )
+ self.input_acl_set_interface(self.pg0, self.acl_tbl_idx.get(key))
self.acl_active_table = key
self.pg_enable_capture(self.pg_interfaces)
@@ -406,7 +411,7 @@ class TestClassifierIP6TCP(TestClassifier):
class TestClassifierIP6Out(TestClassifier):
- """ Classifier output IP6 Test Case """
+ """Classifier output IP6 Test Case"""
@classmethod
def setUpClass(cls):
@@ -414,7 +419,7 @@ class TestClassifierIP6Out(TestClassifier):
cls.af = socket.AF_INET6
def test_acl_ip_out(self):
- """ Output IP6 ACL test
+ """Output IP6 ACL test
Test scenario for basic IP ACL with source IP
- Create IPv6 stream for pg1 -> pg0 interface.
@@ -426,16 +431,16 @@ class TestClassifierIP6Out(TestClassifier):
pkts = self.create_stream(self.pg1, self.pg0, self.pg_if_packet_sizes)
self.pg1.add_stream(pkts)
- key = 'ip6_out'
+ key = "ip6_out"
self.create_classify_table(
key,
- self.build_ip6_mask(src_ip='ffffffffffffffffffffffffffffffff'),
- data_offset=0)
+ self.build_ip6_mask(src_ip="ffffffffffffffffffffffffffffffff"),
+ data_offset=0,
+ )
self.create_classify_session(
- self.acl_tbl_idx.get(key),
- self.build_ip6_match(src_ip=self.pg1.remote_ip6))
- self.output_acl_set_interface(
- self.pg0, self.acl_tbl_idx.get(key))
+ self.acl_tbl_idx.get(key), self.build_ip6_match(src_ip=self.pg1.remote_ip6)
+ )
+ self.output_acl_set_interface(self.pg0, self.acl_tbl_idx.get(key))
self.acl_active_table = key
self.pg_enable_capture(self.pg_interfaces)
@@ -448,7 +453,7 @@ class TestClassifierIP6Out(TestClassifier):
class TestClassifierIP6MAC(TestClassifier):
- """ Classifier IP6 MAC Test Case """
+ """Classifier IP6 MAC Test Case"""
@classmethod
def setUpClass(cls):
@@ -456,7 +461,7 @@ class TestClassifierIP6MAC(TestClassifier):
cls.af = socket.AF_INET6
def test_acl_mac(self):
- """ IP6 MAC iACL test
+ """IP6 MAC iACL test
Test scenario for basic MAC ACL with source MAC
- Create IPv6 stream for pg0 -> pg2 interface.
@@ -468,12 +473,13 @@ class TestClassifierIP6MAC(TestClassifier):
pkts = self.create_stream(self.pg0, self.pg2, self.pg_if_packet_sizes)
self.pg0.add_stream(pkts)
- key = 'mac'
+ key = "mac"
self.create_classify_table(
- key, self.build_mac_mask(src_mac='ffffffffffff'), data_offset=-14)
+ key, self.build_mac_mask(src_mac="ffffffffffff"), data_offset=-14
+ )
self.create_classify_session(
- self.acl_tbl_idx.get(key),
- self.build_mac_match(src_mac=self.pg0.remote_mac))
+ self.acl_tbl_idx.get(key), self.build_mac_match(src_mac=self.pg0.remote_mac)
+ )
self.input_acl_set_interface(self.pg0, self.acl_tbl_idx.get(key))
self.acl_active_table = key
@@ -486,5 +492,5 @@ class TestClassifierIP6MAC(TestClassifier):
self.pg1.assert_nothing_captured(remark="packets forwarded")
-if __name__ == '__main__':
+if __name__ == "__main__":
unittest.main(testRunner=VppTestRunner)