summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/nat/test')
-rw-r--r--src/plugins/nat/test/test_nat66.py55
1 files changed, 19 insertions, 36 deletions
diff --git a/src/plugins/nat/test/test_nat66.py b/src/plugins/nat/test/test_nat66.py
index bd1b50b9ee2..acda72bcdf6 100644
--- a/src/plugins/nat/test/test_nat66.py
+++ b/src/plugins/nat/test/test_nat66.py
@@ -32,14 +32,7 @@ from vpp_neighbor import VppNeighbor
from vpp_papi import VppEnum
-class MethodHolder(VppTestCase):
- """ NAT create capture and verify method holder """
- @property
- def config_flags(self):
- return VppEnum.vl_api_nat_config_flags_t
-
-
-class TestNAT66(MethodHolder):
+class TestNAT66(VppTestCase):
""" NAT66 Test Cases """
@classmethod
@@ -47,7 +40,6 @@ class TestNAT66(MethodHolder):
super(TestNAT66, cls).setUpClass()
cls.nat_addr = 'fd01:ff::2'
-
cls.create_pg_interfaces(range(2))
cls.interfaces = list(cls.pg_interfaces)
@@ -56,9 +48,24 @@ class TestNAT66(MethodHolder):
i.config_ip6()
i.configure_ipv6_neighbors()
- @classmethod
- def tearDownClass(cls):
- super(TestNAT66, cls).tearDownClass()
+ @property
+ def config_flags(self):
+ return VppEnum.vl_api_nat_config_flags_t
+
+ def plugin_enable(self):
+ self.vapi.nat66_plugin_enable_disable(enable=1)
+
+ def plugin_disable(self):
+ self.vapi.nat66_plugin_enable_disable(enable=0)
+
+ def setUp(self):
+ super(TestNAT66, self).setUp()
+ self.plugin_enable()
+
+ def tearDown(self):
+ super(TestNAT66, self).tearDown()
+ if not self.vpp_dead:
+ self.plugin_disable()
def test_static(self):
""" 1:1 NAT66 test """
@@ -167,30 +174,6 @@ class TestNAT66(MethodHolder):
self.logger.error(ppp("Unexpected or invalid packet:", packet))
raise
- def clear_nat66(self):
- """
- Clear NAT66 configuration.
- """
- interfaces = self.vapi.nat66_interface_dump()
- for intf in interfaces:
- self.vapi.nat66_add_del_interface(is_add=0, flags=intf.flags,
- sw_if_index=intf.sw_if_index)
-
- static_mappings = self.vapi.nat66_static_mapping_dump()
- for sm in static_mappings:
- self.vapi.nat66_add_del_static_mapping(
- local_ip_address=sm.local_ip_address,
- external_ip_address=sm.external_ip_address, vrf_id=sm.vrf_id,
- is_add=0)
-
- def tearDown(self):
- super(TestNAT66, self).tearDown()
- self.clear_nat66()
-
- def show_commands_at_teardown(self):
- self.logger.info(self.vapi.cli("show nat66 interfaces"))
- self.logger.info(self.vapi.cli("show nat66 static mappings"))
-
if __name__ == '__main__':
unittest.main(testRunner=VppTestRunner)