diff options
author | adrianvillin <avillin@cisco.com> | 2023-10-23 18:54:29 +0200 |
---|---|---|
committer | Dave Wallace <dwallacelf@gmail.com> | 2023-10-25 02:15:54 +0000 |
commit | 52aaa9b0ac20d7dca1b342c1dec3a9726ff45f4c (patch) | |
tree | 717fbdcf6c99983b9e7be5a5e995f7d831f01c5b /test/test_stn.py | |
parent | 4450aed056d0f096944d81c230bc33d9bd8497e3 (diff) |
tests: Added STN plugin test to improve coverage.
Type: test
Change-Id: I30dfaed684e1f808089bb8eb301486434425ccd7
Signed-off-by: adrianvillin <avillin@cisco.com>
Diffstat (limited to 'test/test_stn.py')
-rw-r--r-- | test/test_stn.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/test/test_stn.py b/test/test_stn.py new file mode 100644 index 00000000000..d6c8284f829 --- /dev/null +++ b/test/test_stn.py @@ -0,0 +1,63 @@ +from framework import VppTestCase, VppTestRunner +import unittest +from config import config + + +@unittest.skipIf("stn" in config.excluded_plugins, "Exclude stn plugin tests") +class TestStn(VppTestCase): + """STN plugin tests""" + + # TODO: actually test the rules by sending packets + @classmethod + def setUpClass(cls): + super(TestStn, cls).setUpClass() + try: + cls.create_pg_interfaces(range(2)) + for i in cls.pg_interfaces: + i.config_ip4() + i.resolve_arp() + i.admin_up() + except Exception: + cls.tearDownClass() + raise + + @classmethod + def tearDownClass(cls): + for i in cls.pg_interfaces: + i.unconfig_ip4() + i.admin_down() + super(TestStn, cls).tearDownClass() + + def test_stn_cli(self): + """Add, dump and delete stn rule [CLI]""" + expected = [ + "rule_index: 0", + f"address: {self.pg0.local_ip4}", + "iface: pg0", + "next_node: pg0-output", + ] + self.vapi.cli(f"stn rule address {self.pg0.local_ip4} interface pg0") + + reply = self.vapi.cli("show stn rules") + for entry in expected: + self.assertIn(entry, reply) + + self.vapi.cli(f"stn rule address {self.pg0.local_ip4} interface pg0 del") + + def test_stn_vapi(self): + """Add, dump and delete stn rule [VAPI]""" + self.vapi.stn_add_del_rule( + ip_address=self.pg1.local_ip4, + sw_if_index=1, + is_add=1, + ) + self.vapi.stn_rules_dump() + self.vapi.stn_add_del_rule( + ip_address=self.pg1.local_ip4, + sw_if_index=1, + is_add=0, + ) + + +if __name__ == "__main__": + unittest.main(testRunner=VppTestRunner) |