summaryrefslogtreecommitdiffstats
path: root/test/test_l2_flood.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_l2_flood.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_l2_flood.py')
-rw-r--r--test/test_l2_flood.py174
1 files changed, 103 insertions, 71 deletions
diff --git a/test/test_l2_flood.py b/test/test_l2_flood.py
index 7f3c57a399d..db4af607451 100644
--- a/test/test_l2_flood.py
+++ b/test/test_l2_flood.py
@@ -15,7 +15,7 @@ NUM_PKTS = 67
class TestL2Flood(VppTestCase):
- """ L2-flood """
+ """L2-flood"""
@classmethod
def setUpClass(cls):
@@ -52,7 +52,7 @@ class TestL2Flood(VppTestCase):
super(TestL2Flood, self).tearDown()
def test_flood(self):
- """ L2 Flood Tests """
+ """L2 Flood Tests"""
#
# Create a single bridge Domain
@@ -63,31 +63,35 @@ class TestL2Flood(VppTestCase):
# add each interface to the BD. 3 interfaces per split horizon group
#
for i in self.pg_interfaces[0:4]:
- self.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=i.sw_if_index,
- bd_id=1, shg=0)
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=i.sw_if_index, bd_id=1, shg=0
+ )
for i in self.pg_interfaces[4:8]:
- self.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=i.sw_if_index,
- bd_id=1, shg=1)
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=i.sw_if_index, bd_id=1, shg=1
+ )
for i in self.pg_interfaces[8:12]:
- self.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=i.sw_if_index,
- bd_id=1, shg=2)
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=i.sw_if_index, bd_id=1, shg=2
+ )
for i in self.bvi_interfaces:
- self.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=i.sw_if_index,
- bd_id=1, shg=2,
- port_type=L2_PORT_TYPE.BVI)
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=i.sw_if_index, bd_id=1, shg=2, port_type=L2_PORT_TYPE.BVI
+ )
- p = (Ether(dst="ff:ff:ff:ff:ff:ff",
- src="00:00:de:ad:be:ef") /
- IP(src="10.10.10.10", dst="1.1.1.1") /
- UDP(sport=1234, dport=1234) /
- Raw(b'\xa5' * 100))
+ p = (
+ Ether(dst="ff:ff:ff:ff:ff:ff", src="00:00:de:ad:be:ef")
+ / IP(src="10.10.10.10", dst="1.1.1.1")
+ / UDP(sport=1234, dport=1234)
+ / Raw(b"\xa5" * 100)
+ )
#
# input on pg0 expect copies on pg1->11
# this is in SHG=0 so its flooded to all, expect the pg0 since that's
# the ingress link
#
- self.pg0.add_stream(p*NUM_PKTS)
+ self.pg0.add_stream(p * NUM_PKTS)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
@@ -98,7 +102,7 @@ class TestL2Flood(VppTestCase):
# input on pg4 (SHG=1) expect copies on pg0->3 (SHG=0)
# and pg8->11 (SHG=2)
#
- self.pg4.add_stream(p*NUM_PKTS)
+ self.pg4.add_stream(p * NUM_PKTS)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
@@ -112,9 +116,12 @@ class TestL2Flood(VppTestCase):
#
# An IP route so the packet that hits the BVI is sent out of pg12
#
- ip_route = VppIpRoute(self, "1.1.1.1", 32,
- [VppRoutePath(self.pg12.remote_ip4,
- self.pg12.sw_if_index)])
+ ip_route = VppIpRoute(
+ self,
+ "1.1.1.1",
+ 32,
+ [VppRoutePath(self.pg12.remote_ip4, self.pg12.sw_if_index)],
+ )
ip_route.add_vpp_config()
self.logger.info(self.vapi.cli("sh bridge 1 detail"))
@@ -124,7 +131,7 @@ class TestL2Flood(VppTestCase):
# this is in SHG=0 so its flooded to all, expect the pg0 since that's
# the ingress link
#
- self.pg0.add_stream(p*NUM_PKTS)
+ self.pg0.add_stream(p * NUM_PKTS)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
@@ -135,7 +142,7 @@ class TestL2Flood(VppTestCase):
# input on pg4 (SHG=1) expect copies on pg0->3 (SHG=0)
# and pg8->12 (SHG=2)
#
- self.pg4.add_stream(p*NUM_PKTS)
+ self.pg4.add_stream(p * NUM_PKTS)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
@@ -150,18 +157,22 @@ class TestL2Flood(VppTestCase):
# cleanup
#
for i in self.pg_interfaces[:12]:
- self.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=i.sw_if_index,
- bd_id=1, enable=0)
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=i.sw_if_index, bd_id=1, enable=0
+ )
for i in self.bvi_interfaces:
- self.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=i.sw_if_index,
- bd_id=1, shg=2,
- port_type=L2_PORT_TYPE.BVI,
- enable=0)
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=i.sw_if_index,
+ bd_id=1,
+ shg=2,
+ port_type=L2_PORT_TYPE.BVI,
+ enable=0,
+ )
self.vapi.bridge_domain_add_del(bd_id=1, is_add=0)
def test_flood_one(self):
- """ L2 no-Flood Test """
+ """L2 no-Flood Test"""
#
# Create a single bridge Domain
@@ -173,30 +184,33 @@ class TestL2Flood(VppTestCase):
# one member
#
for i in self.pg_interfaces[:2]:
- self.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=i.sw_if_index,
- bd_id=1, shg=0)
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=i.sw_if_index, bd_id=1, shg=0
+ )
- p = (Ether(dst="ff:ff:ff:ff:ff:ff",
- src="00:00:de:ad:be:ef") /
- IP(src="10.10.10.10", dst="1.1.1.1") /
- UDP(sport=1234, dport=1234) /
- Raw(b'\xa5' * 100))
+ p = (
+ Ether(dst="ff:ff:ff:ff:ff:ff", src="00:00:de:ad:be:ef")
+ / IP(src="10.10.10.10", dst="1.1.1.1")
+ / UDP(sport=1234, dport=1234)
+ / Raw(b"\xa5" * 100)
+ )
#
# input on pg0 expect copies on pg1
#
- self.send_and_expect(self.pg0, p*NUM_PKTS, self.pg1)
+ self.send_and_expect(self.pg0, p * NUM_PKTS, self.pg1)
#
# cleanup
#
for i in self.pg_interfaces[:2]:
- self.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=i.sw_if_index,
- bd_id=1, enable=0)
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=i.sw_if_index, bd_id=1, enable=0
+ )
self.vapi.bridge_domain_add_del(bd_id=1, is_add=0)
def test_uu_fwd(self):
- """ UU Flood """
+ """UU Flood"""
#
# Create a single bridge Domain
@@ -207,34 +221,37 @@ class TestL2Flood(VppTestCase):
# add each interface to the BD. 3 interfaces per split horizon group
#
for i in self.pg_interfaces[0:4]:
- self.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=i.sw_if_index,
- bd_id=1, shg=0)
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=i.sw_if_index, bd_id=1, shg=0
+ )
#
# an unknown unicast and broadcast packets
#
- p_uu = (Ether(dst="00:00:00:c1:5c:00",
- src="00:00:de:ad:be:ef") /
- IP(src="10.10.10.10", dst="1.1.1.1") /
- UDP(sport=1234, dport=1234) /
- Raw(b'\xa5' * 100))
- p_bm = (Ether(dst="ff:ff:ff:ff:ff:ff",
- src="00:00:de:ad:be:ef") /
- IP(src="10.10.10.10", dst="1.1.1.1") /
- UDP(sport=1234, dport=1234) /
- Raw(b'\xa5' * 100))
+ p_uu = (
+ Ether(dst="00:00:00:c1:5c:00", src="00:00:de:ad:be:ef")
+ / IP(src="10.10.10.10", dst="1.1.1.1")
+ / UDP(sport=1234, dport=1234)
+ / Raw(b"\xa5" * 100)
+ )
+ p_bm = (
+ Ether(dst="ff:ff:ff:ff:ff:ff", src="00:00:de:ad:be:ef")
+ / IP(src="10.10.10.10", dst="1.1.1.1")
+ / UDP(sport=1234, dport=1234)
+ / Raw(b"\xa5" * 100)
+ )
#
# input on pg0, expected copies on pg1->4
#
- self.pg0.add_stream(p_uu*NUM_PKTS)
+ self.pg0.add_stream(p_uu * NUM_PKTS)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
for i in self.pg_interfaces[1:4]:
rx0 = i.get_capture(NUM_PKTS, timeout=1)
- self.pg0.add_stream(p_bm*NUM_PKTS)
+ self.pg0.add_stream(p_bm * NUM_PKTS)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
@@ -245,13 +262,16 @@ class TestL2Flood(VppTestCase):
# use pg8 as the uu-fwd interface
#
self.vapi.sw_interface_set_l2_bridge(
- rx_sw_if_index=self.pg8.sw_if_index, bd_id=1, shg=0,
- port_type=L2_PORT_TYPE.UU_FWD)
+ rx_sw_if_index=self.pg8.sw_if_index,
+ bd_id=1,
+ shg=0,
+ port_type=L2_PORT_TYPE.UU_FWD,
+ )
#
# expect the UU packet on the uu-fwd interface and not be flooded
#
- self.pg0.add_stream(p_uu*NUM_PKTS)
+ self.pg0.add_stream(p_uu * NUM_PKTS)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
@@ -260,7 +280,7 @@ class TestL2Flood(VppTestCase):
for i in self.pg_interfaces[0:4]:
i.assert_nothing_captured(remark="UU not flooded")
- self.pg0.add_stream(p_bm*NUM_PKTS)
+ self.pg0.add_stream(p_bm * NUM_PKTS)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
@@ -271,10 +291,14 @@ class TestL2Flood(VppTestCase):
# remove the uu-fwd interface and expect UU to be flooded again
#
self.vapi.sw_interface_set_l2_bridge(
- rx_sw_if_index=self.pg8.sw_if_index, bd_id=1, shg=0,
- port_type=L2_PORT_TYPE.UU_FWD, enable=0)
-
- self.pg0.add_stream(p_uu*NUM_PKTS)
+ rx_sw_if_index=self.pg8.sw_if_index,
+ bd_id=1,
+ shg=0,
+ port_type=L2_PORT_TYPE.UU_FWD,
+ enable=0,
+ )
+
+ self.pg0.add_stream(p_uu * NUM_PKTS)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
@@ -292,11 +316,14 @@ class TestL2Flood(VppTestCase):
# re-add the uu-fwd interface
#
self.vapi.sw_interface_set_l2_bridge(
- rx_sw_if_index=self.pg8.sw_if_index, bd_id=1, shg=0,
- port_type=L2_PORT_TYPE.UU_FWD)
+ rx_sw_if_index=self.pg8.sw_if_index,
+ bd_id=1,
+ shg=0,
+ port_type=L2_PORT_TYPE.UU_FWD,
+ )
self.logger.info(self.vapi.cli("sh bridge 1 detail"))
- self.pg0.add_stream(p_uu*NUM_PKTS)
+ self.pg0.add_stream(p_uu * NUM_PKTS)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
@@ -309,19 +336,24 @@ class TestL2Flood(VppTestCase):
# remove the uu-fwd interface
#
self.vapi.sw_interface_set_l2_bridge(
- rx_sw_if_index=self.pg8.sw_if_index, bd_id=1, shg=0,
- port_type=L2_PORT_TYPE.UU_FWD, enable=0)
+ rx_sw_if_index=self.pg8.sw_if_index,
+ bd_id=1,
+ shg=0,
+ port_type=L2_PORT_TYPE.UU_FWD,
+ enable=0,
+ )
self.send_and_assert_no_replies(self.pg0, p_uu)
#
# cleanup
#
for i in self.pg_interfaces[:4]:
- self.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=i.sw_if_index,
- bd_id=1, enable=0)
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=i.sw_if_index, bd_id=1, enable=0
+ )
self.vapi.bridge_domain_add_del(bd_id=1, is_add=0)
-if __name__ == '__main__':
+if __name__ == "__main__":
unittest.main(testRunner=VppTestRunner)