summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2025-11-04 17:53:11 +0200
committerGitHub <noreply@github.com>2025-11-04 17:53:11 +0200
commitcc60275ab0db2c45f2ad7387d6a91a96fa9d6337 (patch)
treea59baa904529193481c12fb112a2de29b9d08608 /smoketest/scripts/cli
parent6d0324506a5b0419eb0ae001d8d006a414030405 (diff)
parentae6d3437dc3247c396444b7f65eb49a98b0dd800 (diff)
downloadvyos-1x-cc60275ab0db2c45f2ad7387d6a91a96fa9d6337.tar.gz
vyos-1x-cc60275ab0db2c45f2ad7387d6a91a96fa9d6337.zip
Merge pull request #4828 from c-po/restart-container-vrf
container: T7305: fix VRF loss when restarting pods
Diffstat (limited to 'smoketest/scripts/cli')
-rwxr-xr-xsmoketest/scripts/cli/test_container.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/smoketest/scripts/cli/test_container.py b/smoketest/scripts/cli/test_container.py
index b41a7dd53..ae85273e8 100755
--- a/smoketest/scripts/cli/test_container.py
+++ b/smoketest/scripts/cli/test_container.py
@@ -23,6 +23,7 @@ from base_vyostest_shim import VyOSUnitTestSHIM
from ipaddress import ip_interface
from vyos.configsession import ConfigSessionError
+from vyos.utils.network import get_interface_vrf
from vyos.utils.process import cmd
from vyos.utils.process import process_named_running
@@ -51,6 +52,7 @@ class TestContainer(VyOSUnitTestSHIM.TestCase):
# ensure we can also run this test on a live system - so lets clean
# out the current configuration :)
cls.cli_delete(cls, base_path)
+ cls.cli_delete(cls, ['vrf'])
@classmethod
def tearDownClass(cls):
@@ -133,7 +135,6 @@ class TestContainer(VyOSUnitTestSHIM.TestCase):
self.assertEqual(l['Config']['Healthcheck']['Timeout'], 1000000000)
self.assertEqual(l['Config']['Healthcheck']['Retries'], 2)
-
def test_name_server(self):
cont_name = 'dns-test'
net_name = 'net-test'
@@ -517,6 +518,30 @@ class TestContainer(VyOSUnitTestSHIM.TestCase):
# We expect the same amount of containers from the API that we started above
self.assertEqual(len(container_list), len(tmp))
+ def test_network_vrf(self):
+ cont_name = 'vrf-test50'
+ net_name = 'vrf-test50'
+ vrf_name = 'red-15'
+
+ # create temporary VRF for testing
+ self.cli_set(['vrf', 'name', vrf_name, 'table', '100'])
+
+ self.cli_set(base_path + ['name', cont_name, 'image', busybox_image])
+ self.cli_set(base_path + ['name', cont_name, 'network', net_name])
+ self.cli_set(base_path + ['network', net_name, 'prefix', '192.168.0.0/24'])
+ self.cli_set(base_path + ['network', net_name, 'vrf', vrf_name])
+
+ self.cli_commit()
+
+ tmp = get_interface_vrf(f'pod-{net_name}')
+ self.assertEqual(tmp, vrf_name)
+
+ # Restart container and validate VRF assignment
+ self.op_mode(['restart', 'container', cont_name])
+ tmp = get_interface_vrf(f'pod-{net_name}')
+ self.assertEqual(tmp, vrf_name)
+
+ self.cli_delete(['vrf', 'name', vrf_name])
if __name__ == '__main__':
unittest.main(verbosity=2, failfast=VyOSUnitTestSHIM.TestCase.debug_on())