summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli/test_protocols_static.py
diff options
context:
space:
mode:
authorNicolas Vandamme <n.vandamme@firis-system.lu>2025-09-01 17:24:26 +0200
committerGitHub <noreply@github.com>2025-09-01 17:24:26 +0200
commita791cc3b7bb28081a6e79a988964f1fc51a47dae (patch)
treeef5e734bf580f1abfd7d3d4ea30240d8d9fb1278 /smoketest/scripts/cli/test_protocols_static.py
parentb9f60711392463af1892a30472fba6622a73390a (diff)
parentb1b4545cb7984cd3cdf42554ab2b28acd1ecb6cb (diff)
downloadvyos-1x-a791cc3b7bb28081a6e79a988964f1fc51a47dae.tar.gz
vyos-1x-a791cc3b7bb28081a6e79a988964f1fc51a47dae.zip
Merge branch 'vyos:current' into current
Diffstat (limited to 'smoketest/scripts/cli/test_protocols_static.py')
-rwxr-xr-xsmoketest/scripts/cli/test_protocols_static.py36
1 files changed, 34 insertions, 2 deletions
diff --git a/smoketest/scripts/cli/test_protocols_static.py b/smoketest/scripts/cli/test_protocols_static.py
index 79d6b3af4..7b482b78c 100755
--- a/smoketest/scripts/cli/test_protocols_static.py
+++ b/smoketest/scripts/cli/test_protocols_static.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2021-2025 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -581,7 +581,7 @@ class TestProtocolsStatic(VyOSUnitTestSHIM.TestCase):
self.assertIn(tmp, frrconfig)
def test_05_dhcp_default_route(self):
- # When running via vyos-build under the QEmu environment a local DHCP
+ # When running via vyos-build under the QEMU environment a local DHCP
# server is available. This test verifies that the default route is set.
# When not running under the VyOS QEMU environment, this test is skipped.
if not os.path.exists('/tmp/vyos.smoketests.hint'):
@@ -619,5 +619,37 @@ class TestProtocolsStatic(VyOSUnitTestSHIM.TestCase):
while process_named_running('dhclient', cmdline=interface, timeout=10):
sleep(0.250)
+ def test_06_dhcp_default_route_for_vrf(self):
+ # When running via vyos-build under the QEMU environment a local DHCP
+ # server is available. This test verifies that the default route is set.
+ # When not running under the VyOS QEMU environment, this test is skipped.
+ if not os.path.exists('/tmp/vyos.smoketests.hint'):
+ self.skipTest('Not running under VyOS CI/CD QEMU environment!')
+
+ interface = 'eth0'
+ vrf = 'red'
+ vrf_path = ['vrf', 'name', vrf]
+ interface_path = ['interfaces', 'ethernet', interface]
+ self.cli_set(vrf_path + ['table', '1000'])
+ default_distance = default_value(interface_path + ['dhcp-options', 'default-route-distance'])
+ self.cli_set(interface_path + ['address', 'dhcp'])
+ self.cli_set(interface_path + ['vrf', vrf])
+ self.cli_commit()
+
+ # Wait for dhclient to receive IP address and default gateway
+ sleep(5)
+
+ router = get_dhcp_router(interface)
+ frrconfig = self.getFRRconfig(f'vrf {vrf}', endsection='^exit-vrf')
+ self.assertIn(rf'ip route 0.0.0.0/0 {router} {interface} tag 210 {default_distance}', frrconfig)
+
+ self.cli_delete(interface_path + ['address'])
+ self.cli_delete(interface_path + ['vrf'])
+ self.cli_commit()
+
+ # Wait for dhclient to stop
+ while process_named_running('dhclient', cmdline=interface, timeout=10):
+ sleep(0.250)
+
if __name__ == '__main__':
unittest.main(verbosity=2)