aboutsummaryrefslogtreecommitdiffstats
path: root/test/vpp_bier.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_bier.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_bier.py')
-rw-r--r--test/vpp_bier.py140
1 files changed, 62 insertions, 78 deletions
diff --git a/test/vpp_bier.py b/test/vpp_bier.py
index 6e087a8ee0b..9fdaf1faa1c 100644
--- a/test/vpp_bier.py
+++ b/test/vpp_bier.py
@@ -18,7 +18,7 @@ class BIER_HDR_PAYLOAD:
BIER_HDR_PROTO_OAM = 8
-class VppBierTableID():
+class VppBierTableID:
def __init__(self, sub_domain_id, set_id, hdr_len_id):
self.set_id = set_id
self.sub_domain_id = sub_domain_id
@@ -28,9 +28,11 @@ class VppBierTableID():
def find_bier_table(test, bti):
tables = test.vapi.bier_table_dump()
for t in tables:
- if bti.set_id == t.bt_tbl_id.bt_set \
- and bti.sub_domain_id == t.bt_tbl_id.bt_sub_domain \
- and bti.hdr_len_id == t.bt_tbl_id.bt_hdr_len_id:
+ if (
+ bti.set_id == t.bt_tbl_id.bt_set
+ and bti.sub_domain_id == t.bt_tbl_id.bt_sub_domain
+ and bti.hdr_len_id == t.bt_tbl_id.bt_hdr_len_id
+ ):
return True
return False
@@ -38,10 +40,12 @@ def find_bier_table(test, bti):
def find_bier_route(test, bti, bp):
routes = test.vapi.bier_route_dump(bti)
for r in routes:
- if bti.set_id == r.br_route.br_tbl_id.bt_set \
- and bti.sub_domain_id == r.br_route.br_tbl_id.bt_sub_domain \
- and bti.hdr_len_id == r.br_route.br_tbl_id.bt_hdr_len_id \
- and bp == r.br_route.br_bp:
+ if (
+ bti.set_id == r.br_route.br_tbl_id.bt_set
+ and bti.sub_domain_id == r.br_route.br_tbl_id.bt_sub_domain
+ and bti.hdr_len_id == r.br_route.br_tbl_id.bt_hdr_len_id
+ and bp == r.br_route.br_bp
+ ):
return True
return False
@@ -57,8 +61,7 @@ def find_bier_disp_table(test, bdti):
def find_bier_disp_entry(test, bdti, bp):
entries = test.vapi.bier_disp_entry_dump(bdti)
for e in entries:
- if bp == e.bde_bp \
- and bdti == e.bde_tbl_id:
+ if bp == e.bde_bp and bdti == e.bde_tbl_id:
return True
return False
@@ -66,10 +69,12 @@ def find_bier_disp_entry(test, bdti, bp):
def find_bier_imp(test, bti, bp):
imps = test.vapi.bier_imp_dump()
for i in imps:
- if bti.set_id == i.bi_tbl_id.bt_set \
- and bti.sub_domain_id == i.bi_tbl_id.bt_sub_domain \
- and bti.hdr_len_id == i.bi_tbl_id.bt_hdr_len_id \
- and bp == i.bi_src:
+ if (
+ bti.set_id == i.bi_tbl_id.bt_set
+ and bti.sub_domain_id == i.bi_tbl_id.bt_sub_domain
+ and bti.hdr_len_id == i.bi_tbl_id.bt_hdr_len_id
+ and bp == i.bi_src
+ ):
return True
return False
@@ -85,22 +90,18 @@ class VppBierTable(VppObject):
self.mpls_label = mpls_label
def add_vpp_config(self):
- self._test.vapi.bier_table_add_del(
- self.id,
- self.mpls_label,
- is_add=1)
+ self._test.vapi.bier_table_add_del(self.id, self.mpls_label, is_add=1)
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
- self._test.vapi.bier_table_add_del(
- self.id,
- self.mpls_label,
- is_add=0)
+ self._test.vapi.bier_table_add_del(self.id, self.mpls_label, is_add=0)
def object_id(self):
- return "bier-table;[%d:%d:%d]" % (self.id.set_id,
- self.id.sub_domain_id,
- self.id.hdr_len_id)
+ return "bier-table;[%d:%d:%d]" % (
+ self.id.set_id,
+ self.id.sub_domain_id,
+ self.id.hdr_len_id,
+ )
def query_vpp_config(self):
return find_bier_table(self._test, self.id)
@@ -122,18 +123,14 @@ class VppBierRoute(VppObject):
def add_vpp_config(self):
self._test.vapi.bier_route_add_del(
- self.tbl_id,
- self.bp,
- self.encoded_paths,
- is_add=1)
+ self.tbl_id, self.bp, self.encoded_paths, is_add=1
+ )
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
self._test.vapi.bier_route_add_del(
- self.tbl_id,
- self.bp,
- self.encoded_paths,
- is_add=0)
+ self.tbl_id, self.bp, self.encoded_paths, is_add=0
+ )
def update_paths(self, paths):
self.paths = paths
@@ -141,46 +138,37 @@ class VppBierRoute(VppObject):
for path in self.paths:
self.encoded_paths.append(path.encode())
self._test.vapi.bier_route_add_del(
- self.tbl_id,
- self.bp,
- self.encoded_paths,
- is_replace=1)
+ self.tbl_id, self.bp, self.encoded_paths, is_replace=1
+ )
def add_path(self, path):
self.encoded_paths.append(path.encode())
self._test.vapi.bier_route_add_del(
- self.tbl_id,
- self.bp,
- [path.encode()],
- is_add=1,
- is_replace=0)
+ self.tbl_id, self.bp, [path.encode()], is_add=1, is_replace=0
+ )
self.paths.append(path)
self._test.registry.register(self, self._test.logger)
def remove_path(self, path):
self.encoded_paths.remove(path.encode())
self._test.vapi.bier_route_add_del(
- self.tbl_id,
- self.bp,
- [path.encode()],
- is_add=0,
- is_replace=0)
+ self.tbl_id, self.bp, [path.encode()], is_add=0, is_replace=0
+ )
self.paths.remove(path)
def remove_all_paths(self):
self._test.vapi.bier_route_add_del(
- self.tbl_id,
- self.bp,
- [],
- is_add=0,
- is_replace=1)
+ self.tbl_id, self.bp, [], is_add=0, is_replace=1
+ )
self.paths = []
def object_id(self):
- return "bier-route;[%d:%d:%d:%d]" % (self.tbl_id.set_id,
- self.tbl_id.sub_domain_id,
- self.tbl_id.hdr_len_id,
- self.bp)
+ return "bier-route;[%d:%d:%d:%d]" % (
+ self.tbl_id.set_id,
+ self.tbl_id.sub_domain_id,
+ self.tbl_id.hdr_len_id,
+ self.bp,
+ )
def query_vpp_config(self):
return find_bier_route(self._test, self.tbl_id, self.bp)
@@ -198,22 +186,20 @@ class VppBierImp(VppObject):
self.src = src
def add_vpp_config(self):
- res = self._test.vapi.bier_imp_add(
- self.tbl_id,
- self.src,
- self.ibytes)
+ res = self._test.vapi.bier_imp_add(self.tbl_id, self.src, self.ibytes)
self.bi_index = res.bi_index
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
- self._test.vapi.bier_imp_del(
- self.bi_index)
+ self._test.vapi.bier_imp_del(self.bi_index)
def object_id(self):
- return "bier-imp;[%d:%d:%d:%d]" % (self.tbl_id.set_id,
- self.tbl_id.sub_domain_id,
- self.tbl_id.hdr_len_id,
- self.src)
+ return "bier-imp;[%d:%d:%d:%d]" % (
+ self.tbl_id.set_id,
+ self.tbl_id.sub_domain_id,
+ self.tbl_id.hdr_len_id,
+ self.src,
+ )
def query_vpp_config(self):
return find_bier_imp(self._test, self.tbl_id, self.src)
@@ -229,15 +215,11 @@ class VppBierDispTable(VppObject):
self.id = id
def add_vpp_config(self):
- self._test.vapi.bier_disp_table_add_del(
- self.id,
- is_add=1)
+ self._test.vapi.bier_disp_table_add_del(self.id, is_add=1)
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
- self._test.vapi.bier_disp_table_add_del(
- self.id,
- is_add=0)
+ self._test.vapi.bier_disp_table_add_del(self.id, is_add=0)
def object_id(self):
return "bier-disp-table;[%d]" % (self.id)
@@ -251,8 +233,9 @@ class VppBierDispEntry(VppObject):
BIER Disposition Entry
"""
- def __init__(self, test, tbl_id, bp, payload_proto, nh_proto,
- nh, nh_tbl, rpf_id=~0):
+ def __init__(
+ self, test, tbl_id, bp, payload_proto, nh_proto, nh, nh_tbl, rpf_id=~0
+ ):
self._test = test
self.tbl_id = tbl_id
self.nh_tbl = nh_tbl
@@ -271,7 +254,8 @@ class VppBierDispEntry(VppObject):
self.nh,
self.nh_tbl,
self.rpf_id,
- is_add=1)
+ is_add=1,
+ )
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
@@ -283,11 +267,11 @@ class VppBierDispEntry(VppObject):
self.nh,
self.nh_tbl,
self.rpf_id,
- is_add=0)
+ is_add=0,
+ )
def object_id(self):
- return "bier-disp-entry;[%d:%d]" % (self.tbl_id,
- self.bp)
+ return "bier-disp-entry;[%d:%d]" % (self.tbl_id, self.bp)
def query_vpp_config(self):
return find_bier_disp_entry(self._test, self.tbl_id, self.bp)