From 13189cd9e82f4c4cf8ce90bfdef327a59e2e5716 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Sat, 19 Sep 2026 07:42:32 +0200 Subject: smoketest: T9316: match VRF process names by prefix, not equality test_08_dyndns_vrf started failing after the conversion to get_vrf_pids(): AssertionError: 'ddclient' not found in ['ddclient - slee'] "ip vrf pids" prints the kernel comm, which is capped at 15 characters and follows a process rewriting its own title - ddclient advertises its poll state as "ddclient - sleeping for 300 seconds". Comparing the name column for equality is therefore too strict. Add verify_process_in_vrf() to the test shim, matching the name column by prefix and reporting the VRF's process list on failure, and use it for all the name based probes. Matching stays confined to the name column, so a process name still cannot be satisfied by the PID column. The PID based checks in base_interfaces_test.py are unaffected - they compare integers, which a process title does not change. --- smoketest/scripts/cli/base_vyostest_shim.py | 12 ++++++++++++ smoketest/scripts/cli/test_service_dns_dynamic.py | 4 +--- smoketest/scripts/cli/test_service_https.py | 4 +--- smoketest/scripts/cli/test_service_ntp.py | 4 +--- smoketest/scripts/cli/test_service_ssh.py | 7 ++----- smoketest/scripts/cli/test_service_tftp-server.py | 4 +--- smoketest/scripts/cli/test_system_sflow.py | 4 +--- 7 files changed, 19 insertions(+), 20 deletions(-) (limited to 'smoketest/scripts/cli') diff --git a/smoketest/scripts/cli/base_vyostest_shim.py b/smoketest/scripts/cli/base_vyostest_shim.py index 0fc146b0a..dfc1e6a14 100644 --- a/smoketest/scripts/cli/base_vyostest_shim.py +++ b/smoketest/scripts/cli/base_vyostest_shim.py @@ -27,6 +27,7 @@ from vyos.configsession import ConfigSession from vyos.configsession import ConfigSessionError from vyos.frrender import mgmt_daemon from vyos.utils.commit import commit_in_progress2 +from vyos.utils.network import get_vrf_pids from vyos.utils.process import cmdl from vyos.utils.process import process_named_running @@ -442,6 +443,17 @@ class VyOSUnitTestSHIM: break self.assertTrue(not matched if inverse else matched, msg=search) + def verify_process_in_vrf(self, process_name, vrf): + """ Verify that a process of a given name runs inside a VRF + + "ip vrf pids" reports the kernel comm, which is capped at 15 + characters and follows a process rewriting its title - ddclient + shows up as "ddclient - slee" - so match by prefix, not equality. + """ + names = [name for _, name in get_vrf_pids(vrf)] + self.assertTrue(any(name.startswith(process_name) for name in names), + f'no {process_name} process running in VRF {vrf}: {names}') + @staticmethod def wait_for_result(runnable, check, pause=1, timeout=10): """ diff --git a/smoketest/scripts/cli/test_service_dns_dynamic.py b/smoketest/scripts/cli/test_service_dns_dynamic.py index 0afb22d52..dc19a84ed 100755 --- a/smoketest/scripts/cli/test_service_dns_dynamic.py +++ b/smoketest/scripts/cli/test_service_dns_dynamic.py @@ -23,7 +23,6 @@ from vyos.configsession import ConfigSessionError from vyos.utils.file import read_file from vyos.utils.process import cmdl from vyos.utils.process import process_named_running -from vyos.utils.network import get_vrf_pids from vyos.xml_ref import default_value DDCLIENT_SYSTEMD_UNIT = '/run/systemd/system/ddclient.service.d/override.conf' @@ -372,8 +371,7 @@ class TestServiceDDNS(VyOSUnitTestSHIM.TestCase): ) # Check for process in VRF - vrf_procs = [name for _, name in get_vrf_pids(vrf_name)] - self.assertIn(DDCLIENT_PNAME, vrf_procs) + self.verify_process_in_vrf(DDCLIENT_PNAME, vrf_name) # Cleanup VRF self.cli_delete(['vrf', 'name', vrf_name]) diff --git a/smoketest/scripts/cli/test_service_https.py b/smoketest/scripts/cli/test_service_https.py index 93a4dff3d..e7a2ba60a 100755 --- a/smoketest/scripts/cli/test_service_https.py +++ b/smoketest/scripts/cli/test_service_https.py @@ -29,7 +29,6 @@ from vyos.utils.file import read_file from vyos.utils.file import write_file from vyos.utils.process import call from vyos.utils.process import process_named_running -from vyos.utils.network import get_vrf_pids from vyos.pki import CERT_BEGIN from vyos.pki import encode_certificate from vyos.pki import load_certificate @@ -248,8 +247,7 @@ class TestHTTPSService(VyOSUnitTestSHIM.TestCase): self.cli_commit() # Verify nginx is running inside the VRF - vrf_procs = [name for _, name in get_vrf_pids(vrf)] - self.assertIn(PROCESS_NAME, vrf_procs) + self.verify_process_in_vrf(PROCESS_NAME, vrf) self.cli_delete(['interfaces', 'dummy', interface]) self.cli_delete(['vrf', 'name', vrf]) diff --git a/smoketest/scripts/cli/test_service_ntp.py b/smoketest/scripts/cli/test_service_ntp.py index b0109ab51..fc5359b1c 100755 --- a/smoketest/scripts/cli/test_service_ntp.py +++ b/smoketest/scripts/cli/test_service_ntp.py @@ -21,7 +21,6 @@ from base_vyostest_shim import VyOSUnitTestSHIM from vyos.configsession import ConfigSessionError from vyos.utils.file import read_file from vyos.utils.process import process_named_running -from vyos.utils.network import get_vrf_pids from vyos.xml_ref import default_value PROCESS_NAME = 'chronyd' @@ -278,8 +277,7 @@ class TestSystemNTP(VyOSUnitTestSHIM.TestCase): self.cli_commit() # Check for process in VRF - vrf_procs = [name for _, name in get_vrf_pids(vrf_name)] - self.assertIn(PROCESS_NAME, vrf_procs) + self.verify_process_in_vrf(PROCESS_NAME, vrf_name) self.cli_delete(['vrf', 'name', vrf_name]) diff --git a/smoketest/scripts/cli/test_service_ssh.py b/smoketest/scripts/cli/test_service_ssh.py index 120afb12a..dad7bbe2c 100755 --- a/smoketest/scripts/cli/test_service_ssh.py +++ b/smoketest/scripts/cli/test_service_ssh.py @@ -29,7 +29,6 @@ from vyos.utils.process import is_systemd_service_running from vyos.utils.process import process_named_running from vyos.utils.file import read_file from vyos.utils.file import write_file -from vyos.utils.network import get_vrf_pids from vyos.xml_ref import default_value PROCESS_NAME = 'sshd' @@ -254,8 +253,7 @@ class TestServiceSSH(VyOSUnitTestSHIM.TestCase): self.cli_commit() # Check for process in VRF - vrf_procs = [name for _, name in get_vrf_pids(vrf)] - self.assertIn(PROCESS_NAME, vrf_procs) + self.verify_process_in_vrf(PROCESS_NAME, vrf) def test_ssh_vrf_multi(self): # Check if SSH service can be bound to multiple VRFs @@ -277,8 +275,7 @@ class TestServiceSSH(VyOSUnitTestSHIM.TestCase): # Check for process in VRF for vrf in vrfs: - vrf_procs = [name for _, name in get_vrf_pids(vrf)] - self.assertIn(PROCESS_NAME, vrf_procs) + self.verify_process_in_vrf(PROCESS_NAME, vrf) def test_ssh_login(self): # Perform SSH login and command execution with a predefined user. The diff --git a/smoketest/scripts/cli/test_service_tftp-server.py b/smoketest/scripts/cli/test_service_tftp-server.py index 2c04f2122..aa44274fc 100755 --- a/smoketest/scripts/cli/test_service_tftp-server.py +++ b/smoketest/scripts/cli/test_service_tftp-server.py @@ -22,7 +22,6 @@ from base_vyostest_shim import VyOSUnitTestSHIM from vyos.configsession import ConfigSessionError from vyos.utils.file import read_file from vyos.utils.process import process_named_running -from vyos.utils.network import get_vrf_pids from vyos.template import is_ipv6 PROCESS_NAME = 'in.tftpd' @@ -140,8 +139,7 @@ class TestServiceTFTPD(VyOSUnitTestSHIM.TestCase): self.assertIn('--create --umask 000', config) # Check for process in VRF - vrf_procs = [name for _, name in get_vrf_pids(vrf)] - self.assertIn(PROCESS_NAME, vrf_procs) + self.verify_process_in_vrf(PROCESS_NAME, vrf) # delete VRF self.cli_delete(dummy_if_path + ['vrf']) diff --git a/smoketest/scripts/cli/test_system_sflow.py b/smoketest/scripts/cli/test_system_sflow.py index 4822fc8dc..30e1175f9 100755 --- a/smoketest/scripts/cli/test_system_sflow.py +++ b/smoketest/scripts/cli/test_system_sflow.py @@ -22,7 +22,6 @@ from vyos.configsession import ConfigSessionError from vyos.ifconfig import Section from vyos.utils.process import process_named_running from vyos.utils.file import read_file -from vyos.utils.network import get_vrf_pids PROCESS_NAME = 'hsflowd' base_path = ['system', 'sflow'] @@ -148,8 +147,7 @@ class TestSystemFlowAccounting(VyOSUnitTestSHIM.TestCase): self.assertIn(f'pcap {{ dev=eth0 }}', hsflowd) # Check for process in VRF - vrf_procs = [name for _, name in get_vrf_pids(vrf)] - self.assertIn(PROCESS_NAME, vrf_procs) + self.verify_process_in_vrf(PROCESS_NAME, vrf) def test_sflow_egress(self): interface = 'eth0' -- cgit v1.2.3