summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli
diff options
context:
space:
mode:
authorNobi <nobi@nobidev.com>2025-07-09 08:21:52 +0700
committerNobi <nobi@nobidev.com>2025-07-13 01:04:09 +0700
commitfcb2975de5f21923002ae1e7d428862ae78dc6d1 (patch)
tree3b7eb9a7e4790b4c08dcce7c073ea7daaa4372d6 /smoketest/scripts/cli
parent1e768a5393e523867730e6b1f660e9a15f0d5fa0 (diff)
downloadvyos-1x-fcb2975de5f21923002ae1e7d428862ae78dc6d1.tar.gz
vyos-1x-fcb2975de5f21923002ae1e7d428862ae78dc6d1.zip
T7623: smoketest: Add test dhcp default route for VRF
Diffstat (limited to 'smoketest/scripts/cli')
-rwxr-xr-xsmoketest/scripts/cli/test_protocols_static.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_protocols_static.py b/smoketest/scripts/cli/test_protocols_static.py
index 66fb880c5..be9ce2d05 100755
--- a/smoketest/scripts/cli/test_protocols_static.py
+++ b/smoketest/scripts/cli/test_protocols_static.py
@@ -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)