From a47af4aa084ec755a654c9d726d7e11d30ba209e Mon Sep 17 00:00:00 2001 From: Janet Cui Date: Tue, 13 Aug 2024 20:17:51 +1000 Subject: [PATCH 1/2] solve conflicts in the PR #14041 Signed-off-by: Janetxxx --- tests/pfcwd/files/pfcwd_helper.py | 19 ++++++++++++++++ tests/pfcwd/test_pfcwd_function.py | 31 +++++++++++++++++++++++++++ tests/pfcwd/test_pfcwd_warm_reboot.py | 16 +++++++++++++- 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/tests/pfcwd/files/pfcwd_helper.py b/tests/pfcwd/files/pfcwd_helper.py index 898b0a1d37..6b8965c73d 100644 --- a/tests/pfcwd/files/pfcwd_helper.py +++ b/tests/pfcwd/files/pfcwd_helper.py @@ -546,6 +546,25 @@ def _stop_background_traffic(ptfhost, background_traffic_log): ptfhost.shell(f"kill -9 {pid}", module_ignore_errors=True) +def has_neighbor_device(setup_pfc_test): + """ + Check if there are neighbor devices present + + Args: + setup_pfc_test (fixture): Module scoped autouse fixture for PFCwd + + Returns: + bool: True if there are neighbor devices present, False otherwise + """ + for _, details in setup_pfc_test['selected_test_ports'].items(): + # 'rx_port' and 'rx_port_id' are expected to be conjugate attributes + # if one is unset or contains None, the other should be as well + if (not details.get('rx_port') or None in details['rx_port']) or \ + (not details.get('rx_port_id') or None in details['rx_port_id']): + return False # neighbor devices are not present + return True + + def check_pfc_storm_state(dut, port, queue): """ Helper function to check if PFC storm is detected/restored on a given queue diff --git a/tests/pfcwd/test_pfcwd_function.py b/tests/pfcwd/test_pfcwd_function.py index 4e9e6d29ba..baf37190cc 100644 --- a/tests/pfcwd/test_pfcwd_function.py +++ b/tests/pfcwd/test_pfcwd_function.py @@ -12,6 +12,7 @@ from tests.common.plugins.loganalyzer.loganalyzer import LogAnalyzer from .files.pfcwd_helper import start_wd_on_ports from .files.pfcwd_helper import EXPECT_PFC_WD_DETECT_RE, EXPECT_PFC_WD_RESTORE_RE, fetch_vendor_specific_diagnosis_re +from .files.pfcwd_helper import has_neighbor_device from tests.ptf_runner import ptf_runner from tests.common import port_toggle from tests.common import constants @@ -884,6 +885,12 @@ def test_pfcwd_actions(self, request, fake_storm, setup_pfc_test, setup_dut_test self.tx_action = None self.is_dualtor = setup_dut_info['basicParams']['is_dualtor'] + # skip the pytest when the device does not have neighbors + # 'rx_port' being None indicates there are no ports available to receive frames for pfc storm + if not has_neighbor_device(setup_pfc_test): + pytest.skip("Test skipped: No neighbors detected as 'rx_port' is None for selected test ports," + " which is necessary for PFCwd test setup.") + for idx, port in enumerate(self.ports): logger.info("") logger.info("--- Testing various Pfcwd actions on {} ---".format(port)) @@ -973,6 +980,12 @@ def test_pfcwd_multi_port(self, request, fake_storm, setup_pfc_test, setup_dut_t self.set_traffic_action(duthost, "drop") self.stats = PfcPktCntrs(self.dut, self.rx_action, self.tx_action) + # skip the pytest when the device does not have neighbors + # 'rx_port' being None indicates there are no ports available to receive frames for pfc storm + if not has_neighbor_device(setup_pfc_test): + pytest.skip("Test skipped: No neighbors detected as 'rx_port' is None for selected test ports," + " which is necessary for PFCwd test setup.") + for count in range(2): try: for idx, port in enumerate(selected_ports): @@ -1055,6 +1068,12 @@ def test_pfcwd_mmu_change(self, request, fake_storm, setup_pfc_test, setup_dut_t self.set_traffic_action(duthost, "drop") self.stats = PfcPktCntrs(self.dut, self.rx_action, self.tx_action) + # skip the pytest when the device does not have neighbors + # 'rx_port' being None indicates there are no ports available to receive frames for pfc storm + if not has_neighbor_device(setup_pfc_test): + pytest.skip("Test skipped: No neighbors detected as 'rx_port' is None for selected test ports," + " which is necessary for PFCwd test setup.") + try: for idx, mmu_action in enumerate(MMU_ACTIONS): self.traffic_inst = SendVerifyTraffic( @@ -1139,6 +1158,12 @@ def test_pfcwd_port_toggle(self, request, fake_storm, setup_pfc_test, setup_dut_ self.is_dualtor = setup_dut_info['basicParams']['is_dualtor'] action = "dontcare" + # skip the pytest when the device does not have neighbors + # 'rx_port' being None indicates there are no ports available to receive frames for pfc storm + if not has_neighbor_device(setup_pfc_test): + pytest.skip("Test skipped: No neighbors detected as 'rx_port' is None for selected test ports," + " which is necessary for PFCwd test setup.") + for idx, port in enumerate(self.ports): logger.info("") logger.info("--- Testing port toggling with PFCWD enabled on {} ---".format(port)) @@ -1227,6 +1252,12 @@ def test_pfcwd_no_traffic( self.is_dualtor = setup_dut_info['basicParams']['is_dualtor'] self.fake_storm = False # Not needed for this test. + # skip the pytest when the device does not have neighbors + # 'rx_port' being None indicates there are no ports available to receive frames for pfc storm + if not has_neighbor_device(setup_pfc_test): + pytest.skip("Test skipped: No neighbors detected as 'rx_port' is None for selected test ports," + " which is necessary for PFCwd test setup.") + for idx, port in enumerate(self.ports): logger.info("") logger.info("--- Testing non-Trafific Pfcwd actions on {} ---".format(port)) diff --git a/tests/pfcwd/test_pfcwd_warm_reboot.py b/tests/pfcwd/test_pfcwd_warm_reboot.py index 1e673beb33..f12a4eaa83 100644 --- a/tests/pfcwd/test_pfcwd_warm_reboot.py +++ b/tests/pfcwd/test_pfcwd_warm_reboot.py @@ -18,6 +18,7 @@ from tests.ptf_runner import ptf_runner from .files.pfcwd_helper import EXPECT_PFC_WD_DETECT_RE, EXPECT_PFC_WD_RESTORE_RE from .files.pfcwd_helper import send_background_traffic +from .files.pfcwd_helper import has_neighbor_device from tests.common.utilities import wait_until TEMPLATES_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "templates") @@ -440,14 +441,21 @@ def run_test(self, port, queue, detect=True, storm_start=True, first_detect_afte self.traffic_inst.verify_wd_func(self.dut, detect=detect) @pytest.fixture(autouse=True) - def pfcwd_wb_test_cleanup(self): + def pfcwd_wb_test_cleanup(self, setup_pfc_test): """ Cleanup method + + Args: + setup_pfc_test(fixture): module scoped autouse fixture """ yield # stop all threads that might stuck in wait DUT_ACTIVE.set() + # if there are no neighbor devices detected, exit the cleanup function early + if not has_neighbor_device(setup_pfc_test): + return + for thread in self.storm_threads: thread_exception = thread.join(timeout=0.1, suppress_exception=True) @@ -610,6 +618,12 @@ def test_pfcwd_wb(self, fake_storm, testcase_action, setup_pfc_test, enum_fanout localhost(AnsibleHost) : localhost instance fanouthosts(AnsibleHost): fanout instance """ + # skip the pytest when the device does not have neighbors + # 'rx_port_id' being None indicates there are no ports available to receive frames for the fake storm + if not has_neighbor_device(setup_pfc_test): + pytest.skip("Test skipped: No neighbors detected as 'rx_port_id' is None for selected test ports," + " which is necessary for PFCwd test setup.") + duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] logger.info("--- {} ---".format(TESTCASE_INFO[testcase_action]['desc'])) self.pfcwd_wb_helper(fake_storm, TESTCASE_INFO[testcase_action]['test_sequence'], setup_pfc_test, From e77680bf49bda1a4fbcb443762344ab270cf134d Mon Sep 17 00:00:00 2001 From: Riff Date: Wed, 29 May 2024 14:08:36 -0700 Subject: [PATCH 2/2] Enable fdb and qos tests for t0-standalone-* topology (#13019) * Whitelist t0-standalone-* topology for enabling FDB test cases. * Whitelist t0-standalone-* topology to enable QoS tests. * Update test marks. --- tests/qos/qos_sai_base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/qos/qos_sai_base.py b/tests/qos/qos_sai_base.py index ee5b56738b..35bda80d6f 100644 --- a/tests/qos/qos_sai_base.py +++ b/tests/qos/qos_sai_base.py @@ -36,9 +36,9 @@ class QosBase: Common APIs """ SUPPORTED_T0_TOPOS = ["t0", "t0-56-po2vlan", "t0-64", "t0-116", "t0-35", "dualtor-56", "dualtor-64", "dualtor-120", - "dualtor", "dualtor-64-breakout", "t0-120", "t0-80", "t0-backend", "t0-56-o8v48", "t0-8-lag", - "t0-standalone-32", "t0-standalone-64", "t0-standalone-128", "t0-standalone-256", "t0-28"] - SUPPORTED_T1_TOPOS = ["t1-lag", "t1-64-lag", "t1-56-lag", "t1-backend", "t1-28-lag", "t1-32-lag"] + "dualtor", "t0-120", "t0-80", "t0-backend", "t0-56-o8v48", "t0-8-lag", "t0-standalone-32", + "t0-standalone-64", "t0-standalone-128", "t0-standalone-256"] + SUPPORTED_T1_TOPOS = ["t1-lag", "t1-64-lag", "t1-56-lag", "t1-backend", "t1-28-lag"] SUPPORTED_PTF_TOPOS = ['ptf32', 'ptf64'] SUPPORTED_ASIC_LIST = ["pac", "gr", "gr2", "gb", "td2", "th", "th2", "spc1", "spc2", "spc3", "spc4", "td3", "th3", "j2c+", "jr2", "th5"]