Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ycabled] remove restriction of at least a single physical y_cable to be present for correct start of all ycable threads #468

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions sonic-ycabled/tests/test_y_cable_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ def test_check_identifier_presence_and_update_mux_table_entry_status_false(self)
port_tbl[asic_index].get.return_value = (status, fvs)

rc = check_identifier_presence_and_update_mux_table_entry(
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name, y_cable_presence)
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name)
assert(rc == None)

@patch('ycable.ycable_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
Expand Down Expand Up @@ -1200,7 +1200,7 @@ def test_check_identifier_presence_and_update_mux_table_entry_state_absent(self)
port_tbl[asic_index].get.return_value = (status, fvs)

rc = check_identifier_presence_and_update_mux_table_entry(
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name, y_cable_presence)
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name)
assert(rc == None)

@patch('ycable.ycable_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
Expand Down Expand Up @@ -1231,7 +1231,7 @@ def test_check_identifier_presence_and_update_mux_table_entry_bad_state_value(se
port_tbl[asic_index].get.return_value = (status, fvs)

rc = check_identifier_presence_and_update_mux_table_entry(
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name, y_cable_presence)
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name)
assert(rc == None)

@patch('ycable.ycable_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
Expand Down Expand Up @@ -1262,7 +1262,7 @@ def test_check_identifier_presence_and_update_mux_table_entry_no_presence(self):
port_tbl[asic_index].get.return_value = (status, fvs)

rc = check_identifier_presence_and_update_mux_table_entry(
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name, y_cable_presence)
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name)
assert(rc == None)

@patch('ycable.ycable_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
Expand Down Expand Up @@ -1296,7 +1296,7 @@ def test_check_identifier_presence_and_update_mux_table_entry_no_port_info(self)
patched_util.get_transceiver_info_dict.return_value = None

rc = check_identifier_presence_and_update_mux_table_entry(
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name, y_cable_presence)
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name)
assert(rc == None)

@patch('ycable.ycable_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0, 1, 2]))
Expand Down Expand Up @@ -1331,7 +1331,7 @@ def test_check_identifier_presence_and_update_mux_table_entry_multiple_port_inst
'manufacturer': 'Microsoft', 'model': 'simulated'}

rc = check_identifier_presence_and_update_mux_table_entry(
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name, y_cable_presence)
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name)
assert(rc == None)

@patch('ycable.ycable_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
Expand Down Expand Up @@ -1366,7 +1366,7 @@ def test_check_identifier_presence_and_update_mux_table_entry_no_vendor_port_inf
'bad_manufacturer': 'Microsoft', 'model': 'simulated'}

rc = check_identifier_presence_and_update_mux_table_entry(
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name, y_cable_presence)
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name)
assert(rc == None)

@patch('ycable.ycable_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
Expand Down Expand Up @@ -1401,7 +1401,7 @@ def test_check_identifier_presence_and_update_mux_table_entry_no_model_port_info
'manufacturer': 'Microsoft', 'bad_model': 'simulated'}

rc = check_identifier_presence_and_update_mux_table_entry(
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name, y_cable_presence)
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name)
assert(rc == None)

@patch('ycable.ycable_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
Expand Down Expand Up @@ -1436,7 +1436,7 @@ def test_check_identifier_presence_and_update_mux_table_entry_invalid_vendor_por
'manufacturer': 'not_Microsoft', 'model': 'simulated'}

rc = check_identifier_presence_and_update_mux_table_entry(
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name, y_cable_presence)
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name)
assert(rc == None)

@patch('ycable.ycable_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
Expand Down Expand Up @@ -1472,7 +1472,7 @@ def test_check_identifier_presence_and_update_mux_table_entry_invalid_model_port
'manufacturer': 'Microsoft', 'model': 'bad_model1'}

rc = check_identifier_presence_and_update_mux_table_entry(
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name, y_cable_presence)
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name)
assert(rc == None)

@patch('ycable.ycable_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
Expand Down Expand Up @@ -1511,7 +1511,7 @@ def test_check_identifier_presence_and_update_mux_table_entry_module_dir_none(se
mock_mapping.get.return_value = None

rc = check_identifier_presence_and_update_mux_table_entry(
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name, y_cable_presence)
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name)
assert(rc == None)

@patch('ycable.ycable_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
Expand Down Expand Up @@ -1548,7 +1548,7 @@ def test_check_identifier_presence_and_update_mux_table_entry_module_none(self):
'manufacturer': 'not_Microsoft', 'model': 'model1'}

rc = check_identifier_presence_and_update_mux_table_entry(
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name, y_cable_presence)
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name)
assert(rc == None)

@patch('ycable.ycable_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
Expand Down Expand Up @@ -1586,7 +1586,7 @@ def test_check_identifier_presence_and_update_mux_table_entry_module_microsoft(s

sys.modules['builtins.getattr'] = MagicMock()
rc = check_identifier_presence_and_update_mux_table_entry(
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name, y_cable_presence)
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name)
assert(rc == None)

@patch('ycable.ycable_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
Expand Down Expand Up @@ -1622,7 +1622,7 @@ def test_check_identifier_presence_and_update_mux_table_entry_module_microsoft_y

sys.modules['builtins.getattr'] = MagicMock()
rc = check_identifier_presence_and_update_mux_table_entry(
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name, y_cable_presence)
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name)
assert(rc == None)


Expand Down Expand Up @@ -1660,7 +1660,7 @@ def test_check_identifier_presence_and_delete_mux_table_entry(self):

with patch('ycable.ycable_utilities.y_cable_helper.y_cable_port_instances') as port_instance:
rc = check_identifier_presence_and_delete_mux_table_entry(
state_db, port_tbl, asic_index, logical_port_name, y_cable_presence, delete_change_event, y_cable_tbl, static_tbl, mux_tbl)
state_db, port_tbl, asic_index, logical_port_name, delete_change_event, y_cable_tbl, static_tbl, mux_tbl)
assert(rc == None)


Expand Down Expand Up @@ -1717,7 +1717,7 @@ def mock_get_asic_id(mock_logical_port_name):
grpc_config[asic_index].get.return_value = (status, fvs)
fwd_state_response_tbl = {}

rc = init_ports_status_for_y_cable(platform_sfp, platform_chassis, y_cable_presence, state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, port_table_keys, loopback_keys, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, grpc_config, fwd_state_response_tbl, stop_event=threading.Event())
rc = init_ports_status_for_y_cable(platform_sfp, platform_chassis, state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, port_table_keys, loopback_keys, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, grpc_config, fwd_state_response_tbl, stop_event=threading.Event())

assert(rc == None)

Expand Down Expand Up @@ -1750,7 +1750,7 @@ def mock_get_asic_id(mock_logical_port_name):
patched_util.get_asic_id_for_logical_port.return_value = 0

rc = change_ports_status_for_y_cable_change_event(
logical_port_dict, y_cable_presence, port_tbl, port_table_keys, loopback_tbl, loopback_keys, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, y_cable_tbl, static_tbl, mux_tbl, grpc_client, fwd_state_response_tbl, state_db, stop_event=threading.Event())
logical_port_dict, port_tbl, port_table_keys, loopback_tbl, loopback_keys, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, y_cable_tbl, static_tbl, mux_tbl, grpc_client, fwd_state_response_tbl, state_db, stop_event=threading.Event())

assert(rc == None)

Expand Down Expand Up @@ -1783,7 +1783,7 @@ def mock_get_asic_id(mock_logical_port_name):

patched_util.get_asic_id_for_logical_port.return_value = 0
rc = change_ports_status_for_y_cable_change_event(
logical_port_dict, y_cable_presence, port_tbl, port_table_keys, loopback_tbl, loopback_keys, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, y_cable_tbl, static_tbl, mux_tbl, grpc_client, fwd_state_response_tbl, state_db, stop_event=threading.Event())
logical_port_dict, port_tbl, port_table_keys, loopback_tbl, loopback_keys, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, y_cable_tbl, static_tbl, mux_tbl, grpc_client, fwd_state_response_tbl, state_db, stop_event=threading.Event())

assert(rc == None)

Expand Down Expand Up @@ -1827,7 +1827,7 @@ def mock_get_asic_id(mock_logical_port_name):

patched_util.get_asic_id_for_logical_port.return_value = 0
rc = change_ports_status_for_y_cable_change_event(
logical_port_dict, y_cable_presence, port_tbl, port_table_keys, loopback_tbl, loopback_keys, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, y_cable_tbl, static_tbl, mux_tbl, grpc_client, fwd_state_response_tbl, state_db, stop_event=threading.Event())
logical_port_dict, port_tbl, port_table_keys, loopback_tbl, loopback_keys, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, y_cable_tbl, static_tbl, mux_tbl, grpc_client, fwd_state_response_tbl, state_db, stop_event=threading.Event())

assert(rc == None)

Expand Down Expand Up @@ -1874,7 +1874,7 @@ def mock_get_asic_id(mock_logical_port_name):

patched_util.get_asic_id_for_logical_port.return_value = 0
rc = change_ports_status_for_y_cable_change_event(
logical_port_dict, y_cable_presence, port_tbl, port_table_keys, loopback_tbl, loopback_keys, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, y_cable_tbl, static_tbl, mux_tbl, grpc_client, fwd_state_response_tbl, state_db, stop_event=threading.Event())
logical_port_dict, port_tbl, port_table_keys, loopback_tbl, loopback_keys, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, y_cable_tbl, static_tbl, mux_tbl, grpc_client, fwd_state_response_tbl, state_db, stop_event=threading.Event())

assert(rc == None)

Expand Down Expand Up @@ -1914,7 +1914,7 @@ def mock_get_asic_id(mock_logical_port_name):

patched_util.get_asic_id_for_logical_port.return_value = 0
rc = change_ports_status_for_y_cable_change_event(
logical_port_dict, y_cable_presence,port_tbl, port_table_keys, loopback_tbl, loopback_keys, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, y_cable_tbl, static_tbl, mux_tbl, grpc_client, fwd_state_response_tbl, state_db, stop_event=threading.Event())
logical_port_dict, port_tbl, port_table_keys, loopback_tbl, loopback_keys, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, y_cable_tbl, static_tbl, mux_tbl, grpc_client, fwd_state_response_tbl, state_db, stop_event=threading.Event())

assert(rc == None)

Expand Down Expand Up @@ -6615,7 +6615,7 @@ def test_check_identifier_presence_and_setup_channel(self):
mux_tbl[asic_index] = swsscommon.Table(
test_db[asic_index], "MUX_INFO_TABLE")

rc = check_identifier_presence_and_setup_channel("Ethernet0", port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence, grpc_client, fwd_state_response_tbl)
rc = check_identifier_presence_and_setup_channel("Ethernet0", port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, grpc_client, fwd_state_response_tbl)

assert(rc == None)

Expand Down Expand Up @@ -6651,7 +6651,7 @@ def test_check_identifier_presence_and_setup_channel_with_false_status(self):
mux_tbl[asic_index] = swsscommon.Table(
test_db[asic_index], "MUX_INFO_TABLE")

rc = check_identifier_presence_and_setup_channel("Ethernet0", port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence, grpc_client, fwd_state_response_tbl)
rc = check_identifier_presence_and_setup_channel("Ethernet0", port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, grpc_client, fwd_state_response_tbl)

assert(rc == None)

Expand Down Expand Up @@ -6688,7 +6688,7 @@ def test_check_identifier_presence_and_setup_channel_with_mock(self):
mux_tbl[asic_index] = swsscommon.Table(
test_db[asic_index], "MUX_INFO_TABLE")

rc = check_identifier_presence_and_setup_channel("Ethernet0", port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence, grpc_client, fwd_state_response_tbl)
rc = check_identifier_presence_and_setup_channel("Ethernet0", port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, grpc_client, fwd_state_response_tbl)
assert(rc == None)


Expand Down Expand Up @@ -6726,7 +6726,7 @@ def test_check_identifier_presence_and_setup_channel_with_mock_not_none(self):
mux_tbl[asic_index] = swsscommon.Table(
test_db[asic_index], "MUX_INFO_TABLE")

rc = check_identifier_presence_and_setup_channel("Ethernet0", port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence, grpc_client, fwd_state_response_tbl)
rc = check_identifier_presence_and_setup_channel("Ethernet0", port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, grpc_client, fwd_state_response_tbl)

assert(rc == None)

Expand Down
Loading
Loading