aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/test/test_nat66.py
diff options
context:
space:
mode:
authorFilip Varga <fivarga@cisco.com>2021-03-23 12:57:58 +0100
committerOle Tr�an <otroan@employees.org>2021-03-31 11:46:05 +0000
commited2ee5e57b0f65ac4a94aac84cb6c27468878ea4 (patch)
tree60ce5bb4f17bf57c12146c20db66cd19fdb233a4 /src/plugins/nat/test/test_nat66.py
parent7554aef84a8a406c9dae73a7445e8b97920a83b3 (diff)
nat: NAT66 plugin enable&disable calls update
Type: improvement Adding support for enable&disable calls (dynamic plugin configuration). API (nat66_plugin_enable_disable) and CLI (nat66 plugin enable/nat66 plugin disable) with support for outside_vrf id configuration. Change-Id: I5637ff1621d6662adc3b7c6f7f8176d84a4b492b Signed-off-by: Filip Varga <fivarga@cisco.com>
Diffstat (limited to 'src/plugins/nat/test/test_nat66.py')
-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)
entheses: false SpacesInCStyleCastParentheses: false SpaceAfterControlStatementKeyword: true Cpp11BracedListStyle: true Standard: Cpp11 SortIncludes: false IndentWidth: 2 TabWidth: 4 UseTab: Never IndentFunctionDeclarationAfterType: false ContinuationIndentWidth: 4 ...