aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPaul Vinciguerra <pvinci@vinciconsulting.com>2019-06-15 20:31:31 -0400
committerNeale Ranns <nranns@cisco.com>2019-06-25 12:37:13 +0000
commit1b534f5a4ad33f78159113f5a922465df6b32cef (patch)
treeddc769cdfa278979f8608211a9a217be674707e2 /test
parent464e1dcd6b219038c28ee8c71cc7247151a0d18c (diff)
tests: fix test_gbp.py.
A number of VppGbpContractRules were missing the hash_mode_t and were being replaced by an optional kwarg. Type: fix Change-Id: I6ca03c93b69e4355c237a6c9402e1e178b701b21 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'test')
-rw-r--r--test/test_gbp.py73
-rw-r--r--test/test_vxlan_gbp.py32
-rw-r--r--test/vpp_papi_provider.py53
-rw-r--r--test/vpp_vxlan_gbp_tunnel.py34
4 files changed, 107 insertions, 85 deletions
diff --git a/test/test_gbp.py b/test/test_gbp.py
index 0580fff2b6f..cc26238276a 100644
--- a/test/test_gbp.py
+++ b/test/test_gbp.py
@@ -413,10 +413,10 @@ class VppGbpContractNextHop():
class VppGbpContractRule():
- def __init__(self, action, hash_mode, nhs=[]):
+ def __init__(self, action, hash_mode, nhs=None):
self.action = action
self.hash_mode = hash_mode
- self.nhs = nhs
+ self.nhs = [] if nhs is None else nhs
def encode(self):
nhs = []
@@ -430,6 +430,10 @@ class VppGbpContractRule():
'n_nhs': len(self.nhs),
'nhs': nhs}}
+ def __repr__(self):
+ return '<VppGbpContractRule action=%s, hash_mode=%s>' % (
+ self.action, self.hash_mode)
+
class VppGbpContract(VppObject):
"""
@@ -439,6 +443,10 @@ class VppGbpContract(VppObject):
def __init__(self, test, sclass, dclass, acl_index,
rules, allowed_ethertypes):
self._test = test
+ if not isinstance(rules, list):
+ raise ValueError("'rules' must be a list.")
+ if not isinstance(allowed_ethertypes, list):
+ raise ValueError("'allowed_ethertypes' must be a list.")
self.acl_index = acl_index
self.sclass = sclass
self.dclass = dclass
@@ -452,23 +460,30 @@ class VppGbpContract(VppObject):
for r in self.rules:
rules.append(r.encode())
r = self._test.vapi.gbp_contract_add_del(
- 1,
- self.sclass,
- self.dclass,
- self.acl_index,
- rules,
- self.allowed_ethertypes)
+ is_add=1,
+ contract={
+ 'acl_index': self.acl_index,
+ 'sclass': self.sclass,
+ 'dclass': self.dclass,
+ 'n_rules': len(rules),
+ 'rules': rules,
+ 'n_ether_types': len(self.allowed_ethertypes),
+ 'allowed_ethertypes': self.allowed_ethertypes})
self.stats_index = r.stats_index
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
self._test.vapi.gbp_contract_add_del(
- 0,
- self.sclass,
- self.dclass,
- self.acl_index,
- [],
- self.allowed_ethertypes)
+ is_add=0,
+ contract={
+ 'acl_index': self.acl_index,
+ 'sclass': self.sclass,
+ 'dclass': self.dclass,
+ 'n_rules': 0,
+ 'rules': [],
+ 'n_ether_types': len(self.allowed_ethertypes),
+ 'allowed_ethertypes': self.allowed_ethertypes}
+ )
def object_id(self):
return "gbp-contract:[%d:%s:%d]" % (self.sclass,
@@ -556,7 +571,7 @@ class VppGbpAcl(VppObject):
def add_vpp_config(self, rules):
- reply = self._test.vapi.acl_add_replace(self.acl_index,
+ reply = self._test.vapi.acl_add_replace(acl_index=self.acl_index,
r=rules,
tag=b'GBPTest')
self.acl_index = reply.acl_index
@@ -1171,9 +1186,11 @@ class TestGBP(VppTestCase):
self, epgs[0].sclass, epgs[1].sclass, acl_index,
[VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[]),
VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[])],
[ETH_P_IP, ETH_P_IPV6])
c1.add_vpp_config()
@@ -1191,9 +1208,11 @@ class TestGBP(VppTestCase):
self, epgs[1].sclass, epgs[0].sclass, acl_index,
[VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[]),
VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[])],
[ETH_P_IP, ETH_P_IPV6])
c2.add_vpp_config()
@@ -1233,9 +1252,11 @@ class TestGBP(VppTestCase):
self, epgs[0].sclass, epgs[2].sclass, acl_index,
[VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[]),
VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[])],
[ETH_P_IP, ETH_P_IPV6])
c3.add_vpp_config()
@@ -1338,9 +1359,11 @@ class TestGBP(VppTestCase):
self, epgs[0].sclass, epgs[3].sclass, acl_index2,
[VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[]),
VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[])],
[ETH_P_IP, ETH_P_IPV6])
c4.add_vpp_config()
@@ -1379,9 +1402,11 @@ class TestGBP(VppTestCase):
self, epgs[3].sclass, epgs[0].sclass, acl_index2,
[VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[]),
VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[])],
[ETH_P_IP, ETH_P_IPV6])
c5.add_vpp_config()
@@ -1896,9 +1921,11 @@ class TestGBP(VppTestCase):
self, epg_220.sclass, epg_330.sclass, acl_index,
[VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[]),
VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[])],
[ETH_P_IP, ETH_P_IPV6])
c1.add_vpp_config()
@@ -2117,9 +2144,11 @@ class TestGBP(VppTestCase):
self, epgs[0].sclass, epgs[1].sclass, acl_index,
[VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[]),
VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[])],
[ETH_P_IP, ETH_P_IPV6])
c1.add_vpp_config()
@@ -2144,9 +2173,11 @@ class TestGBP(VppTestCase):
self, epgs[1].sclass, epgs[0].sclass, acl_index,
[VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[]),
VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[])],
[ETH_P_IP, ETH_P_IPV6])
c2.add_vpp_config()
@@ -2171,9 +2202,11 @@ class TestGBP(VppTestCase):
self, epgs[0].sclass, epgs[2].sclass, acl_index,
[VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[]),
VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[])],
[ETH_P_IP, ETH_P_IPV6])
c3.add_vpp_config()
@@ -3333,9 +3366,11 @@ class TestGBP(VppTestCase):
self, epg_221.sclass, epg_220.sclass, acl_index,
[VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[]),
VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[])],
[ETH_P_IP, ETH_P_IPV6])
c4.add_vpp_config()
@@ -3749,9 +3784,11 @@ class TestGBP(VppTestCase):
self, 4220, 4221, acl_index,
[VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[]),
VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[])],
[ETH_P_IP, ETH_P_IPV6])
c1.add_vpp_config()
@@ -3763,9 +3800,11 @@ class TestGBP(VppTestCase):
self, 4220, 113, acl_index,
[VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[]),
VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[])],
[ETH_P_IP, ETH_P_IPV6])
c2.add_vpp_config()
@@ -3773,9 +3812,11 @@ class TestGBP(VppTestCase):
self, 113, 4220, acl_index,
[VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[]),
VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[])],
[ETH_P_IP, ETH_P_IPV6])
c3.add_vpp_config()
@@ -3905,9 +3946,11 @@ class TestGBP(VppTestCase):
self, 4220, 4222, acl_index,
[VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[]),
VppGbpContractRule(
VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT,
+ VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP,
[])],
[ETH_P_IP, ETH_P_IPV6])
c4.add_vpp_config()
diff --git a/test/test_vxlan_gbp.py b/test/test_vxlan_gbp.py
index 9abff19bb79..bd70eefa685 100644
--- a/test/test_vxlan_gbp.py
+++ b/test/test_vxlan_gbp.py
@@ -103,9 +103,16 @@ class TestVxlanGbp(VppTestCase):
register=False)
rip.add_vpp_config()
r = cls.vapi.vxlan_gbp_tunnel_add_del(
- cls.pg0.local_ip4,
- dest_ip4,
- vni=vni)
+ tunnel={
+ 'src': VppIpAddress(cls.pg0.local_ip4).encode(),
+ 'dst': VppIpAddress(dest_ip4).encode(),
+ 'vni': vni,
+ 'instance': INVALID_INDEX,
+ 'mcast_sw_if_index': INVALID_INDEX,
+ 'mode': 1,
+ },
+ is_add=1
+ )
cls.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=r.sw_if_index,
bd_id=vni)
@@ -139,13 +146,21 @@ class TestVxlanGbp(VppTestCase):
# pg1 into BD.
cls.single_tunnel_bd = 1
r = cls.vapi.vxlan_gbp_tunnel_add_del(
- VppIpAddress(cls.pg0.local_ip4).encode(),
- VppIpAddress(cls.pg0.remote_ip4).encode(),
- vni=cls.single_tunnel_bd)
+ tunnel={
+ 'src': VppIpAddress(cls.pg0.local_ip4).encode(),
+ 'dst': VppIpAddress(cls.pg0.remote_ip4).encode(),
+ 'vni': cls.single_tunnel_bd,
+ 'instance': INVALID_INDEX,
+ 'mcast_sw_if_index': INVALID_INDEX,
+ 'mode': 1,
+ },
+ is_add=1
+ )
cls.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=r.sw_if_index,
bd_id=cls.single_tunnel_bd)
cls.vapi.sw_interface_set_l2_bridge(
- rx_sw_if_index=cls.pg1.sw_if_index, bd_id=cls.single_tunnel_bd)
+ rx_sw_if_index=cls.pg1.sw_if_index,
+ bd_id=cls.single_tunnel_bd)
# Setup vni 2 to test multicast flooding
cls.n_ucast_tunnels = 2
@@ -154,7 +169,8 @@ class TestVxlanGbp(VppTestCase):
cls.create_vxlan_gbp_flood_test_bd(cls.ucast_flood_bd,
cls.n_ucast_tunnels)
cls.vapi.sw_interface_set_l2_bridge(
- rx_sw_if_index=cls.pg3.sw_if_index, bd_id=cls.ucast_flood_bd)
+ rx_sw_if_index=cls.pg3.sw_if_index,
+ bd_id=cls.ucast_flood_bd)
except Exception:
super(TestVxlanGbp, cls).tearDownClass()
raise
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index 75ec57f8221..29a5716508c 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -131,8 +131,6 @@ defaultmapping = {
'vxlan_add_del_tunnel': {'mcast_sw_if_index': 4294967295, 'is_add': 1,
'decap_next_index': 4294967295,
'instance': 4294967295, },
- 'vxlan_gbp_tunnel_add_del': {'mcast_sw_if_index': 4294967295, 'is_add': 1,
- 'instance': 4294967295, },
'vxlan_gbp_tunnel_dump': {'sw_if_index': 4294967295, },
'vxlan_gpe_add_del_tunnel': {'mcast_sw_if_index': 4294967295, 'is_add': 1,
'protocol': 3, },
@@ -331,7 +329,7 @@ class VppPapiProvider(object):
if hasattr(reply, 'retval') and reply.retval != expected_retval:
msg = "API call failed, expected %d return value instead " \
"of %d in %s" % (expected_retval, reply.retval,
- moves.reprlib.repr(reply))
+ repr(reply))
self.test_class.logger.info(msg)
raise UnexpectedApiReturnValueError(msg)
else:
@@ -1276,41 +1274,6 @@ class VppPapiProvider(object):
'protocol': protocol,
'vni': vni})
- def vxlan_gbp_tunnel_add_del(
- self,
- src,
- dst,
- mcast_sw_if_index=0xFFFFFFFF,
- is_add=1,
- is_ipv6=0,
- encap_table_id=0,
- vni=0,
- mode=1,
- instance=0xFFFFFFFF):
- """
-
- :param dst_addr:
- :param src_addr:
- :param is_add: (Default value = 1)
- :param is_ipv6: (Default value = 0)
- :param encap_table_id: (Default value = 0)
- :param decap_next_index: (Default value = 0xFFFFFFFF)
- :param mcast_sw_if_index: (Default value = 0xFFFFFFFF)
- :param vni: (Default value = 0)
- :param instance: (Default value = 0xFFFFFFFF)
-
- """
- return self.api(self.papi.vxlan_gbp_tunnel_add_del,
- {'is_add': is_add,
- 'tunnel': {
- 'src': src,
- 'dst': dst,
- 'mcast_sw_if_index': mcast_sw_if_index,
- 'encap_table_id': encap_table_id,
- 'vni': vni,
- 'instance': instance,
- "mode": mode}})
-
def vxlan_gbp_tunnel_dump(self, sw_if_index=0xffffffff):
return self.api(self.papi.vxlan_gbp_tunnel_dump,
{'sw_if_index': sw_if_index,
@@ -2135,20 +2098,6 @@ class VppPapiProvider(object):
return self.api(self.papi.gbp_subnet_dump,
{'_no_type_conversion': True})
- def gbp_contract_add_del(self, is_add, sclass, dclass, acl_index,
- rules, allowed_ethertypes):
- """ GBP contract Add/Del """
- return self.api(self.papi.gbp_contract_add_del,
- {'is_add': is_add,
- 'contract': {
- 'acl_index': acl_index,
- 'sclass': sclass,
- 'dclass': dclass,
- 'n_rules': len(rules),
- 'rules': rules,
- 'n_ether_types': len(allowed_ethertypes),
- 'allowed_ethertypes': allowed_ethertypes}})
-
def gbp_contract_dump(self):
""" GBP contract Dump """
return self.api(self.papi.gbp_contract_dump, {})
diff --git a/test/vpp_vxlan_gbp_tunnel.py b/test/vpp_vxlan_gbp_tunnel.py
index 47817ed168f..5352d6ebf31 100644
--- a/test/vpp_vxlan_gbp_tunnel.py
+++ b/test/vpp_vxlan_gbp_tunnel.py
@@ -25,13 +25,17 @@ class VppVxlanGbpTunnel(VppInterface):
VPP VXLAN GBP interface
"""
- def __init__(self, test, src, dst, vni, mcast_itf=None, mode=None):
+ def __init__(self, test, src, dst, vni, mcast_itf=None, mode=None,
+ is_ipv6=None, encap_table_id=None, instance=0xffffffff):
""" Create VXLAN-GBP Tunnel interface """
super(VppVxlanGbpTunnel, self).__init__(test)
self.src = VppIpAddress(src)
self.dst = VppIpAddress(dst)
self.vni = vni
self.mcast_itf = mcast_itf
+ self.ipv6 = is_ipv6
+ self.encap_table_id = encap_table_id
+ self.instance = instance
if not mode:
self.mode = (VppEnum.vl_api_vxlan_gbp_api_tunnel_mode_t.
VXLAN_GBP_API_TUNNEL_MODE_L2)
@@ -43,11 +47,16 @@ class VppVxlanGbpTunnel(VppInterface):
if (self.mcast_itf):
mcast_sw_if_index = self.mcast_itf.sw_if_index
reply = self.test.vapi.vxlan_gbp_tunnel_add_del(
- self.src.encode(),
- self.dst.encode(),
- mode=self.mode,
- vni=self.vni,
- mcast_sw_if_index=mcast_sw_if_index)
+ is_add=1,
+ tunnel={
+ 'src': self.src.encode(),
+ 'dst': self.dst.encode(),
+ 'mode': self.mode,
+ 'vni': self.vni,
+ 'mcast_sw_if_index': mcast_sw_if_index,
+ 'encap_table_id': self.encap_table_id,
+ 'instance': self.instance
+ })
self.set_sw_if_index(reply.sw_if_index)
self._test.registry.register(self, self._test.logger)
@@ -56,11 +65,16 @@ class VppVxlanGbpTunnel(VppInterface):
if (self.mcast_itf):
mcast_sw_if_index = self.mcast_itf.sw_if_index
self.test.vapi.vxlan_gbp_tunnel_add_del(
- self.src.encode(),
- self.dst.encode(),
- vni=self.vni,
is_add=0,
- mcast_sw_if_index=mcast_sw_if_index)
+ tunnel={
+ 'src': self.src.encode(),
+ 'dst': self.dst.encode(),
+ 'mode': self.mode,
+ 'vni': self.vni,
+ 'mcast_sw_if_index': mcast_sw_if_index,
+ 'encap_table_id': self.encap_table_id,
+ 'instance': self.instance,
+ })
def query_vpp_config(self):
return (INDEX_INVALID != find_vxlan_gbp_tunnel(self._test,