aboutsummaryrefslogtreecommitdiffstats
path: root/test/vpp_ip_route.py
diff options
context:
space:
mode:
authorKlement Sekera <klement.sekera@gmail.com>2022-04-14 16:29:07 +0200
committerDave Wallace <dwallacelf@gmail.com>2022-05-03 15:07:41 +0000
commit77c821ccc6b72d18a247e95816ac1013b4dc664d (patch)
tree06028c888750ca5181e5468443f2c5b3d8e05f14 /test/vpp_ip_route.py
parent2ca88ff97884ec9ed20a853b13cee6d86f9c9d0f (diff)
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 <klement.sekera@gmail.com>
Diffstat (limited to 'test/vpp_ip_route.py')
-rw-r--r--test/vpp_ip_route.py13
1 files changed, 9 insertions, 4 deletions
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)