1313from tests .common .platform .processes_utils import wait_critical_processes
1414from tests .common .utilities import wait_until
1515from tests .common .helpers .assertions import pytest_assert
16+ from tests .common .dualtor .mux_simulator_control import toggle_all_simulator_ports_to_rand_selected_tor_m # noqa F401
17+
1618
1719pytestmark = [
1820 pytest .mark .topology ('t0' , 'm0' ),
2426
2527logger = logging .getLogger (__name__ )
2628
29+
30+ def wait_all_bgp_up (duthost ):
31+ config_facts = duthost .config_facts (host = duthost .hostname , source = "running" )['ansible_facts' ]
32+ bgp_neighbors = config_facts .get ('BGP_NEIGHBOR' , {})
33+ if not wait_until (60 , 10 , 0 , duthost .check_bgp_session_state , bgp_neighbors .keys ()):
34+ pytest .fail ("not all bgp sessions are up after config change" )
35+
36+
2737@pytest .fixture (scope = "module" , params = [SINGLE_TOR_MODE , DUAL_TOR_MODE ])
2838def testing_config (request , duthosts , rand_one_dut_hostname , tbinfo ):
2939 testing_mode = request .param
@@ -160,7 +170,8 @@ def test_interface_binding(duthosts, rand_one_dut_hostname, dut_dhcp_relay_data)
160170 for dhcp_relay in dut_dhcp_relay_data :
161171 assert ("*:{}" .format (dhcp_relay ['downlink_vlan_iface' ]['name' ]) or "*:*" in output , "{} is not found in {}" .format ("*:{}" .format (dhcp_relay ['downlink_vlan_iface' ]['name' ]), output )) or ("*:*" in output , "dhcp6relay socket is not properly binded" )
162172
163- def test_dhcpv6_relay_counter (ptfhost , duthosts , rand_one_dut_hostname , dut_dhcp_relay_data ):
173+ def test_dhcpv6_relay_counter (ptfhost , duthosts , rand_one_dut_hostname , dut_dhcp_relay_data ,
174+ toggle_all_simulator_ports_to_rand_selected_tor_m ): # noqa F811
164175 """ Test DHCPv6 Counter """
165176 duthost = duthosts [rand_one_dut_hostname ]
166177 skip_release (duthost , ["201911" , "202106" ])
@@ -185,6 +196,7 @@ def test_dhcpv6_relay_counter(ptfhost, duthosts, rand_one_dut_hostname, dut_dhcp
185196 "server_ip" : str (dhcp_relay ['downlink_vlan_iface' ]['dhcpv6_server_addrs' ][0 ]),
186197 "relay_iface_ip" : str (dhcp_relay ['downlink_vlan_iface' ]['addr' ]),
187198 "relay_iface_mac" : str (dhcp_relay ['downlink_vlan_iface' ]['mac' ]),
199+ "dut_mac" : str (dhcp_relay ['uplink_mac' ]),
188200 "relay_link_local" : str (dhcp_relay ['uplink_interface_link_local' ]),
189201 "vlan_ip" : str (dhcp_relay ['downlink_vlan_iface' ]['addr' ])},
190202 log_file = "/tmp/dhcpv6_relay_test.DHCPCounterTest.log" )
@@ -247,7 +259,7 @@ def test_dhcp_relay_after_link_flap(ptfhost, duthosts, rand_one_dut_hostname, du
247259 duthost .shell ('ifconfig {} up' .format (iface ))
248260
249261 # Sleep a bit to ensure uplinks are up
250- time . sleep ( 20 )
262+ wait_all_bgp_up ( duthost )
251263
252264 # Run the DHCP relay test on the PTF host
253265 ptf_runner (ptfhost ,
@@ -302,7 +314,7 @@ def test_dhcp_relay_start_with_uplinks_down(ptfhost, duthosts, rand_one_dut_host
302314 duthost .shell ('ifconfig {} up' .format (iface ))
303315
304316 # Sleep a bit to ensure uplinks are up
305- time . sleep ( 20 )
317+ wait_all_bgp_up ( duthost )
306318
307319 # Run the DHCP relay test on the PTF host
308320 ptf_runner (ptfhost ,
0 commit comments