From 77c821ccc6b72d18a247e95816ac1013b4dc664d Mon Sep 17 00:00:00 2001 From: Klement Sekera Date: Thu, 14 Apr 2022 16:29:07 +0200 Subject: tests: handle removed interface Catch exception if sw_if_index is invalid when querying interface binding config. If the interface is not there, it's surely not bound to any table ... Type: improvement Change-Id: I1f3e04a631653feb5c2350662b6a041adccefa1f Signed-off-by: Klement Sekera --- test/vpp_ip_route.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'test/vpp_ip_route.py') diff --git a/test/vpp_ip_route.py b/test/vpp_ip_route.py index b6059485275..f5e5a8801e4 100644 --- a/test/vpp_ip_route.py +++ b/test/vpp_ip_route.py @@ -5,10 +5,10 @@ """ from vpp_object import VppObject -from socket import inet_pton, inet_ntop, AF_INET, AF_INET6 from vpp_ip import DpoProto, INVALID_INDEX, VppIpAddressUnion, \ VppIpMPrefix from ipaddress import ip_network, ip_address, IPv4Network, IPv6Network +from vpp_papi_exceptions import UnexpectedApiReturnValueError # from vnet/vnet/mpls/mpls_types.h MPLS_IETF_MAX_LABEL = 0xfffff @@ -340,9 +340,14 @@ class VppIpInterfaceBind(VppObject): def query_vpp_config(self): if 0 == self.table.table_id: return False - return self._test.vapi.sw_interface_get_table( - self.intf.sw_if_index, - self.table.is_ip6).vrf_id == self.table.table_id + try: + return self._test.vapi.sw_interface_get_table( + self.intf.sw_if_index, + self.table.is_ip6).vrf_id == self.table.table_id + except UnexpectedApiReturnValueError as e: + if e.retval == -2: # INVALID_SW_IF_INDEX + return False + raise def object_id(self): return "interface-bind-%s-%s" % (self.intf, self.table) -- cgit 1.2.3-korg