X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftest_ip6_vrf_multi_instance.py;h=c23e30153515d160bfbb1cf749c694a6e55d6fc1;hb=8e7fdddd3;hp=4547b38a45e87538b0d9d616743c92cde49833b5;hpb=d16ba6295b666a1b3d92c3b043ea1c008d2722c6;p=vpp.git diff --git a/test/test_ip6_vrf_multi_instance.py b/test/test_ip6_vrf_multi_instance.py index 4547b38a45e..c23e3015351 100644 --- a/test/test_ip6_vrf_multi_instance.py +++ b/test/test_ip6_vrf_multi_instance.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """IP6 VRF Multi-instance Test Case HLD: **NOTES:** @@ -17,7 +17,7 @@ - send IP6 packets between all pg-ip6 interfaces in all VRF groups **verify 1** - - check VRF data by parsing output of ip6_fib_dump API command + - check VRF data by parsing output of ip_route_dump API command - all packets received correctly in case of pg-ip6 interfaces in the same VRF - no packet received in case of pg-ip6 interfaces not in VRF @@ -30,7 +30,7 @@ - send IP6 packets between all pg-ip6 interfaces in all VRF groups **verify 2** - - check VRF data by parsing output of ip6_fib_dump API command + - check VRF data by parsing output of ip_route_dump API command - all packets received correctly in case of pg-ip6 interfaces in the same VRF - no packet received in case of pg-ip6 interfaces not in VRF @@ -43,7 +43,7 @@ - send IP6 packets between all pg-ip6 interfaces in all VRF groups **verify 3** - - check VRF data by parsing output of ip6_fib_dump API command + - check VRF data by parsing output of ip_route_dump API command - all packets received correctly in case of pg-ip6 interfaces in the same VRF - no packet received in case of pg-ip6 interfaces not in VRF @@ -56,7 +56,7 @@ - send IP6 packets between all pg-ip6 interfaces in all VRF groups **verify 4** - - check VRF data by parsing output of ip6_fib_dump API command + - check VRF data by parsing output of ip_route_dump API command - all packets received correctly in case of pg-ip6 interfaces in the same VRF - no packet received in case of pg-ip6 interfaces not in VRF @@ -120,7 +120,7 @@ class TestIP6VrfMultiInst(VppTestCase): # Packet flows mapping pg0 -> pg1, pg2 etc. cls.flows = dict() for i in range(len(cls.pg_interfaces)): - multiplicand = i / cls.pg_ifs_per_vrf + multiplicand = i // cls.pg_ifs_per_vrf pg_list = [ cls.pg_interfaces[multiplicand * cls.pg_ifs_per_vrf + j] for j in range(cls.pg_ifs_per_vrf) @@ -160,6 +160,10 @@ class TestIP6VrfMultiInst(VppTestCase): super(TestIP6VrfMultiInst, cls).tearDownClass() raise + @classmethod + def tearDownClass(cls): + super(TestIP6VrfMultiInst, cls).tearDownClass() + def setUp(self): """ Clear trace and packet infos before running each test. @@ -172,9 +176,10 @@ class TestIP6VrfMultiInst(VppTestCase): Show various debug prints after each test. """ super(TestIP6VrfMultiInst, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.ppcli("show ip6 fib")) - self.logger.info(self.vapi.ppcli("show ip6 neighbors")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.ppcli("show ip6 fib")) + self.logger.info(self.vapi.ppcli("show ip6 neighbors")) def create_vrf_and_assign_interfaces(self, count, start=1): """ @@ -190,10 +195,8 @@ class TestIP6VrfMultiInst(VppTestCase): pg_if = self.pg_if_by_vrf_id[vrf_id][0] dest_addr = pg_if.local_ip6n dest_addr_len = 64 - self.vapi.ip_table_add_del(vrf_id, is_add=1, is_ipv6=1) - self.vapi.ip_add_del_route( - dest_addr, dest_addr_len, pg_if.local_ip6n, is_ipv6=1, - table_id=vrf_id, is_multipath=1) + self.vapi.ip_table_add_del(is_add=1, + table={'table_id': vrf_id, 'is_ip6': 1}) self.logger.info("IPv6 VRF ID %d created" % vrf_id) if vrf_id not in self.vrf_list: self.vrf_list.append(vrf_id) @@ -220,8 +223,7 @@ class TestIP6VrfMultiInst(VppTestCase): :param int vrf_id: The FIB table / VRF ID to be reset. """ - # self.vapi.reset_vrf(vrf_id, is_ipv6=1) - self.vapi.reset_fib(vrf_id, is_ipv6=1) + self.vapi.ip_table_flush(table={'table_id': vrf_id, 'is_ip6': 1}) if vrf_id in self.vrf_list: self.vrf_list.remove(vrf_id) if vrf_id not in self.vrf_reset_list: @@ -236,7 +238,8 @@ class TestIP6VrfMultiInst(VppTestCase): self.logger.info("IPv6 VRF ID %d reset finished" % vrf_id) self.logger.debug(self.vapi.ppcli("show ip6 fib")) self.logger.debug(self.vapi.ppcli("show ip6 neighbors")) - self.vapi.ip_table_add_del(vrf_id, is_add=0, is_ipv6=1) + self.vapi.ip_table_add_del(is_add=0, + table={'table_id': vrf_id, 'is_ip6': 1}) def create_stream(self, src_if, packet_sizes): """ @@ -312,7 +315,7 @@ class TestIP6VrfMultiInst(VppTestCase): try: ip = packet[IPv6] udp = packet[UDP] - 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("Got packet on port %s: src=%u (id=%u)" % @@ -347,23 +350,20 @@ class TestIP6VrfMultiInst(VppTestCase): :param int vrf_id: The FIB table / VRF ID to be verified. :return: 1 if the FIB table / VRF ID is configured, otherwise return 0. """ - ip6_fib_dump = self.vapi.ip6_fib_dump() - vrf_exist = False + ip6_fib_dump = self.vapi.ip_route_dump(vrf_id, True) + vrf_exist = len(ip6_fib_dump) vrf_count = 0 for ip6_fib_details in ip6_fib_dump: - if ip6_fib_details.table_id == vrf_id: - if not vrf_exist: - vrf_exist = True - addr = inet_ntop(socket.AF_INET6, ip6_fib_details.address) - found = False - for pg_if in self.pg_if_by_vrf_id[vrf_id]: - if found: + addr = ip6_fib_details.route.prefix.network_address + found = False + for pg_if in self.pg_if_by_vrf_id[vrf_id]: + if found: + break + for host in pg_if.remote_hosts: + if str(addr) == host.ip6: + vrf_count += 1 + found = True break - for host in pg_if.remote_hosts: - if str(addr) == str(host.ip6): - vrf_count += 1 - found = True - break if not vrf_exist and vrf_count == 0: self.logger.info("IPv6 VRF ID %d is not configured" % vrf_id) return VRFState.not_configured