aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBrian Russell <brian@graphiant.com>2021-01-19 16:56:32 +0000
committerNeale Ranns <neale@graphiant.com>2021-01-28 10:27:32 +0000
commit318fdb8a83101153dcebdc7cdf705a6df81aa5d7 (patch)
tree90f7d24a67034c06c66d0975f53e9140d63191ee /test
parent1b2e16ac7703681a66edd589fd1f6be26b9f1661 (diff)
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 <brian@graphiant.com> Change-Id: I1a976e8fc0e8a44a86fe923a3ae093fe0c9057a8
Diffstat (limited to 'test')
-rw-r--r--test/test_ip4.py57
1 files changed, 29 insertions, 28 deletions
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.