summaryrefslogtreecommitdiffstats
path: root/test/vpp_vxlan_tunnel.py
diff options
context:
space:
mode:
authorKlement Sekera <klement.sekera@gmail.com>2022-04-26 19:02:15 +0200
committerOle Tr�an <otroan@employees.org>2022-05-10 18:52:08 +0000
commitd9b0c6fbf7aa5bd9af84264105b39c82028a4a29 (patch)
tree4f786cfd8ebc2443cb11e11b74c8657204068898 /test/vpp_vxlan_tunnel.py
parentf90348bcb4afd0af2611cefc43b17ef3042b511c (diff)
tests: replace pycodestyle with black
Drop pycodestyle for code style checking in favor of black. Black is much faster, stable PEP8 compliant code style checker offering also automatic formatting. It aims to be very stable and produce smallest diffs. It's used by many small and big projects. Running checkstyle with black takes a few seconds with a terse output. Thus, test-checkstyle-diff is no longer necessary. Expand scope of checkstyle to all python files in the repo, replacing test-checkstyle with checkstyle-python. Also, fixstyle-python is now available for automatic style formatting. Note: python virtualenv has been consolidated in test/Makefile, test/requirements*.txt which will eventually be moved to a central location. This is required to simply the automated generation of docker executor images in the CI. Type: improvement Change-Id: I022a326603485f58585e879ac0f697fceefbc9c8 Signed-off-by: Klement Sekera <klement.sekera@gmail.com> Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Diffstat (limited to 'test/vpp_vxlan_tunnel.py')
-rw-r--r--test/vpp_vxlan_tunnel.py80
1 files changed, 50 insertions, 30 deletions
diff --git a/test/vpp_vxlan_tunnel.py b/test/vpp_vxlan_tunnel.py
index d7e087da6f8..8c993b09196 100644
--- a/test/vpp_vxlan_tunnel.py
+++ b/test/vpp_vxlan_tunnel.py
@@ -2,7 +2,7 @@ from vpp_interface import VppInterface
from vpp_papi import VppEnum
-INDEX_INVALID = 0xffffffff
+INDEX_INVALID = 0xFFFFFFFF
DEFAULT_PORT = 4789
UNDEFINED_PORT = 0
@@ -19,11 +19,13 @@ def find_vxlan_tunnel(test, src, dst, s_port, d_port, vni):
dst_port = d_port
for t in ts:
- if src == str(t.src_address) and \
- dst == str(t.dst_address) and \
- src_port == t.src_port and \
- dst_port == t.dst_port and \
- t.vni == vni:
+ if (
+ src == str(t.src_address)
+ and dst == str(t.dst_address)
+ and src_port == t.src_port
+ and dst_port == t.dst_port
+ and t.vni == vni
+ ):
return t.sw_if_index
return INDEX_INVALID
@@ -33,13 +35,22 @@ class VppVxlanTunnel(VppInterface):
VPP VXLAN interface
"""
- def __init__(self, test, src, dst, vni,
- src_port=UNDEFINED_PORT, dst_port=UNDEFINED_PORT,
- mcast_itf=None,
- mcast_sw_if_index=INDEX_INVALID,
- decap_next_index=INDEX_INVALID,
- encap_vrf_id=None, instance=0xffffffff, is_l3=False):
- """ Create VXLAN Tunnel interface """
+ def __init__(
+ self,
+ test,
+ src,
+ dst,
+ vni,
+ src_port=UNDEFINED_PORT,
+ dst_port=UNDEFINED_PORT,
+ mcast_itf=None,
+ mcast_sw_if_index=INDEX_INVALID,
+ decap_next_index=INDEX_INVALID,
+ encap_vrf_id=None,
+ instance=0xFFFFFFFF,
+ is_l3=False,
+ ):
+ """Create VXLAN Tunnel interface"""
super(VppVxlanTunnel, self).__init__(test)
self.src = src
self.dst = dst
@@ -53,35 +64,44 @@ class VppVxlanTunnel(VppInterface):
self.instance = instance
self.is_l3 = is_l3
- if (self.mcast_itf):
+ if self.mcast_itf:
self.mcast_sw_if_index = self.mcast_itf.sw_if_index
def add_vpp_config(self):
reply = self.test.vapi.vxlan_add_del_tunnel_v3(
- is_add=1, src_address=self.src, dst_address=self.dst, vni=self.vni,
- src_port=self.src_port, dst_port=self.dst_port,
+ is_add=1,
+ src_address=self.src,
+ dst_address=self.dst,
+ vni=self.vni,
+ src_port=self.src_port,
+ dst_port=self.dst_port,
mcast_sw_if_index=self.mcast_sw_if_index,
- encap_vrf_id=self.encap_vrf_id, is_l3=self.is_l3,
- instance=self.instance, decap_next_index=self.decap_next_index)
+ encap_vrf_id=self.encap_vrf_id,
+ is_l3=self.is_l3,
+ instance=self.instance,
+ decap_next_index=self.decap_next_index,
+ )
self.set_sw_if_index(reply.sw_if_index)
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
self.test.vapi.vxlan_add_del_tunnel_v2(
- is_add=0, src_address=self.src, dst_address=self.dst, vni=self.vni,
- src_port=self.src_port, dst_port=self.dst_port,
+ is_add=0,
+ src_address=self.src,
+ dst_address=self.dst,
+ vni=self.vni,
+ src_port=self.src_port,
+ dst_port=self.dst_port,
mcast_sw_if_index=self.mcast_sw_if_index,
- encap_vrf_id=self.encap_vrf_id, instance=self.instance,
- decap_next_index=self.decap_next_index)
+ encap_vrf_id=self.encap_vrf_id,
+ instance=self.instance,
+ decap_next_index=self.decap_next_index,
+ )
def query_vpp_config(self):
- return (INDEX_INVALID != find_vxlan_tunnel(self._test,
- self.src,
- self.dst,
- self.src_port,
- self.dst_port,
- self.vni))
+ return INDEX_INVALID != find_vxlan_tunnel(
+ self._test, self.src, self.dst, self.src_port, self.dst_port, self.vni
+ )
def object_id(self):
- return "vxlan-%d-%d-%s-%s" % (self.sw_if_index, self.vni,
- self.src, self.dst)
+ return "vxlan-%d-%d-%s-%s" % (self.sw_if_index, self.vni, self.src, self.dst)