From 81cf7ca8fb8645fee817553fb70cf16c5aa74989 Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Fri, 21 Oct 2022 00:54:05 +0000 Subject: [PATCH] fix tests Signed-off-by: vaibhav-dahiya --- sonic-ycabled/tests/test_ycable.py | 11 ++--------- .../ycable/ycable_utilities/y_cable_helper.py | 5 ++++- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/sonic-ycabled/tests/test_ycable.py b/sonic-ycabled/tests/test_ycable.py index faa34f32f..bb530d8ad 100644 --- a/sonic-ycabled/tests/test_ycable.py +++ b/sonic-ycabled/tests/test_ycable.py @@ -40,11 +40,11 @@ def test_ycable_info_helper_class_run(self, mocked_sleep): with patch('ycable.ycable.platform_sfputil') as patched_util: patched_util.logical.return_value = ['Ethernet0', 'Ethernet4'] patched_util.get_asic_id_for_logical_port.return_value = 0 + stopping_event = MagicMock() + sfp_error_event = MagicMock() Y_cable_state_task = YcableStateUpdateTask(sfp_error_event, y_cable_presence) Y_cable_state_task.task_process = MagicMock() Y_cable_state_task.task_stopping_event = MagicMock() - stopping_event = MagicMock() - sfp_error_event = MagicMock() y_cable_presence = [True] Y_cable_state_task.start() Y_cable_state_task.join() @@ -71,9 +71,6 @@ def test_ycable_helper_class_run_loop(self): Y_cable_task.task_thread = MagicMock() Y_cable_task.task_thread.start = MagicMock() Y_cable_task.task_thread.join = MagicMock() - Y_cable_task.task_cli_thead = MagicMock() - Y_cable_task.task_cli_thead.start = MagicMock() - Y_cable_task.task_cli_thead.join = MagicMock() #Y_cable_task.task_stopping_event.return_value.is_set.return_value = False swsscommon.SubscriberStateTable.return_value.pop.return_value = (True, True, {"read_side": "2"}) Y_cable_task.task_worker() @@ -88,12 +85,8 @@ def test_ycable_helper_class_run(self): Y_cable_task.task_thread = MagicMock() Y_cable_task.task_thread.start = MagicMock() Y_cable_task.task_thread.join = MagicMock() - Y_cable_task.task_cli_thead = MagicMock() - Y_cable_task.task_cli_thead.start = MagicMock() - Y_cable_task.task_cli_thead.join = MagicMock() Y_cable_task.task_stopping_event.return_value.is_set.return_value = True Y_cable_task.task_worker() - Y_cable_task.task_cli_worker() Y_cable_task.start() Y_cable_task.join() diff --git a/sonic-ycabled/ycable/ycable_utilities/y_cable_helper.py b/sonic-ycabled/ycable/ycable_utilities/y_cable_helper.py index bf175b5d5..7b07b7cd6 100644 --- a/sonic-ycabled/ycable/ycable_utilities/y_cable_helper.py +++ b/sonic-ycabled/ycable/ycable_utilities/y_cable_helper.py @@ -1490,7 +1490,7 @@ def change_ports_status_for_y_cable_change_event(port_dict, y_cable_presence, st def delete_ports_status_for_y_cable(y_cable_tbl, static_tbl, mux_tbl, port_tbl, grpc_config): - state_db = {} + config_db, state_db y_cable_tbl_keys = {} static_tbl, mux_tbl = {}, {} grpc_config = {} @@ -1499,6 +1499,7 @@ def delete_ports_status_for_y_cable(y_cable_tbl, static_tbl, mux_tbl, port_tbl, for namespace in namespaces: asic_id = multi_asic.get_asic_index_from_namespace(namespace) state_db[asic_id] = daemon_base.db_connect("STATE_DB", namespace) + config_db[asic_id] = daemon_base.db_connect("CONFIG_DB", namespace) y_cable_tbl_keys[asic_id] = y_cable_tbl[asic_id].getKeys() static_tbl[asic_id] = swsscommon.Table( state_db[asic_id], MUX_CABLE_STATIC_INFO_TABLE) @@ -3442,6 +3443,8 @@ def handle_ycable_enable_disable_tel_notification(fvp_m, key): class YCableTableUpdateTask(threading.Thread): def __init__(self): threading.Thread.__init__(self) + + self.exc = None self.task_thread = None self.task_cli_thread = None self.task_download_firmware_thread = {}