@@ -1754,7 +1754,7 @@ def mock_get_asic_id(mock_logical_port_name):
1754
1754
patched_util .get_asic_id_for_logical_port .return_value = 0
1755
1755
1756
1756
rc = change_ports_status_for_y_cable_change_event (
1757
- 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 ())
1757
+ 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 , state_db , stop_event = threading .Event ())
1758
1758
1759
1759
assert (rc == None )
1760
1760
@@ -1787,7 +1787,7 @@ def mock_get_asic_id(mock_logical_port_name):
1787
1787
1788
1788
patched_util .get_asic_id_for_logical_port .return_value = 0
1789
1789
rc = change_ports_status_for_y_cable_change_event (
1790
- 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 ())
1790
+ 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 , state_db , stop_event = threading .Event ())
1791
1791
1792
1792
assert (rc == None )
1793
1793
@@ -1831,7 +1831,7 @@ def mock_get_asic_id(mock_logical_port_name):
1831
1831
1832
1832
patched_util .get_asic_id_for_logical_port .return_value = 0
1833
1833
rc = change_ports_status_for_y_cable_change_event (
1834
- 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 ())
1834
+ 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 , state_db , stop_event = threading .Event ())
1835
1835
1836
1836
assert (rc == None )
1837
1837
@@ -1878,7 +1878,7 @@ def mock_get_asic_id(mock_logical_port_name):
1878
1878
1879
1879
patched_util .get_asic_id_for_logical_port .return_value = 0
1880
1880
rc = change_ports_status_for_y_cable_change_event (
1881
- 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 ())
1881
+ 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 , state_db , stop_event = threading .Event ())
1882
1882
1883
1883
assert (rc == None )
1884
1884
@@ -1918,7 +1918,7 @@ def mock_get_asic_id(mock_logical_port_name):
1918
1918
1919
1919
patched_util .get_asic_id_for_logical_port .return_value = 0
1920
1920
rc = change_ports_status_for_y_cable_change_event (
1921
- 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 ())
1921
+ 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 , state_db , stop_event = threading .Event ())
1922
1922
1923
1923
assert (rc == None )
1924
1924
@@ -6496,7 +6496,7 @@ def test_retry_setup_grpc_channel_for_port_incorrect(self):
6496
6496
port_tbl [asic_index ] = swsscommon .Table (
6497
6497
test_db [asic_index ], "PORT_INFO_TABLE" )
6498
6498
grpc_client , fwd_state_response_tbl = {}, {}
6499
- rc = retry_setup_grpc_channel_for_port ("Ethernet0" , 0 , port_tbl , grpc_client , fwd_state_response_tbl )
6499
+ rc = retry_setup_grpc_channel_for_port ("Ethernet0" , 0 , port_tbl , grpc_client )
6500
6500
assert (rc == False )
6501
6501
6502
6502
@patch ('ycable.ycable_utilities.y_cable_helper.setup_grpc_channel_for_port' , MagicMock (return_value = (None ,None )))
@@ -6514,7 +6514,7 @@ def test_retry_setup_grpc_channel_for_port_correct_none_val(self):
6514
6514
port_tbl [asic_index ] = swsscommon .Table (
6515
6515
test_db [asic_index ], "PORT_INFO_TABLE" )
6516
6516
grpc_client , fwd_state_response_tbl = {}, {}
6517
- rc = retry_setup_grpc_channel_for_port ("Ethernet0" , 0 , port_tbl , grpc_client , fwd_state_response_tbl )
6517
+ rc = retry_setup_grpc_channel_for_port ("Ethernet0" , 0 , port_tbl , grpc_client )
6518
6518
assert (rc == False )
6519
6519
6520
6520
def test_process_loopback_interface_and_get_read_side_rc (self ):
@@ -6532,7 +6532,7 @@ def test_process_loopback_interface_and_get_read_side_rc(self):
6532
6532
port_tbl [asic_index ] = swsscommon .Table (
6533
6533
test_db [asic_index ], "PORT_INFO_TABLE" )
6534
6534
grpc_client , fwd_state_response_tbl = {}, {}
6535
- rc = retry_setup_grpc_channel_for_port ("Ethernet0" , 0 , port_tbl , grpc_client , fwd_state_response_tbl )
6535
+ rc = retry_setup_grpc_channel_for_port ("Ethernet0" , 0 , port_tbl , grpc_client )
6536
6536
assert (rc == False )
6537
6537
6538
6538
@patch ('ycable.ycable_utilities.y_cable_helper.setup_grpc_channel_for_port' , MagicMock (return_value = (True ,True )))
@@ -6550,7 +6550,7 @@ def test_retry_setup_grpc_channel_for_port_correct(self):
6550
6550
port_tbl [asic_index ] = swsscommon .Table (
6551
6551
test_db [asic_index ], "PORT_INFO_TABLE" )
6552
6552
grpc_client , fwd_state_response_tbl = {}, {}
6553
- rc = retry_setup_grpc_channel_for_port ("Ethernet0" , 0 , port_tbl , grpc_client , fwd_state_response_tbl )
6553
+ rc = retry_setup_grpc_channel_for_port ("Ethernet0" , 0 , port_tbl , grpc_client )
6554
6554
assert (rc == True )
6555
6555
6556
6556
@patch ('ycable.ycable_utilities.y_cable_helper.setup_grpc_channel_for_port' , MagicMock (return_value = (None ,None )))
@@ -6568,7 +6568,7 @@ def test_retry_setup_grpc_channel_for_port_correct_none_val(self):
6568
6568
port_tbl [asic_index ] = swsscommon .Table (
6569
6569
test_db [asic_index ], "PORT_INFO_TABLE" )
6570
6570
grpc_client , fwd_state_response_tbl = {}, {}
6571
- rc = retry_setup_grpc_channel_for_port ("Ethernet0" , 0 , port_tbl , grpc_client , fwd_state_response_tbl )
6571
+ rc = retry_setup_grpc_channel_for_port ("Ethernet0" , 0 , port_tbl , grpc_client )
6572
6572
assert (rc == False )
6573
6573
6574
6574
def test_process_loopback_interface_and_get_read_side_rc (self ):
@@ -6619,7 +6619,7 @@ def test_check_identifier_presence_and_setup_channel(self):
6619
6619
mux_tbl [asic_index ] = swsscommon .Table (
6620
6620
test_db [asic_index ], "MUX_INFO_TABLE" )
6621
6621
6622
- 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 )
6622
+ 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 )
6623
6623
6624
6624
assert (rc == None )
6625
6625
@@ -6655,7 +6655,7 @@ def test_check_identifier_presence_and_setup_channel_with_false_status(self):
6655
6655
mux_tbl [asic_index ] = swsscommon .Table (
6656
6656
test_db [asic_index ], "MUX_INFO_TABLE" )
6657
6657
6658
- 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 )
6658
+ 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 )
6659
6659
6660
6660
assert (rc == None )
6661
6661
@@ -6692,7 +6692,7 @@ def test_check_identifier_presence_and_setup_channel_with_mock(self):
6692
6692
mux_tbl [asic_index ] = swsscommon .Table (
6693
6693
test_db [asic_index ], "MUX_INFO_TABLE" )
6694
6694
6695
- 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 )
6695
+ 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 )
6696
6696
assert (rc == None )
6697
6697
6698
6698
@@ -6730,7 +6730,7 @@ def test_check_identifier_presence_and_setup_channel_with_mock_not_none(self):
6730
6730
mux_tbl [asic_index ] = swsscommon .Table (
6731
6731
test_db [asic_index ], "MUX_INFO_TABLE" )
6732
6732
6733
- 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 )
6733
+ 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 )
6734
6734
6735
6735
assert (rc == None )
6736
6736
@@ -6754,7 +6754,7 @@ def test_setup_grpc_channel_for_port(self):
6754
6754
with patch ('ycable.ycable_utilities.y_cable_helper.y_cable_platform_sfputil' ) as patched_util :
6755
6755
6756
6756
patched_util .get_asic_id_for_logical_port .return_value = 0
6757
- (channel , stub ) = setup_grpc_channel_for_port ("Ethernet0" , "192.168.0.1" , asic_index , grpc_client , fwd_state_response_tbl , False )
6757
+ (channel , stub ) = setup_grpc_channel_for_port ("Ethernet0" , "192.168.0.1" , asic_index , grpc_client , False )
6758
6758
6759
6759
assert (stub == True )
6760
6760
assert (channel != None )
@@ -6779,7 +6779,7 @@ def test_setup_grpc_channel_for_port_get_false(self):
6779
6779
with patch ('ycable.ycable_utilities.y_cable_helper.y_cable_platform_sfputil' ) as patched_util :
6780
6780
6781
6781
patched_util .get_asic_id_for_logical_port .return_value = 0
6782
- (channel , stub ) = setup_grpc_channel_for_port ("Ethernet0" , "192.168.0.1" , asic_index , grpc_client , fwd_state_response_tbl , False )
6782
+ (channel , stub ) = setup_grpc_channel_for_port ("Ethernet0" , "192.168.0.1" , asic_index , grpc_client , False )
6783
6783
6784
6784
assert (stub == True )
6785
6785
assert (channel != None )
@@ -6803,7 +6803,7 @@ def test_setup_grpc_channels(self):
6803
6803
patched_util .logical .return_value = ['Ethernet0' , 'Ethernet4' ]
6804
6804
patched_util .get_asic_id_for_logical_port .return_value = 0
6805
6805
loopback_keys , hw_mux_cable_tbl , hw_mux_cable_tbl_peer , port_tbl , loopback_tbl , port_table_keys , grpc_client , fwd_state_response_tbl = {}, {}, {}, {}, {}, {}, {}, {}
6806
- rc = setup_grpc_channels (stop_event , loopback_keys , hw_mux_cable_tbl , hw_mux_cable_tbl_peer , port_tbl , loopback_tbl , port_table_keys , grpc_client , fwd_state_response_tbl )
6806
+ rc = setup_grpc_channels (stop_event , loopback_keys , hw_mux_cable_tbl , hw_mux_cable_tbl_peer , port_tbl , loopback_tbl , port_table_keys , grpc_client )
6807
6807
6808
6808
assert (rc == None )
6809
6809
@@ -7764,3 +7764,25 @@ def test_ycable_helper_table_worker_toggle_active_active(self, mock_select, mock
7764
7764
assert swsscommon .Select .select .call_count == 1
7765
7765
7766
7766
7767
+ def test_ycable_wait_for_state_change (self ):
7768
+
7769
+ channel_conn = grpc .ChannelConnectivity .TRANSIENT_FAILURE
7770
+ port = 'Ethernet0'
7771
+ rc = wait_for_state_change (channel_conn , port )
7772
+
7773
+ assert (rc == None )
7774
+
7775
+ channel_conn = grpc .ChannelConnectivity .CONNECTING
7776
+ rc = wait_for_state_change (channel_conn , port )
7777
+
7778
+ assert (rc == None )
7779
+
7780
+ channel_conn = grpc .ChannelConnectivity .READY
7781
+ rc = wait_for_state_change (channel_conn , port )
7782
+
7783
+ assert (rc == None )
7784
+
7785
+ channel_conn = grpc .ChannelConnectivity .SHUTDOWN
7786
+ rc = wait_for_state_change (channel_conn , port )
7787
+
7788
+ assert (rc == None )
0 commit comments