From c312eb57512d26c970978996fdfa1b36acce93d2 Mon Sep 17 00:00:00 2001 From: Longxiang Lyu Date: Wed, 8 Jan 2025 22:16:54 -0800 Subject: [PATCH 1/2] Stabilize `test_snmp_fdb_send_tagged Signed-off-by: Longxiang Lyu --- tests/snmp/test_snmp_fdb.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/snmp/test_snmp_fdb.py b/tests/snmp/test_snmp_fdb.py index 711b4bf6ebf..7db328b4b56 100644 --- a/tests/snmp/test_snmp_fdb.py +++ b/tests/snmp/test_snmp_fdb.py @@ -17,6 +17,7 @@ from tests.common.helpers.portchannel_to_vlan import vlan_intfs_dict # noqa F401 from tests.common.helpers.portchannel_to_vlan import setup_po2vlan # noqa F401 from tests.common.helpers.portchannel_to_vlan import running_vlan_ports_list +from tests.common.helpers.assertions import pytest_assert logger = logging.getLogger(__name__) @@ -46,8 +47,9 @@ def fdb_table_has_no_dynamic_macs(duthost): @pytest.fixture(scope="module", autouse=True) -def fdb_cleanup(duthost): +def fdb_cleanup(duthosts, rand_one_dut_hostname): """ cleanup FDB before test run """ + duthost = duthosts[rand_one_dut_hostname] if fdb_table_has_no_dynamic_macs(duthost): return else: @@ -109,6 +111,7 @@ def test_snmp_fdb_send_tagged(ptfadapter, duthosts, rand_one_dut_hostname, send_cnt = 0 send_portchannels_cnt = 0 vlan_ports_list = running_vlan_ports_list(duthosts, rand_one_dut_hostname, rand_selected_dut, tbinfo, ports_list) + count_before = get_fdb_dynamic_mac_count(duthost) for vlan_port in vlan_ports_list: port_index = vlan_port["port_index"][0] for permit_vlanid in map(int, vlan_port["permit_vlanid"]): @@ -126,7 +129,14 @@ def test_snmp_fdb_send_tagged(ptfadapter, duthosts, rand_one_dut_hostname, # Flush dataplane ptfadapter.dataplane.flush() - time.sleep(20) + pytest_assert( + wait_until( + 40, 5, 10, + lambda: (get_fdb_dynamic_mac_count(duthost) - count_before) >= send_cnt + ), + "The dummy MACs are not fully populated." + ) + hostip = duthost.host.options['inventory_manager'].get_host( duthost.hostname).vars['ansible_host'] snmp_facts = get_snmp_facts( From cdd7389dae58de8a8e44b4c0eeed1b778a53885d Mon Sep 17 00:00:00 2001 From: Longxiang Lyu Date: Thu, 9 Jan 2025 00:49:09 -0800 Subject: [PATCH 2/2] Fix pre-commit Signed-off-by: Longxiang Lyu --- tests/snmp/test_snmp_fdb.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/snmp/test_snmp_fdb.py b/tests/snmp/test_snmp_fdb.py index 7db328b4b56..cf59b80b22f 100644 --- a/tests/snmp/test_snmp_fdb.py +++ b/tests/snmp/test_snmp_fdb.py @@ -2,7 +2,6 @@ import ptf.testutils as testutils import logging import pprint -import time from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa F401 from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_rand_selected_tor_m # noqa F401