Skip to content

Commit dd4023a

Browse files
authored
Stabilize test_snmp_fdb_send_tagged (sonic-net#16409)
* Stabilize `test_snmp_fdb_send_tagged Signed-off-by: Longxiang Lyu <lolv@microsoft.com>
1 parent acfd404 commit dd4023a

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tests/snmp/test_snmp_fdb.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import ptf.testutils as testutils
33
import logging
44
import pprint
5-
import time
65

76
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa F401
87
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_rand_selected_tor_m # noqa F401
@@ -17,6 +16,7 @@
1716
from tests.common.helpers.portchannel_to_vlan import vlan_intfs_dict # noqa F401
1817
from tests.common.helpers.portchannel_to_vlan import setup_po2vlan # noqa F401
1918
from tests.common.helpers.portchannel_to_vlan import running_vlan_ports_list
19+
from tests.common.helpers.assertions import pytest_assert
2020

2121
logger = logging.getLogger(__name__)
2222

@@ -46,8 +46,9 @@ def fdb_table_has_no_dynamic_macs(duthost):
4646

4747

4848
@pytest.fixture(scope="module", autouse=True)
49-
def fdb_cleanup(duthost):
49+
def fdb_cleanup(duthosts, rand_one_dut_hostname):
5050
""" cleanup FDB before test run """
51+
duthost = duthosts[rand_one_dut_hostname]
5152
if fdb_table_has_no_dynamic_macs(duthost):
5253
return
5354
else:
@@ -109,6 +110,7 @@ def test_snmp_fdb_send_tagged(ptfadapter, duthosts, rand_one_dut_hostname,
109110
send_cnt = 0
110111
send_portchannels_cnt = 0
111112
vlan_ports_list = running_vlan_ports_list(duthosts, rand_one_dut_hostname, rand_selected_dut, tbinfo, ports_list)
113+
count_before = get_fdb_dynamic_mac_count(duthost)
112114
for vlan_port in vlan_ports_list:
113115
port_index = vlan_port["port_index"][0]
114116
for permit_vlanid in map(int, vlan_port["permit_vlanid"]):
@@ -126,7 +128,14 @@ def test_snmp_fdb_send_tagged(ptfadapter, duthosts, rand_one_dut_hostname,
126128
# Flush dataplane
127129
ptfadapter.dataplane.flush()
128130

129-
time.sleep(20)
131+
pytest_assert(
132+
wait_until(
133+
40, 5, 10,
134+
lambda: (get_fdb_dynamic_mac_count(duthost) - count_before) >= send_cnt
135+
),
136+
"The dummy MACs are not fully populated."
137+
)
138+
130139
hostip = duthost.host.options['inventory_manager'].get_host(
131140
duthost.hostname).vars['ansible_host']
132141
snmp_facts = get_snmp_facts(

0 commit comments

Comments
 (0)