aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMartin <magalik@cisco.com>2017-03-08 05:53:20 -0800
committerFlorin Coras <florin.coras@gmail.com>2017-03-08 23:43:44 +0000
commit17a75cb2728900a51f9fa2531ea0142d829ea664 (patch)
tree4254adeba362aaff8f9ad1b5a523b8d0b3bdb4af /test
parent2ef5d014d6beb45aa5ca4557e1fac6c1b5abfeeb (diff)
SNAT: deterministic map dump
Change-Id: Iead6dc6a0fe15a0b8e148e780c3aeadd0b378824 Signed-off-by: Martin <magalik@cisco.com>
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)