-#!/usr/bin/env python
+#!/usr/bin/env python3
"""IP4 VRF Multi-instance Test Case HLD:
**NOTES:**
# 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)
super(TestIp4VrfMultiInst, cls).tearDownClass()
raise
+ @classmethod
+ def tearDownClass(cls):
+ super(TestIp4VrfMultiInst, cls).tearDownClass()
+
def setUp(self):
"""
Clear trace and packet infos before running each test.
Show various debug prints after each test.
"""
super(TestIp4VrfMultiInst, self).tearDown()
- if not self.vpp_dead:
- self.logger.info(self.vapi.ppcli("show ip fib"))
- self.logger.info(self.vapi.ppcli("show ip arp"))
+
+ def show_commands_at_teardown(self):
+ self.logger.info(self.vapi.ppcli("show ip fib"))
+ self.logger.info(self.vapi.ppcli("show ip arp"))
def create_vrf_and_assign_interfaces(self, count, start=1):
"""
: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.
"""
- ip_fib_dump = self.vapi.ip_fib_dump()
- vrf_exist = False
+ ip_fib_dump = self.vapi.ip_route_dump(vrf_id)
+ vrf_exist = len(ip_fib_dump)
vrf_count = 0
for ip_fib_details in ip_fib_dump:
- if ip_fib_details.table_id == vrf_id:
- if not vrf_exist:
- vrf_exist = True
- addr = socket.inet_ntoa(ip_fib_details.address)
- found = False
- for pg_if in self.pg_if_by_vrf_id[vrf_id]:
- if found:
+ addr = ip_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.ip4:
+ vrf_count += 1
+ found = True
break
- for host in pg_if.remote_hosts:
- if scapy.compat.raw(addr) == \
- scapy.compat.raw(host.ip4):
- vrf_count += 1
- found = True
- break
if not vrf_exist and vrf_count == 0:
self.logger.info("IPv4 VRF ID %d is not configured" % vrf_id)
return VRFState.not_configured