X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftest_classifier_ip6.py;h=0522520d30950b9440d67575182cd506d48a5724;hb=5854b43de4c04a7c52b0cf03cd548c9cac86c325;hp=cbcf5c472579528241b5501a70fcd914394d3ad1;hpb=6e4c6ad92e59045f0babf5af5093cb8402ec37fb;p=vpp.git diff --git a/test/test_classifier_ip6.py b/test/test_classifier_ip6.py index cbcf5c47257..0522520d309 100644 --- a/test/test_classifier_ip6.py +++ b/test/test_classifier_ip6.py @@ -26,6 +26,10 @@ class TestClassifier(VppTestCase): super(TestClassifier, cls).setUpClass() cls.acl_active_table = '' + @classmethod + def tearDownClass(cls): + super(TestClassifier, cls).tearDownClass() + def setUp(self): """ Perform test setup before test case. @@ -69,10 +73,6 @@ class TestClassifier(VppTestCase): def tearDown(self): """Run standard test teardown and acl related log.""" if not self.vpp_dead: - self.logger.info(self.vapi.ppcli("show inacl type ip6")) - self.logger.info(self.vapi.ppcli("show outacl type ip6")) - self.logger.info(self.vapi.cli("show classify table verbose")) - self.logger.info(self.vapi.cli("show ip fib")) if self.acl_active_table == 'ip6_out': self.output_acl_set_interface( self.pg0, self.acl_tbl_idx.get(self.acl_active_table), 0) @@ -87,6 +87,12 @@ class TestClassifier(VppTestCase): super(TestClassifier, self).tearDown() + def show_commands_at_teardown(self): + self.logger.info(self.vapi.ppcli("show inacl type ip6")) + self.logger.info(self.vapi.ppcli("show outacl type ip6")) + self.logger.info(self.vapi.cli("show classify table verbose")) + self.logger.info(self.vapi.cli("show ip fib")) + def create_stream(self, src_if, dst_if, packet_sizes, proto_l=UDP(sport=1234, dport=5678)): """Create input packet stream for defined interfaces. @@ -126,7 +132,7 @@ class TestClassifier(VppTestCase): try: ip6_received = packet[IPv6] proto_received = packet[proto_l] - payload_info = self.payload_to_info(str(packet[Raw])) + payload_info = self.payload_to_info(packet[Raw]) packet_index = payload_info.index self.assertEqual(payload_info.dst, dst_sw_if_index) self.logger.debug( @@ -168,7 +174,7 @@ class TestClassifier(VppTestCase): :param str dst_port: destination port number <0-ffff> """ - return ('{:0>14}{:0>34}{:0>32}{:0>4}{:0>4}'.format( + return ('{!s:0>14}{!s:0>34}{!s:0>32}{!s:0>4}{!s:0>4}'.format( nh, src_ip, dst_ip, src_port, dst_port)).rstrip('0') @staticmethod @@ -184,13 +190,20 @@ class TestClassifier(VppTestCase): :param int dst_port: destination port number "x" """ if src_ip: - src_ip = binascii.hexlify(socket.inet_pton( - socket.AF_INET6, src_ip)) + if sys.version_info[0] == 2: + src_ip = binascii.hexlify(socket.inet_pton( + socket.AF_INET6, src_ip)) + else: + src_ip = socket.inet_pton(socket.AF_INET6, src_ip).hex() + if dst_ip: - dst_ip = binascii.hexlify(socket.inet_pton( - socket.AF_INET6, dst_ip)) + if sys.version_info[0] == 2: + dst_ip = binascii.hexlify(socket.inet_pton( + socket.AF_INET6, dst_ip)) + else: + dst_ip = socket.inet_pton(socket.AF_INET6, dst_ip).hex() - return ('{:0>14}{:0>34}{:0>32}{:0>4}{:0>4}'.format( + return ('{!s:0>14}{!s:0>34}{!s:0>32}{!s:0>4}{!s:0>4}'.format( hex(nh)[2:], src_ip, dst_ip, hex(src_port)[2:], hex(dst_port)[2:])).rstrip('0') @@ -203,8 +216,8 @@ class TestClassifier(VppTestCase): :param str ether_type: ethernet type <0-ffff> """ - return ('{:0>12}{:0>12}{:0>4}'.format(dst_mac, src_mac, - ether_type)).rstrip('0') + return ('{!s:0>12}{!s:0>12}{!s:0>4}'.format( + dst_mac, src_mac, ether_type)).rstrip('0') @staticmethod def build_mac_match(dst_mac='', src_mac='', ether_type=''): @@ -219,8 +232,8 @@ class TestClassifier(VppTestCase): if src_mac: src_mac = src_mac.replace(':', '') - return ('{:0>12}{:0>12}{:0>4}'.format(dst_mac, src_mac, - ether_type)).rstrip('0') + return ('{!s:0>12}{!s:0>12}{!s:0>4}'.format( + dst_mac, src_mac, ether_type)).rstrip('0') def create_classify_table(self, key, mask, data_offset=0): """Create Classify Table @@ -236,7 +249,7 @@ class TestClassifier(VppTestCase): miss_next_index=0, current_data_flag=1, current_data_offset=data_offset) - self.assertIsNotNone(r, msg='No response msg for add_del_table') + self.assertIsNotNone(r, 'No response msg for add_del_table') self.acl_tbl_idx[key] = r.new_table_index def create_classify_session(self, table_index, match, vrfid=0, is_add=1): @@ -254,7 +267,7 @@ class TestClassifier(VppTestCase): binascii.unhexlify(match), opaque_index=0, metadata=vrfid) - self.assertIsNotNone(r, msg='No response msg for add_del_session') + self.assertIsNotNone(r, 'No response msg for add_del_session') def input_acl_set_interface(self, intf, table_index, is_add=1): """Configure Input ACL interface @@ -268,7 +281,7 @@ class TestClassifier(VppTestCase): is_add, intf.sw_if_index, ip6_table_index=table_index) - self.assertIsNotNone(r, msg='No response msg for acl_set_interface') + self.assertIsNotNone(r, 'No response msg for acl_set_interface') def output_acl_set_interface(self, intf, table_index, is_add=1): """Configure Output ACL interface @@ -282,12 +295,20 @@ class TestClassifier(VppTestCase): is_add, intf.sw_if_index, ip6_table_index=table_index) - self.assertIsNotNone(r, msg='No response msg for acl_set_interface') + self.assertIsNotNone(r, 'No response msg for acl_set_interface') class TestClassifierIP6(TestClassifier): """ Classifier IP6 Test Case """ + @classmethod + def setUpClass(cls): + super(TestClassifierIP6, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestClassifierIP6, cls).tearDownClass() + def test_iacl_src_ip(self): """ Source IP6 iACL test @@ -389,6 +410,14 @@ class TestClassifierIP6(TestClassifier): class TestClassifierIP6UDP(TestClassifier): """ Classifier IP6 UDP proto Test Case """ + @classmethod + def setUpClass(cls): + super(TestClassifierIP6UDP, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestClassifierIP6UDP, cls).tearDownClass() + def test_iacl_proto_udp(self): """ IP6 UDP protocol iACL test @@ -524,6 +553,14 @@ class TestClassifierIP6UDP(TestClassifier): class TestClassifierIP6TCP(TestClassifier): """ Classifier IP6 TCP proto Test Case """ + @classmethod + def setUpClass(cls): + super(TestClassifierIP6TCP, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestClassifierIP6TCP, cls).tearDownClass() + def test_iacl_proto_tcp(self): """ IP6 TCP protocol iACL test @@ -661,6 +698,14 @@ class TestClassifierIP6TCP(TestClassifier): class TestClassifierIP6Out(TestClassifier): """ Classifier output IP6 Test Case """ + @classmethod + def setUpClass(cls): + super(TestClassifierIP6Out, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestClassifierIP6Out, cls).tearDownClass() + def test_acl_ip_out(self): """ Output IP6 ACL test @@ -698,6 +743,14 @@ class TestClassifierIP6Out(TestClassifier): class TestClassifierIP6MAC(TestClassifier): """ Classifier IP6 MAC Test Case """ + @classmethod + def setUpClass(cls): + super(TestClassifierIP6MAC, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestClassifierIP6MAC, cls).tearDownClass() + def test_acl_mac(self): """ IP6 MAC iACL test