diff --git a/sonic-ycabled/tests/test_ycable.py b/sonic-ycabled/tests/test_ycable.py index a84a48c19bd2..be4b4f3959e0 100644 --- a/sonic-ycabled/tests/test_ycable.py +++ b/sonic-ycabled/tests/test_ycable.py @@ -294,6 +294,16 @@ def test_DaemonYcable_init_deinit_full(self): # TODO: fow now we only simply call ycable.init/deinit without any further check, it only makes sure that # ycable.init/deinit will not raise unexpected exception. In future, probably more check will be added + @patch('ycable.ycable_utilities.y_cable_helper.change_ports_status_for_y_cable_change_event', MagicMock(return_value=0)) + def test_handle_state_update_task(self): + + port = "Ethernet0" + fvp_dict = {} + y_cable_presence = False + stopping_event = None + rc = handle_state_update_task(port, fvp_dict, y_cable_presence, stopping_event) + assert(rc == None) + def wait_until(total_wait_time, interval, call_back, *args, **kwargs): wait_time = 0 diff --git a/sonic-ycabled/ycable/ycable.py b/sonic-ycabled/ycable/ycable.py index a020e2a3f5c3..0d62352c715b 100644 --- a/sonic-ycabled/ycable/ycable.py +++ b/sonic-ycabled/ycable/ycable.py @@ -80,6 +80,14 @@ def detect_port_in_error_status(logical_port_name, status_tbl): else: return False +def handle_state_update_task(port, fvp_dict, y_cable_presence, stopping_event): + + port_dict = {} + port_dict[port] = fvp_dict.get('status', None) + + y_cable_helper.change_ports_status_for_y_cable_change_event( + port_dict, y_cable_presence, stopping_event) + # # Helper classes =============================================================== # @@ -149,7 +157,6 @@ def task_worker(self, stopping_event, sfp_error_event, y_cable_presence): # Connect to STATE_DB and listen to ycable transceiver status update tables state_db, status_tbl= {}, {} - port_dict = {} sel = swsscommon.Select() @@ -195,10 +202,8 @@ def task_worker(self, stopping_event, sfp_error_event, y_cable_presence): if not fvp_dict: continue - port_dict[port] = fvp_dict.get('status', None) + handle_state_update_task(port, fvp_dict, y_cable_presence, stopping_event) - y_cable_helper.change_ports_status_for_y_cable_change_event( - port_dict, y_cable_presence, stopping_event) def task_run(self, sfp_error_event, y_cable_presence): if self.task_stopping_event.is_set(): diff --git a/sonic-ycabled/ycable/ycable_utilities/y_cable_helper.py b/sonic-ycabled/ycable/ycable_utilities/y_cable_helper.py index c037c22dcb3f..9cb099dfd832 100644 --- a/sonic-ycabled/ycable/ycable_utilities/y_cable_helper.py +++ b/sonic-ycabled/ycable/ycable_utilities/y_cable_helper.py @@ -2274,6 +2274,9 @@ def handle_config_prbs_cmd_arg_tbl_notification(fvp, xcvrd_config_prbs_cmd_arg_t status = -1 helper_logger.log_warning("Failed to execute the disable prbs API for port {} due to {}".format(physical_port,repr(e))) elif config_prbs_mode == "reset": + + port_instance.mux_toggle_status = port_instance.MUX_TOGGLE_STATUS_NOT_INITIATED_OR_FINISHED + port_instance.download_firmware_status == port_instance.FIRMWARE_DOWNLOAD_STATUS_NOT_INITIATED_OR_FINISHED with y_cable_port_locks[physical_port]: try: status = port_instance.reset(target)