Skip to content

Commit 8341c29

Browse files
zhixzhuvidyac86
authored andcommitted
Consolidate voq watchdog testcases to single testcase (sonic-net#19076)
Description of PR Summary: Fixes # (issue) Consolidate voq watchdog test cases into a single test case using parametrize to simplify the code. A requirement from PR comments: Azure/sonic-mgmt.msft#405 Type of change Bug fix Testbed and Framework(new/improvement) New Test case Skipped for non-supported platforms Test case improvement Approach What is the motivation for this PR? How did you do it? How did you verify/test it? Verified on T1 testbed: ------------------------------- generated xml file: /tmp/qos/test_voq_watchdog_2025-06-18-00-56-38.xml -------------------------------- INFO:root:Can not get Allure report URL. Please check logs ------------------------------------------------------- live log sessionfinish -------------------------------------------------------- 01:05:43 __init__.pytest_terminal_summary L0067 INFO | Can not get Allure report URL. Please check logs ======================================================= short test summary info ======================================================= PASSED qos/test_voq_watchdog.py::TestVoqWatchdog::testVoqWatchdog[single_asic-True] PASSED qos/test_voq_watchdog.py::TestVoqWatchdog::testVoqWatchdog[single_asic-False] SKIPPED [2] qos/test_voq_watchdog.py:61: Did not find any frontend node that is multi-asic - so can't run single_dut_multi_asic tests SKIPPED [6] qos/test_voq_watchdog.py:61: multi-dut is not supported on T1 topologies ========================================= 2 passed, 8 skipped, 1 warning in 543.11s (0:09:03) ========================================= sonic@sonic-ucs-m6-26:/data/tests$ T2: ----------------------------- generated xml file: /run_logs/qos/test_voq_watchdog_2025-06-24-03-43-12.xml ----------------------------- INFO:root:Can not get Allure report URL. Please check logs ------------------------------------------------------- live log sessionfinish -------------------------------------------------------- 05:21:22 __init__.pytest_terminal_summary L0067 INFO | Can not get Allure report URL. Please check logs ======================================================= short test summary info ======================================================= PASSED qos/test_voq_watchdog.py::TestVoqWatchdog::testVoqWatchdog[single_asic-True] PASSED qos/test_voq_watchdog.py::TestVoqWatchdog::testVoqWatchdog[single_asic-False] PASSED qos/test_voq_watchdog.py::TestVoqWatchdog::testVoqWatchdog[single_dut_multi_asic-True] PASSED qos/test_voq_watchdog.py::TestVoqWatchdog::testVoqWatchdog[single_dut_multi_asic-False] PASSED qos/test_voq_watchdog.py::TestVoqWatchdog::testVoqWatchdog[multi_dut_longlink_to_shortlink-True] PASSED qos/test_voq_watchdog.py::TestVoqWatchdog::testVoqWatchdog[multi_dut_longlink_to_shortlink-False] PASSED qos/test_voq_watchdog.py::TestVoqWatchdog::testVoqWatchdog[multi_dut_shortlink_to_shortlink-True] PASSED qos/test_voq_watchdog.py::TestVoqWatchdog::testVoqWatchdog[multi_dut_shortlink_to_shortlink-False] PASSED qos/test_voq_watchdog.py::TestVoqWatchdog::testVoqWatchdog[multi_dut_shortlink_to_longlink-True] PASSED qos/test_voq_watchdog.py::TestVoqWatchdog::testVoqWatchdog[multi_dut_shortlink_to_longlink-False] Signed-off-by: Zhixin Zhu <zhixzhu@cisco.com>
1 parent 1ce04f8 commit 8341c29

2 files changed

Lines changed: 46 additions & 83 deletions

File tree

tests/qos/qos_sai_base.py

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,8 +2853,12 @@ def voq_watchdog_enabled(self, get_src_dst_asic_and_duts):
28532853
match = re.search(pattern, result["stdout"])
28542854
return match
28552855

2856-
@contextmanager
2857-
def disable_voq_watchdog(self, duthosts, get_src_dst_asic_and_duts, dutConfig):
2856+
def modify_voq_watchdog(self, duthosts, get_src_dst_asic_and_duts, dutConfig, enable):
2857+
# Skip if voq watchdog is not enabled.
2858+
if not self.voq_watchdog_enabled(get_src_dst_asic_and_duts):
2859+
logger.info("voq_watchdog is not enabled, skipping modify voq watchdog")
2860+
return
2861+
28582862
dst_dut = get_src_dst_asic_and_duts['dst_dut']
28592863
dst_asic = get_src_dst_asic_and_duts['dst_asic']
28602864
dut_list = [dst_dut]
@@ -2871,35 +2875,24 @@ def disable_voq_watchdog(self, duthosts, get_src_dst_asic_and_duts, dutConfig):
28712875
dut_list.append(rp_dut)
28722876
asic_index_list.append(asic.asic_index)
28732877

2874-
# Skip if voq watchdog is not enabled.
2875-
if not self.voq_watchdog_enabled(get_src_dst_asic_and_duts):
2876-
logger.info("voq_watchdog is not enabled, skipping disable voq watchdog")
2877-
yield
2878-
return
2879-
2880-
# Disable voq watchdog.
2878+
# Modify voq watchdog.
28812879
for (dut, asic_index) in zip(dut_list, asic_index_list):
28822880
copy_set_voq_watchdog_script_cisco_8000(
28832881
dut=dut,
28842882
asic=asic_index,
2885-
enable=False)
2883+
enable=enable)
28862884
cmd_opt = "-n asic{}".format(asic_index)
28872885
if not dst_dut.sonichost.is_multi_asic:
28882886
cmd_opt = ""
28892887
dut.shell("sudo show platform npu script {} -s set_voq_watchdog.py".format(cmd_opt))
28902888

2889+
@contextmanager
2890+
def disable_voq_watchdog(self, duthosts, get_src_dst_asic_and_duts, dutConfig):
2891+
# Disable voq watchdog.
2892+
self.modify_voq_watchdog(duthosts, get_src_dst_asic_and_duts, dutConfig, enable=False)
28912893
yield
2892-
28932894
# Enable voq watchdog.
2894-
for (dut, asic_index) in zip(dut_list, asic_index_list):
2895-
copy_set_voq_watchdog_script_cisco_8000(
2896-
dut=dut,
2897-
asic=asic_index,
2898-
enable=True)
2899-
cmd_opt = "-n asic{}".format(asic_index)
2900-
if not dst_dut.sonichost.is_multi_asic:
2901-
cmd_opt = ""
2902-
dut.shell("sudo show platform npu script {} -s set_voq_watchdog.py".format(cmd_opt))
2895+
self.modify_voq_watchdog(duthosts, get_src_dst_asic_and_duts, dutConfig, enable=True)
29032896

29042897
@pytest.fixture(scope='function')
29052898
def disable_voq_watchdog_function_scope(self, duthosts, get_src_dst_asic_and_duts, dutConfig):

tests/qos/test_voq_watchdog.py

Lines changed: 33 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
PKTS_NUM = 100
3838

3939

40-
@pytest.fixture(scope="function")
40+
@pytest.fixture(scope="function", autouse=True)
4141
def ignore_log_voq_watchdog(duthosts, loganalyzer):
4242
if not loganalyzer:
4343
yield
@@ -58,9 +58,10 @@ def check_skip_voq_watchdog_test(self, get_src_dst_asic_and_duts):
5858
if not self.voq_watchdog_enabled(get_src_dst_asic_and_duts):
5959
pytest.skip("Voq watchdog test is skipped since voq watchdog is not enabled.")
6060

61+
@pytest.mark.parametrize("voq_watchdog_enabled", [True, False])
6162
def testVoqWatchdog(
6263
self, ptfhost, dutTestParams, dutConfig, dutQosConfig,
63-
get_src_dst_asic_and_duts, ignore_log_voq_watchdog
64+
duthosts, get_src_dst_asic_and_duts, voq_watchdog_enabled
6465
):
6566
"""
6667
Test VOQ watchdog
@@ -70,70 +71,39 @@ def testVoqWatchdog(
7071
dutConfig (Fixture, dict): Map of DUT config containing dut interfaces, test port IDs, test port IPs,
7172
and test ports
7273
dutQosConfig (Fixture, dict): Map containing DUT host QoS configuration
74+
voq_watchdog_enabled (bool): if VOQ watchdog is enabled or not
7375
Returns:
7476
None
7577
Raises:
7678
RunAnsibleModuleFail if ptf test fails
7779
"""
7880

79-
testParams = dict()
80-
testParams.update(dutTestParams["basicParams"])
81-
testParams.update({
82-
"dscp": 8,
83-
"dst_port_id": dutConfig["testPorts"]["dst_port_id"],
84-
"dst_port_ip": dutConfig["testPorts"]["dst_port_ip"],
85-
"src_port_id": dutConfig["testPorts"]["src_port_id"],
86-
"src_port_ip": dutConfig["testPorts"]["src_port_ip"],
87-
"src_port_vlan": dutConfig["testPorts"]["src_port_vlan"],
88-
"packet_size": 1350,
89-
"pkts_num": PKTS_NUM,
90-
"voq_watchdog_enabled": True,
91-
})
92-
93-
self.runPtfTest(
94-
ptfhost, testCase="sai_qos_tests.VoqWatchdogTest",
95-
testParams=testParams)
96-
97-
self.runPtfTest(
98-
ptfhost, testCase="sai_qos_tests.TrafficSanityTest",
99-
testParams=testParams)
100-
101-
def testVoqWatchdogDisable(
102-
self, ptfhost, dutTestParams, dutConfig, dutQosConfig,
103-
get_src_dst_asic_and_duts, disable_voq_watchdog_function_scope
104-
):
105-
"""
106-
Test VOQ watchdog
107-
Args:
108-
ptfhost (AnsibleHost): Packet Test Framework (PTF)
109-
dutTestParams (Fixture, dict): DUT host test params
110-
dutConfig (Fixture, dict): Map of DUT config containing dut interfaces, test port IDs, test port IPs,
111-
and test ports
112-
dutQosConfig (Fixture, dict): Map containing DUT host QoS configuration
113-
Returns:
114-
None
115-
Raises:
116-
RunAnsibleModuleFail if ptf test fails
117-
"""
118-
119-
testParams = dict()
120-
testParams.update(dutTestParams["basicParams"])
121-
testParams.update({
122-
"dscp": 8,
123-
"dst_port_id": dutConfig["testPorts"]["dst_port_id"],
124-
"dst_port_ip": dutConfig["testPorts"]["dst_port_ip"],
125-
"src_port_id": dutConfig["testPorts"]["src_port_id"],
126-
"src_port_ip": dutConfig["testPorts"]["src_port_ip"],
127-
"src_port_vlan": dutConfig["testPorts"]["src_port_vlan"],
128-
"packet_size": 1350,
129-
"pkts_num": PKTS_NUM,
130-
"voq_watchdog_enabled": False,
131-
})
132-
133-
self.runPtfTest(
134-
ptfhost, testCase="sai_qos_tests.VoqWatchdogTest",
135-
testParams=testParams)
136-
137-
self.runPtfTest(
138-
ptfhost, testCase="sai_qos_tests.TrafficSanityTest",
139-
testParams=testParams)
81+
try:
82+
if not voq_watchdog_enabled:
83+
self.modify_voq_watchdog(duthosts, get_src_dst_asic_and_duts, dutConfig, enable=False)
84+
85+
testParams = dict()
86+
testParams.update(dutTestParams["basicParams"])
87+
testParams.update({
88+
"dscp": 8,
89+
"dst_port_id": dutConfig["testPorts"]["dst_port_id"],
90+
"dst_port_ip": dutConfig["testPorts"]["dst_port_ip"],
91+
"src_port_id": dutConfig["testPorts"]["src_port_id"],
92+
"src_port_ip": dutConfig["testPorts"]["src_port_ip"],
93+
"src_port_vlan": dutConfig["testPorts"]["src_port_vlan"],
94+
"packet_size": 1350,
95+
"pkts_num": PKTS_NUM,
96+
"voq_watchdog_enabled": voq_watchdog_enabled,
97+
})
98+
99+
self.runPtfTest(
100+
ptfhost, testCase="sai_qos_tests.VoqWatchdogTest",
101+
testParams=testParams)
102+
103+
self.runPtfTest(
104+
ptfhost, testCase="sai_qos_tests.TrafficSanityTest",
105+
testParams=testParams)
106+
107+
finally:
108+
if not voq_watchdog_enabled:
109+
self.modify_voq_watchdog(duthosts, get_src_dst_asic_and_duts, dutConfig, enable=True)

0 commit comments

Comments
 (0)