summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli/test_vrf.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2025-11-07 17:42:23 +0100
committerGitHub <noreply@github.com>2025-11-07 17:42:23 +0100
commit25224cff345210aaecaa4db95a67bd759af666fb (patch)
treecc6e98e48ee4adcad12e32b08ead5d1bb35327be /smoketest/scripts/cli/test_vrf.py
parent71591b72493da9fa55e41e1b7c175ec95d8addf9 (diff)
parentb50808ac8245aa75bdca5b1996847125d1969dc3 (diff)
downloadvyos-1x-25224cff345210aaecaa4db95a67bd759af666fb.tar.gz
vyos-1x-25224cff345210aaecaa4db95a67bd759af666fb.zip
Merge pull request #4836 from c-po/fix-vrf-smoketest
smoketest: T7996: fix hardcoded "vrf red" search path in FRR config
Diffstat (limited to 'smoketest/scripts/cli/test_vrf.py')
-rwxr-xr-xsmoketest/scripts/cli/test_vrf.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/smoketest/scripts/cli/test_vrf.py b/smoketest/scripts/cli/test_vrf.py
index 456295b49..f941867e1 100755
--- a/smoketest/scripts/cli/test_vrf.py
+++ b/smoketest/scripts/cli/test_vrf.py
@@ -20,7 +20,6 @@ import unittest
from json import loads
from jmespath import search
-from time import sleep
from base_vyostest_shim import VyOSUnitTestSHIM
@@ -28,6 +27,7 @@ from vyos.configsession import ConfigSessionError
from vyos.ifconfig import Interface
from vyos.ifconfig import Section
from vyos.utils.file import read_file
+from vyos.utils.misc import wait_for
from vyos.utils.network import get_interface_config
from vyos.utils.network import get_vrf_tableid
from vyos.utils.network import is_intf_addr_assigned
@@ -783,8 +783,7 @@ class VRFTest(VyOSUnitTestSHIM.TestCase):
def test_dhcp_vrf_default_route(self):
# T7927 - when retrieving a default route via DHCP, check that additional
# calls into FRRender() keep the DHCP route in place
-
- vrf_name = 'red15'
+ vrf_name = 'red-16'
default_gateway = '192.0.2.1'
dhcp_if_server = 'veth0'
dhcp_if_client = 'veth1'
@@ -816,25 +815,29 @@ class VRFTest(VyOSUnitTestSHIM.TestCase):
self.cli_set(['interfaces', 'virtual-ethernet', dhcp_if_client, 'address', 'dhcp'])
self.cli_commit()
- # We need to wait until DHCP client has started and an IP address has been received
- sleep(8)
+ # define helper for the string we are looking for in FRR configuration
+ # the leading whitespace is required as this lives under a VRF context!
+ test_ok_string = f' ip route 0.0.0.0/0 {default_gateway} {dhcp_if_client}'\
+ f' tag 210 {default_distance}'
- frrconfig = self.getFRRconfig('^vrf red', stop_section='^exit-vrf')
- self.assertIn(f' ip route 0.0.0.0/0 {default_gateway} {dhcp_if_client} '\
- f'tag 210 {default_distance}', frrconfig)
+ def test_callback(self, vrf_name, string) -> bool:
+ tmp = self.getFRRconfig(f'^vrf {vrf_name}', stop_section='^exit-vrf')
+ return bool(string in tmp)
+
+ # We need to wait until DHCP client has started and an IP address has been received
+ tmp = wait_for(test_callback, self, vrf_name, test_ok_string, timeout=20.0)
+ self.assertTrue(tmp)
# Change anything in FRR to re-trigger config generation. DHCP route
# must still be present
self.cli_set(['protocols', 'static', 'route', '10.0.0.0/24', 'blackhole'])
self.cli_commit()
- frrconfig = self.getFRRconfig('^vrf red', stop_section='^exit-vrf')
- self.assertIn(f' ip route 0.0.0.0/0 {default_gateway} {dhcp_if_client} '\
- f'tag 210 {default_distance}', frrconfig)
+ frrconfig = self.getFRRconfig(f'^vrf {vrf_name}', stop_section='^exit-vrf')
+ self.assertIn(test_ok_string, frrconfig)
self.cli_delete(['interfaces', 'virtual-ethernet'])
self.cli_delete(['service', 'dhcp-server'])
- self.cli_delete(['vrf', 'name', vrf_name])
def test_dhcpv6_single_pool(self):
# Prepare the vrf and other options