From 54e2c63d65719292ed3255d72d3ac7b7e17062b4 Mon Sep 17 00:00:00 2001 From: Storm Liang Date: Thu, 2 Jul 2026 11:15:01 +1000 Subject: [PATCH 1/2] tests: harden DVS startup failure handling Increase the default DVS service readiness wait to reduce CI flakes under load, keep it configurable via DVS_SERVICE_READY_TIMEOUT, and avoid retaining a destroyed DVS object after failed recreation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Storm Liang --- tests/conftest.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index c422277b7e9..78ccec4a93a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -45,6 +45,7 @@ FABRIC_NUM_PORTS = 16 SINGLE_ASIC_VOQ_FS = "single_asic_voq_fs" +DEFAULT_DVS_SERVICE_READY_TIMEOUT = int(os.environ.get("DVS_SERVICE_READY_TIMEOUT", "180")) def ensure_system(cmd): rc, output = subprocess.getstatusoutput(cmd) @@ -564,7 +565,7 @@ def check_ready_status_and_init_db(self) -> None: self.destroy() raise - def check_services_ready(self, timeout=60) -> None: + def check_services_ready(self, timeout=DEFAULT_DVS_SERVICE_READY_TIMEOUT) -> None: """Check if all processes in the DVS are ready.""" service_polling_config = PollingConfig(1, timeout, strict=True) @@ -1951,6 +1952,7 @@ def update_dvs(log_path, new_dvs_env=[]): if dvs is not None: dvs.get_logs() dvs.destroy() + dvs = None vol = {} if switch_mode and switch_mode == SINGLE_ASIC_VOQ_FS: @@ -1958,7 +1960,8 @@ def update_dvs(log_path, new_dvs_env=[]): voq_configs = cwd + "/single_asic_voq_fs" vol[voq_configs] = {"bind": "/usr/share/sonic/single_asic_voq_fs", "mode": "ro"} - dvs = DockerVirtualSwitch(name, imgname, keeptb, new_dvs_env, log_path, max_cpu, forcedvs, buffer_model = buffer_model, enable_coverage=enable_coverage, ctnmounts=vol, switch_mode=switch_mode) + new_dvs = DockerVirtualSwitch(name, imgname, keeptb, new_dvs_env, log_path, max_cpu, forcedvs, buffer_model = buffer_model, enable_coverage=enable_coverage, ctnmounts=vol, switch_mode=switch_mode) + dvs = new_dvs curr_dvs_env = new_dvs_env @@ -1977,6 +1980,9 @@ def update_dvs(log_path, new_dvs_env=[]): yield update_dvs + if dvs is None: + return + if graceful_stop: dvs.stop_swss() dvs.stop_syncd() From ca0369833ba496560d20adc0e112287a7cf6976c Mon Sep 17 00:00:00 2001 From: Storm Liang Date: Thu, 2 Jul 2026 12:47:30 +1000 Subject: [PATCH 2/2] tests: guard DVS timeout override parsing Fall back to the default DVS service readiness timeout when DVS_SERVICE_READY_TIMEOUT is set to an invalid or empty value, so pytest collection is not broken by malformed environment input. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Storm Liang --- tests/conftest.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 78ccec4a93a..125dbbf8217 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -45,7 +45,14 @@ FABRIC_NUM_PORTS = 16 SINGLE_ASIC_VOQ_FS = "single_asic_voq_fs" -DEFAULT_DVS_SERVICE_READY_TIMEOUT = int(os.environ.get("DVS_SERVICE_READY_TIMEOUT", "180")) + +def get_dvs_service_ready_timeout(): + try: + return int(os.environ.get("DVS_SERVICE_READY_TIMEOUT", "180")) + except ValueError: + return 180 + +DEFAULT_DVS_SERVICE_READY_TIMEOUT = get_dvs_service_ready_timeout() def ensure_system(cmd): rc, output = subprocess.getstatusoutput(cmd)