summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli/base_vyostest_shim.py
diff options
context:
space:
mode:
authorsarthurdev <965089+sarthurdev@users.noreply.github.com>2024-02-27 21:29:08 +0100
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2024-02-28 19:36:10 +0000
commite1f34b0c019b9771ace1d6c723d4d84658be5cd8 (patch)
treeb97f26a412c1e4ee7edc0c0e06c48b995a829530 /smoketest/scripts/cli/base_vyostest_shim.py
parentfdfe194634f7a15c2299a3a3bffbe64fe578f466 (diff)
downloadvyos-1x-e1f34b0c019b9771ace1d6c723d4d84658be5cd8.tar.gz
vyos-1x-e1f34b0c019b9771ace1d6c723d4d84658be5cd8.zip
smoketest: T5160: Deduplicate nftables verify functions to testcase class, remove obsolete imports
(cherry picked from commit bc9ccaeda54279022b73a806fa8aa77c523fbecc)
Diffstat (limited to 'smoketest/scripts/cli/base_vyostest_shim.py')
-rw-r--r--smoketest/scripts/cli/base_vyostest_shim.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/base_vyostest_shim.py b/smoketest/scripts/cli/base_vyostest_shim.py
index 140642806..c49d3e76c 100644
--- a/smoketest/scripts/cli/base_vyostest_shim.py
+++ b/smoketest/scripts/cli/base_vyostest_shim.py
@@ -102,6 +102,29 @@ class VyOSUnitTestSHIM:
ssh_client.close()
return output, error
+ # Verify nftables output
+ def verify_nftables(self, nftables_search, table, inverse=False, args=''):
+ nftables_output = cmd(f'sudo nft {args} list table {table}')
+
+ for search in nftables_search:
+ matched = False
+ for line in nftables_output.split("\n"):
+ if all(item in line for item in search):
+ matched = True
+ break
+ self.assertTrue(not matched if inverse else matched, msg=search)
+
+ def verify_nftables_chain(self, nftables_search, table, chain, inverse=False, args=''):
+ nftables_output = cmd(f'sudo nft {args} list chain {table} {chain}')
+
+ for search in nftables_search:
+ matched = False
+ for line in nftables_output.split("\n"):
+ if all(item in line for item in search):
+ matched = True
+ break
+ self.assertTrue(not matched if inverse else matched, msg=search)
+
# standard construction; typing suggestion: https://stackoverflow.com/a/70292317
def ignore_warning(warning: Type[Warning]):
import warnings