2
2
import ptf .testutils as testutils
3
3
import logging
4
4
import pprint
5
- import time
6
5
7
6
from tests .common .fixtures .ptfhost_utils import change_mac_addresses # noqa F401
8
7
from tests .common .dualtor .mux_simulator_control import toggle_all_simulator_ports_to_rand_selected_tor_m # noqa F401
17
16
from tests .common .helpers .portchannel_to_vlan import vlan_intfs_dict # noqa F401
18
17
from tests .common .helpers .portchannel_to_vlan import setup_po2vlan # noqa F401
19
18
from tests .common .helpers .portchannel_to_vlan import running_vlan_ports_list
19
+ from tests .common .helpers .assertions import pytest_assert
20
20
21
21
logger = logging .getLogger (__name__ )
22
22
@@ -46,8 +46,9 @@ def fdb_table_has_no_dynamic_macs(duthost):
46
46
47
47
48
48
@pytest .fixture (scope = "module" , autouse = True )
49
- def fdb_cleanup (duthost ):
49
+ def fdb_cleanup (duthosts , rand_one_dut_hostname ):
50
50
""" cleanup FDB before test run """
51
+ duthost = duthosts [rand_one_dut_hostname ]
51
52
if fdb_table_has_no_dynamic_macs (duthost ):
52
53
return
53
54
else :
@@ -109,6 +110,7 @@ def test_snmp_fdb_send_tagged(ptfadapter, duthosts, rand_one_dut_hostname,
109
110
send_cnt = 0
110
111
send_portchannels_cnt = 0
111
112
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 )
112
114
for vlan_port in vlan_ports_list :
113
115
port_index = vlan_port ["port_index" ][0 ]
114
116
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,
126
128
# Flush dataplane
127
129
ptfadapter .dataplane .flush ()
128
130
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
+
130
139
hostip = duthost .host .options ['inventory_manager' ].get_host (
131
140
duthost .hostname ).vars ['ansible_host' ]
132
141
snmp_facts = get_snmp_facts (
0 commit comments