test: ip4 vrf instances multi-context test (CSIT-492)
- add/delete IPv4 VRF instances and verify results by parsing output of ip_fib_dump API command and by traffic Change-Id: I61ed5013adca29afd00b942f65be7bf964f38d85 Signed-off-by: Jan Gelety <jgelety@cisco.com>
This commit is contained in:
410
test/test_ip4_vrf_multi_instance.py
Normal file
410
test/test_ip4_vrf_multi_instance.py
Normal file
File diff suppressed because it is too large
Load Diff
@ -195,12 +195,16 @@ class VppInterface(object):
|
||||
self.has_ip4_config = False
|
||||
self.has_ip4_config = False
|
||||
|
||||
def configure_ipv4_neighbors(self):
|
||||
"""For every remote host assign neighbor's MAC to IPv4 addresses."""
|
||||
def configure_ipv4_neighbors(self, vrf_id=0):
|
||||
"""For every remote host assign neighbor's MAC to IPv4 addresses.
|
||||
|
||||
:param vrf_id: The FIB table / VRF ID. (Default value = 0)
|
||||
"""
|
||||
for host in self._remote_hosts:
|
||||
macn = host.mac.replace(":", "").decode('hex')
|
||||
ipn = host.ip4n
|
||||
self.test.vapi.ip_neighbor_add_del(self.sw_if_index, macn, ipn)
|
||||
self.test.vapi.ip_neighbor_add_del(
|
||||
self.sw_if_index, macn, ipn, vrf_id)
|
||||
|
||||
def config_ip6(self):
|
||||
"""Configure IPv6 address on the VPP interface."""
|
||||
|
@ -595,6 +595,54 @@ class VppPapiProvider(object):
|
||||
}
|
||||
)
|
||||
|
||||
def reset_vrf(self,
|
||||
vrf_id,
|
||||
is_ipv6=0,
|
||||
):
|
||||
""" Reset VRF (remove all routes etc.) request.
|
||||
|
||||
:param int vrf_id: ID of the FIB table / VRF to reset.
|
||||
:param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
|
||||
"""
|
||||
|
||||
return self.api(
|
||||
self.papi.reset_vrf,
|
||||
{'vrf_id': vrf_id,
|
||||
'is_ipv6': is_ipv6,
|
||||
}
|
||||
)
|
||||
|
||||
def reset_fib(self,
|
||||
vrf_id,
|
||||
is_ipv6=0,
|
||||
):
|
||||
""" Reset VRF (remove all routes etc.) request.
|
||||
|
||||
:param int vrf_id: ID of the FIB table / VRF to reset.
|
||||
:param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
|
||||
"""
|
||||
|
||||
return self.api(
|
||||
self.papi.reset_fib,
|
||||
{'vrf_id': vrf_id,
|
||||
'is_ipv6': is_ipv6,
|
||||
}
|
||||
)
|
||||
|
||||
def ip_dump(self,
|
||||
is_ipv6=0,
|
||||
):
|
||||
""" Return IP dump.
|
||||
|
||||
:param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
|
||||
"""
|
||||
|
||||
return self.api(
|
||||
self.papi.ip_dump,
|
||||
{'is_ipv6': is_ipv6,
|
||||
}
|
||||
)
|
||||
|
||||
def sw_interface_span_enable_disable(
|
||||
self, sw_if_index_from, sw_if_index_to, state=1):
|
||||
"""
|
||||
|
@ -145,7 +145,7 @@ class VppPGInterface(VppInterface):
|
||||
output = rdpcap(self.out_path)
|
||||
self.test.logger.debug("Capture has %s packets" % len(output.res))
|
||||
except:
|
||||
self.test.logger.debug("Exception in scapy.rdpcap(%s): %s" %
|
||||
self.test.logger.debug("Exception in scapy.rdpcap (%s): %s" %
|
||||
(self.out_path, format_exc()))
|
||||
return None
|
||||
before = len(output.res)
|
||||
@ -182,7 +182,7 @@ class VppPGInterface(VppInterface):
|
||||
if expected_count == 0:
|
||||
raise Exception(
|
||||
"Internal error, expected packet count for %s is 0!" % name)
|
||||
self.test.logger.debug("Expecting to capture %s(%s) packets on %s" % (
|
||||
self.test.logger.debug("Expecting to capture %s (%s) packets on %s" % (
|
||||
expected_count, based_on, name))
|
||||
while remaining_time > 0:
|
||||
before = time.time()
|
||||
@ -213,22 +213,20 @@ class VppPGInterface(VppInterface):
|
||||
try:
|
||||
capture = self.get_capture(
|
||||
0, remark=remark, filter_out_fn=filter_out_fn)
|
||||
if capture:
|
||||
if len(capture.res) == 0:
|
||||
# junk filtered out, we're good
|
||||
return
|
||||
self.test.logger.error(
|
||||
ppc("Unexpected packets captured:", capture))
|
||||
if not capture:
|
||||
# junk filtered out, we're good
|
||||
return
|
||||
self.test.logger.error(
|
||||
ppc("Unexpected packets captured:", capture))
|
||||
except:
|
||||
pass
|
||||
if remark:
|
||||
raise AssertionError(
|
||||
"Non-empty capture file present for interface %s(%s)" %
|
||||
"Non-empty capture file present for interface %s (%s)" %
|
||||
(self.name, remark))
|
||||
else:
|
||||
raise AssertionError(
|
||||
"Non-empty capture file present for interface %s" %
|
||||
self.name)
|
||||
raise AssertionError("Capture file present for interface %s" %
|
||||
self.name)
|
||||
|
||||
def wait_for_capture_file(self, timeout=1):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user