From: Brian Russell Date: Tue, 19 Jan 2021 16:56:32 +0000 (+0000) Subject: tests: move ip4 punt setup to its own class X-Git-Tag: v21.10-rc0~646 X-Git-Url: https://gerrit.fd.io/r/gitweb?p=vpp.git;a=commitdiff_plain;h=318fdb8a83101153dcebdc7cdf705a6df81aa5d7 tests: move ip4 punt setup to its own class Move interface and packet setup for the ip4 punt test to its own class so that child classes can be created that use it. Type: test Signed-off-by: Brian Russell Change-Id: I1a976e8fc0e8a44a86fe923a3ae093fe0c9057a8 --- diff --git a/test/test_ip4.py b/test/test_ip4.py index 589c668a456..6edb9e852be 100644 --- a/test/test_ip4.py +++ b/test/test_ip4.py @@ -1448,20 +1448,10 @@ class TestIPVlan0(VppTestCase): self.send_and_expect(self.pg0, pkts, self.pg1) -class TestIPPunt(VppTestCase): - """ IPv4 Punt Police/Redirect """ - - @classmethod - def setUpClass(cls): - super(TestIPPunt, cls).setUpClass() - - @classmethod - def tearDownClass(cls): - super(TestIPPunt, cls).tearDownClass() - - def setUp(self): - super(TestIPPunt, self).setUp() +class IPPuntSetup(object): + """ Setup for IPv4 Punt Police/Redirect """ + def punt_setup(self): self.create_pg_interfaces(range(4)) for i in self.pg_interfaces: @@ -1469,15 +1459,6 @@ class TestIPPunt(VppTestCase): i.config_ip4() i.resolve_arp() - def tearDown(self): - super(TestIPPunt, self).tearDown() - for i in self.pg_interfaces: - i.unconfig_ip4() - i.admin_down() - - def test_ip_punt(self): - """ IP punt police and redirect """ - # use UDP packet that have a port we need to explicitly # register to get punted. pt_l4 = VppEnum.vl_api_punt_type_t.PUNT_API_TYPE_L4 @@ -1496,13 +1477,33 @@ class TestIPPunt(VppTestCase): self.vapi.set_punt(is_add=1, punt=punt_udp) - p = (Ether(src=self.pg0.remote_mac, - dst=self.pg0.local_mac) / - IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4) / - UDP(sport=1234, dport=1234) / - Raw(b'\xa5' * 100)) + self.pkt = (Ether(src=self.pg0.remote_mac, + dst=self.pg0.local_mac) / + IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4) / + UDP(sport=1234, dport=1234) / + Raw(b'\xa5' * 100)) + + def punt_teardown(self): + for i in self.pg_interfaces: + i.unconfig_ip4() + i.admin_down() + + +class TestIPPunt(IPPuntSetup, VppTestCase): + """ IPv4 Punt Police/Redirect """ + + def setUp(self): + super(TestIPPunt, self).setUp() + super(TestIPPunt, self).punt_setup() + + def tearDown(self): + super(TestIPPunt, self).punt_teardown() + super(TestIPPunt, self).tearDown() + + def test_ip_punt(self): + """ IP punt police and redirect """ - pkts = p * 1025 + pkts = self.pkt * 1025 # # Configure a punt redirect via pg1.