summaryrefslogtreecommitdiffstats
path: root/test/test_stats_client.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_stats_client.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_stats_client.py')
-rw-r--r--test/test_stats_client.py69
1 files changed, 34 insertions, 35 deletions
diff --git a/test/test_stats_client.py b/test/test_stats_client.py
index f3db2ef3b2e..7b62b292853 100644
--- a/test/test_stats_client.py
+++ b/test/test_stats_client.py
@@ -32,7 +32,8 @@ class StatsClientTestCase(VppTestCase):
"""Test set errors"""
self.assertEqual(self.statistics.set_errors(), {})
self.assertEqual(
- self.statistics.get_counter('/err/ethernet-input/no error'), [0])
+ self.statistics.get_counter("/err/ethernet-input/no error"), [0]
+ )
def test_client_fd_leak(self):
"""Test file descriptor count - VPP-1486"""
@@ -46,11 +47,13 @@ class StatsClientTestCase(VppTestCase):
stats.disconnect()
ending_fds = p.num_fds()
- self.assertEqual(initial_fds, ending_fds,
- "initial client side file descriptor count: %s "
- "is not equal to "
- "ending client side file descriptor count: %s" % (
- initial_fds, ending_fds))
+ self.assertEqual(
+ initial_fds,
+ ending_fds,
+ "initial client side file descriptor count: %s "
+ "is not equal to "
+ "ending client side file descriptor count: %s" % (initial_fds, ending_fds),
+ )
def test_symlink_values(self):
"""Test symlinks reported values"""
@@ -63,16 +66,16 @@ class StatsClientTestCase(VppTestCase):
p = list()
for i in range(5):
- packet = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) /
- IP(src=self.pg0.remote_ip4, dst=self.pg1.remote_ip4))
+ packet = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) / IP(
+ src=self.pg0.remote_ip4, dst=self.pg1.remote_ip4
+ )
p.append(packet)
self.send_and_expect(self.pg0, p, self.pg1)
- pg1_tx = self.statistics.get_counter('/interfaces/pg1/tx')
- if_tx = self.statistics.get_counter('/if/tx')
+ pg1_tx = self.statistics.get_counter("/interfaces/pg1/tx")
+ if_tx = self.statistics.get_counter("/if/tx")
- self.assertEqual(pg1_tx[0]['bytes'],
- if_tx[0][self.pg1.sw_if_index]['bytes'])
+ self.assertEqual(pg1_tx[0]["bytes"], if_tx[0][self.pg1.sw_if_index]["bytes"])
for i in self.pg_interfaces:
i.unconfig()
i.admin_down()
@@ -93,31 +96,28 @@ class StatsClientTestCase(VppTestCase):
p = list()
bytes_to_send = 0
for i in range(5):
- packet = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) /
- IP(src=self.pg0.remote_ip4, dst=self.pg1.remote_ip4))
+ packet = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) / IP(
+ src=self.pg0.remote_ip4, dst=self.pg1.remote_ip4
+ )
bytes_to_send += len(packet)
p.append(packet)
- tx_before_sending = self.statistics.get_counter('/interfaces/pg1/tx')
- rx_before_sending = self.statistics.get_counter('/interfaces/pg0/rx')
+ tx_before_sending = self.statistics.get_counter("/interfaces/pg1/tx")
+ rx_before_sending = self.statistics.get_counter("/interfaces/pg0/rx")
self.send_and_expect(self.pg0, p, self.pg1)
- tx = self.statistics.get_counter('/interfaces/pg1/tx')
- rx = self.statistics.get_counter('/interfaces/pg0/rx')
+ tx = self.statistics.get_counter("/interfaces/pg1/tx")
+ rx = self.statistics.get_counter("/interfaces/pg0/rx")
# We wait for nodes symlinks to update (interfaces created/deleted).
# ... and packets to be sent
self.sleep(0.1)
- vectors = self.statistics.get_counter('/nodes/pg1-tx/vectors')
-
- self.assertEqual(tx[0]['bytes'] - tx_before_sending[0]['bytes'],
- bytes_to_send)
- self.assertEqual(tx[0]['packets'] - tx_before_sending[0]['packets'],
- 5)
- self.assertEqual(rx[0]['bytes'] - rx_before_sending[0]['bytes'],
- bytes_to_send)
- self.assertEqual(rx[0]['packets'] - rx_before_sending[0]['packets'],
- 5)
- self.assertEqual(vectors[0], rx[0]['packets'])
+ vectors = self.statistics.get_counter("/nodes/pg1-tx/vectors")
+
+ self.assertEqual(tx[0]["bytes"] - tx_before_sending[0]["bytes"], bytes_to_send)
+ self.assertEqual(tx[0]["packets"] - tx_before_sending[0]["packets"], 5)
+ self.assertEqual(rx[0]["bytes"] - rx_before_sending[0]["bytes"], bytes_to_send)
+ self.assertEqual(rx[0]["packets"] - rx_before_sending[0]["packets"], 5)
+ self.assertEqual(vectors[0], rx[0]["packets"])
for i in self.pg_interfaces:
i.unconfig()
@@ -125,7 +125,7 @@ class StatsClientTestCase(VppTestCase):
def test_index_consistency(self):
"""Test index consistency despite changes in the stats"""
- d = self.statistics.ls(['/if/names'])
+ d = self.statistics.ls(["/if/names"])
self.create_loopback_interfaces(10)
for i in range(10):
try:
@@ -142,22 +142,21 @@ class StatsClientTestCase(VppTestCase):
@unittest.skip("Manual only")
def test_mem_leak(self):
def loop():
- print('Running loop')
+ print("Running loop")
for i in range(50):
rv = self.vapi.papi.tap_create_v2(id=i, use_random_mac=1)
self.assertEqual(rv.retval, 0)
rv = self.vapi.papi.tap_delete_v2(sw_if_index=rv.sw_if_index)
self.assertEqual(rv.retval, 0)
- before = self.statistics.get_counter('/mem/statseg/used')
+ before = self.statistics.get_counter("/mem/statseg/used")
loop()
self.vapi.cli("memory-trace on stats-segment")
for j in range(100):
loop()
print(self.vapi.cli("show memory stats-segment verbose"))
- print('AFTER', before,
- self.statistics.get_counter('/mem/statseg/used'))
+ print("AFTER", before, self.statistics.get_counter("/mem/statseg/used"))
-if __name__ == '__main__':
+if __name__ == "__main__":
unittest.main(testRunner=VppTestRunner)