summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_snat.py22
-rw-r--r--test/vpp_papi_provider.py7
2 files changed, 28 insertions, 1 deletions
diff --git a/test/test_snat.py b/test/test_snat.py
index 78919a026ed..7084f00208f 100644
--- a/test/test_snat.py
+++ b/test/test_snat.py
@@ -1322,11 +1322,31 @@ class TestDeterministicNAT(VppTestCase):
rep2 = self.vapi.snat_det_reverse(out_addr_n, rep1.out_port_hi)
self.assertEqual(rep2.in_addr[:4], in_addr_t_n)
+ deterministic_mappings = self.vapi.snat_det_map_dump()
+ self.assertEqual(len(deterministic_mappings), 1)
+ dsm = deterministic_mappings[0]
+ self.assertEqual(in_addr_n, dsm.in_addr[:4])
+ self.assertEqual(in_plen, dsm.in_plen)
+ self.assertEqual(out_addr_n, dsm.out_addr[:4])
+ self.assertEqual(out_plen, dsm.out_plen)
+
+ def clear_snat(self):
+ """
+ Clear SNAT configuration.
+ """
+ deterministic_mappings = self.vapi.snat_det_map_dump()
+ for dsm in deterministic_mappings:
+ self.vapi.snat_add_det_map(dsm.in_addr,
+ dsm.in_plen,
+ dsm.out_addr,
+ dsm.out_plen,
+ is_add=0)
+
def tearDown(self):
super(TestDeterministicNAT, self).tearDown()
if not self.vpp_dead:
self.logger.info(self.vapi.cli("show snat detail"))
-
+ self.clear_snat()
if __name__ == '__main__':
unittest.main(testRunner=VppTestRunner)
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index 3d6af8afd55..0062b72b62e 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -1179,6 +1179,13 @@ class VppPapiProvider(object):
{'out_addr': out_addr,
'out_port': out_port})
+ def snat_det_map_dump(self):
+ """Dump S-NAT deterministic mappings
+
+ :return: Dictionary of S-NAT deterministic mappings
+ """
+ return self.api(self.papi.snat_det_map_dump, {})
+
def control_ping(self):
self.api(self.papi.control_ping)