Skip to content
35 changes: 23 additions & 12 deletions tests/platform_tests/api/test_sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,27 @@ def get_interfaces_to_flap_after_sfp_reset(self, port_index_to_info_dict, duthos
interfaces_to_flap.append(intf)
return interfaces_to_flap

def _shutdown_and_no_shutdown_ports(self, duthost, intf_list):
intf_to_flap_joined = ",".join(intf_list)
try:
if duthost.is_multi_asic:
for intf in intf_list:
duthost.shutdown_interface(intf)
else:
duthost.shutdown_interface(intf_to_flap_joined)
except Exception as e:
logger.error("Failed to shutdown interfaces: {}".format(e))

shutdown_wait_scale_factor = max(1, len(intf_list)*0.01)
time.sleep(WAIT_TIME_AFTER_INTF_SHUTDOWN*shutdown_wait_scale_factor)
try:
if duthost.is_multi_asic:
for intf in intf_list:
duthost.no_shutdown_interface(intf)
else:
duthost.no_shutdown_interface(intf_to_flap_joined)
except Exception as e:
logger.error("Failed to startup interfaces: {}".format(e))
#
# Functions to test methods inherited from DeviceBase class
#
Expand Down Expand Up @@ -744,18 +765,8 @@ def test_reset(self,
time.sleep(I2C_WAIT_TIME_AFTER_SFP_RESET)
intf_list = self.get_interfaces_to_flap_after_sfp_reset(port_index_to_info_dict, duthost)
if intf_list:
intf_to_flap_joined = ",".join(intf_list)
logger.info("Flapping interfaces: {}".format(intf_to_flap_joined))
try:
duthost.shutdown_interface(intf_to_flap_joined)
except Exception as e:
logger.error("Failed to shutdown interfaces: {}".format(e))
shutdown_wait_scale_factor = max(1, len(intf_list)*0.01)
time.sleep(WAIT_TIME_AFTER_INTF_SHUTDOWN*shutdown_wait_scale_factor)
try:
duthost.no_shutdown_interface(intf_to_flap_joined)
except Exception as e:
logger.error("Failed to startup interfaces: {}".format(e))
logger.info("Flapping interfaces: {}".format(intf_list))
self._shutdown_and_no_shutdown_ports(duthost, intf_list)
_, port_up_wait_time = default_port_toggle_wait_time(duthost, len(intf_list))
if not wait_until(port_up_wait_time, 10, 0,
check_interface_status_of_up_ports, duthost):
Expand Down
Loading