aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_ipfix_export.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/test_ipfix_export.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/test_ipfix_export.py')
-rw-r--r--test/test_ipfix_export.py134
1 files changed, 69 insertions, 65 deletions
diff --git a/test/test_ipfix_export.py b/test/test_ipfix_export.py
index be7476e67cf..f7b8be7e4d8 100644
--- a/test/test_ipfix_export.py
+++ b/test/test_ipfix_export.py
@@ -16,7 +16,7 @@ from socket import AF_INET, AF_INET6
class TestIpfixExporter(VppTestCase):
- """ Ipfix Exporter Tests """
+ """Ipfix Exporter Tests"""
def setUp(self):
super(TestIpfixExporter, self).setUp()
@@ -37,15 +37,16 @@ class TestIpfixExporter(VppTestCase):
i.admin_down()
def find_exp_by_collector_addr(self, exporters, addr):
- """ Find the exporter in the list of exportes with the given addr """
+ """Find the exporter in the list of exportes with the given addr"""
for exp in exporters:
if exp.collector_address == IPv4Address(addr):
return exp
return None
- def verify_exporter_detail(self, exp, collector_addr, src_addr,
- collector_port=4739, mtu=1400, interval=20):
+ def verify_exporter_detail(
+ self, exp, collector_addr, src_addr, collector_port=4739, mtu=1400, interval=20
+ ):
self.assertTrue(exp is not None)
self.assert_equal(exp.collector_address, collector_addr)
self.assert_equal(exp.src_address, src_addr)
@@ -54,7 +55,7 @@ class TestIpfixExporter(VppTestCase):
self.assert_equal(exp.template_interval, interval)
def test_create_multipe_exporters(self):
- """ test that we can create and dump multiple exporters """
+ """test that we can create and dump multiple exporters"""
mtu = 1400
interval = 20
@@ -66,20 +67,20 @@ class TestIpfixExporter(VppTestCase):
src_address=self.pg0.local_ip4,
collector_port=4739,
path_mtu=mtu,
- template_interval=interval)
+ template_interval=interval,
+ )
exporters = self.vapi.ipfix_exporter_dump()
exp = self.find_exp_by_collector_addr(exporters, self.pg1.remote_ip4)
- self.verify_exporter_detail(exp,
- IPv4Address(self.pg1.remote_ip4),
- IPv4Address(self.pg0.local_ip4))
+ self.verify_exporter_detail(
+ exp, IPv4Address(self.pg1.remote_ip4), IPv4Address(self.pg0.local_ip4)
+ )
- exporters = list(self.vapi.vpp.details_iter(
- self.vapi.ipfix_all_exporter_get))
+ exporters = list(self.vapi.vpp.details_iter(self.vapi.ipfix_all_exporter_get))
exp = self.find_exp_by_collector_addr(exporters, self.pg1.remote_ip4)
- self.verify_exporter_detail(exp,
- IPv4Address(self.pg1.remote_ip4),
- IPv4Address(self.pg0.local_ip4))
+ self.verify_exporter_detail(
+ exp, IPv4Address(self.pg1.remote_ip4), IPv4Address(self.pg0.local_ip4)
+ )
# create a 2nd exporter
self.vapi.ipfix_exporter_create_delete(
@@ -88,19 +89,19 @@ class TestIpfixExporter(VppTestCase):
collector_port=4739,
path_mtu=mtu,
template_interval=interval,
- is_create=True)
+ is_create=True,
+ )
- exporters = list(self.vapi.vpp.details_iter(
- self.vapi.ipfix_all_exporter_get))
+ exporters = list(self.vapi.vpp.details_iter(self.vapi.ipfix_all_exporter_get))
self.assertTrue(len(exporters) == 2)
exp = self.find_exp_by_collector_addr(exporters, self.pg1.remote_ip4)
- self.verify_exporter_detail(exp,
- IPv4Address(self.pg1.remote_ip4),
- IPv4Address(self.pg0.local_ip4))
+ self.verify_exporter_detail(
+ exp, IPv4Address(self.pg1.remote_ip4), IPv4Address(self.pg0.local_ip4)
+ )
exp = self.find_exp_by_collector_addr(exporters, self.pg2.remote_ip4)
- self.verify_exporter_detail(exp,
- IPv4Address(self.pg2.remote_ip4),
- IPv4Address(self.pg0.local_ip4))
+ self.verify_exporter_detail(
+ exp, IPv4Address(self.pg2.remote_ip4), IPv4Address(self.pg0.local_ip4)
+ )
# Create a 3rd exporter
self.vapi.ipfix_exporter_create_delete(
@@ -109,49 +110,52 @@ class TestIpfixExporter(VppTestCase):
collector_port=4739,
path_mtu=mtu,
template_interval=interval,
- is_create=True)
+ is_create=True,
+ )
- exporters = list(self.vapi.vpp.details_iter(
- self.vapi.ipfix_all_exporter_get))
+ exporters = list(self.vapi.vpp.details_iter(self.vapi.ipfix_all_exporter_get))
self.assertTrue(len(exporters) == 3)
exp = self.find_exp_by_collector_addr(exporters, self.pg1.remote_ip4)
- self.verify_exporter_detail(exp,
- IPv4Address(self.pg1.remote_ip4),
- IPv4Address(self.pg0.local_ip4))
+ self.verify_exporter_detail(
+ exp, IPv4Address(self.pg1.remote_ip4), IPv4Address(self.pg0.local_ip4)
+ )
exp = self.find_exp_by_collector_addr(exporters, self.pg2.remote_ip4)
- self.verify_exporter_detail(exp,
- IPv4Address(self.pg2.remote_ip4),
- IPv4Address(self.pg0.local_ip4))
+ self.verify_exporter_detail(
+ exp, IPv4Address(self.pg2.remote_ip4), IPv4Address(self.pg0.local_ip4)
+ )
exp = self.find_exp_by_collector_addr(exporters, self.pg3.remote_ip4)
- self.verify_exporter_detail(exp,
- IPv4Address(self.pg3.remote_ip4),
- IPv4Address(self.pg0.local_ip4))
+ self.verify_exporter_detail(
+ exp, IPv4Address(self.pg3.remote_ip4), IPv4Address(self.pg0.local_ip4)
+ )
# Modify the 2nd exporter.
self.vapi.ipfix_exporter_create_delete(
collector_address=self.pg2.remote_ip4,
src_address=self.pg0.local_ip4,
collector_port=4739,
- path_mtu=mtu+1,
- template_interval=interval+1,
- is_create=True)
+ path_mtu=mtu + 1,
+ template_interval=interval + 1,
+ is_create=True,
+ )
- exporters = list(self.vapi.vpp.details_iter(
- self.vapi.ipfix_all_exporter_get))
+ exporters = list(self.vapi.vpp.details_iter(self.vapi.ipfix_all_exporter_get))
self.assertTrue(len(exporters) == 3)
exp = self.find_exp_by_collector_addr(exporters, self.pg1.remote_ip4)
- self.verify_exporter_detail(exp,
- IPv4Address(self.pg1.remote_ip4),
- IPv4Address(self.pg0.local_ip4))
+ self.verify_exporter_detail(
+ exp, IPv4Address(self.pg1.remote_ip4), IPv4Address(self.pg0.local_ip4)
+ )
exp = self.find_exp_by_collector_addr(exporters, self.pg2.remote_ip4)
- self.verify_exporter_detail(exp,
- IPv4Address(self.pg2.remote_ip4),
- IPv4Address(self.pg0.local_ip4),
- mtu=mtu+1, interval=interval+1)
+ self.verify_exporter_detail(
+ exp,
+ IPv4Address(self.pg2.remote_ip4),
+ IPv4Address(self.pg0.local_ip4),
+ mtu=mtu + 1,
+ interval=interval + 1,
+ )
exp = self.find_exp_by_collector_addr(exporters, self.pg3.remote_ip4)
- self.verify_exporter_detail(exp,
- IPv4Address(self.pg3.remote_ip4),
- IPv4Address(self.pg0.local_ip4))
+ self.verify_exporter_detail(
+ exp, IPv4Address(self.pg3.remote_ip4), IPv4Address(self.pg0.local_ip4)
+ )
# Delete 2nd exporter
self.vapi.ipfix_exporter_create_delete(
@@ -160,19 +164,19 @@ class TestIpfixExporter(VppTestCase):
collector_port=4739,
path_mtu=mtu,
template_interval=interval,
- is_create=False)
+ is_create=False,
+ )
- exporters = list(self.vapi.vpp.details_iter(
- self.vapi.ipfix_all_exporter_get))
+ exporters = list(self.vapi.vpp.details_iter(self.vapi.ipfix_all_exporter_get))
self.assertTrue(len(exporters) == 2)
exp = self.find_exp_by_collector_addr(exporters, self.pg1.remote_ip4)
- self.verify_exporter_detail(exp,
- IPv4Address(self.pg1.remote_ip4),
- IPv4Address(self.pg0.local_ip4))
+ self.verify_exporter_detail(
+ exp, IPv4Address(self.pg1.remote_ip4), IPv4Address(self.pg0.local_ip4)
+ )
exp = self.find_exp_by_collector_addr(exporters, self.pg3.remote_ip4)
- self.verify_exporter_detail(exp,
- IPv4Address(self.pg3.remote_ip4),
- IPv4Address(self.pg0.local_ip4))
+ self.verify_exporter_detail(
+ exp, IPv4Address(self.pg3.remote_ip4), IPv4Address(self.pg0.local_ip4)
+ )
# Delete final exporter (exporter in slot 0 can not be deleted)
self.vapi.ipfix_exporter_create_delete(
@@ -181,12 +185,12 @@ class TestIpfixExporter(VppTestCase):
collector_port=4739,
path_mtu=mtu,
template_interval=interval,
- is_create=False)
+ is_create=False,
+ )
- exporters = list(self.vapi.vpp.details_iter(
- self.vapi.ipfix_all_exporter_get))
+ exporters = list(self.vapi.vpp.details_iter(self.vapi.ipfix_all_exporter_get))
self.assertTrue(len(exporters) == 1)
exp = self.find_exp_by_collector_addr(exporters, self.pg1.remote_ip4)
- self.verify_exporter_detail(exp,
- IPv4Address(self.pg1.remote_ip4),
- IPv4Address(self.pg0.local_ip4))
+ self.verify_exporter_detail(
+ exp, IPv4Address(self.pg1.remote_ip4), IPv4Address(self.pg0.local_ip4)
+ )