@@ -1749,7 +1749,7 @@ def mock_get_asic_id(mock_logical_port_name):
1749
1749
patched_util .get_asic_id_for_logical_port .return_value = 0
1750
1750
1751
1751
rc = change_ports_status_for_y_cable_change_event (
1752
- 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 ())
1752
+ 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 ())
1753
1753
1754
1754
assert (rc == None )
1755
1755
@@ -1782,7 +1782,7 @@ def mock_get_asic_id(mock_logical_port_name):
1782
1782
1783
1783
patched_util .get_asic_id_for_logical_port .return_value = 0
1784
1784
rc = change_ports_status_for_y_cable_change_event (
1785
- 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 ())
1785
+ 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 ())
1786
1786
1787
1787
assert (rc == None )
1788
1788
@@ -1826,7 +1826,7 @@ def mock_get_asic_id(mock_logical_port_name):
1826
1826
1827
1827
patched_util .get_asic_id_for_logical_port .return_value = 0
1828
1828
rc = change_ports_status_for_y_cable_change_event (
1829
- 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 ())
1829
+ 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 ())
1830
1830
1831
1831
assert (rc == None )
1832
1832
@@ -1873,7 +1873,7 @@ def mock_get_asic_id(mock_logical_port_name):
1873
1873
1874
1874
patched_util .get_asic_id_for_logical_port .return_value = 0
1875
1875
rc = change_ports_status_for_y_cable_change_event (
1876
- 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 ())
1876
+ 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 ())
1877
1877
1878
1878
assert (rc == None )
1879
1879
@@ -1913,7 +1913,7 @@ def mock_get_asic_id(mock_logical_port_name):
1913
1913
1914
1914
patched_util .get_asic_id_for_logical_port .return_value = 0
1915
1915
rc = change_ports_status_for_y_cable_change_event (
1916
- 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 ())
1916
+ 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 ())
1917
1917
1918
1918
assert (rc == None )
1919
1919
@@ -6491,7 +6491,7 @@ def test_retry_setup_grpc_channel_for_port_incorrect(self):
6491
6491
port_tbl [asic_index ] = swsscommon .Table (
6492
6492
test_db [asic_index ], "PORT_INFO_TABLE" )
6493
6493
grpc_client , fwd_state_response_tbl = {}, {}
6494
- rc = retry_setup_grpc_channel_for_port ("Ethernet0" , 0 , port_tbl , grpc_client , fwd_state_response_tbl )
6494
+ rc = retry_setup_grpc_channel_for_port ("Ethernet0" , 0 , port_tbl , grpc_client )
6495
6495
assert (rc == False )
6496
6496
6497
6497
@patch ('ycable.ycable_utilities.y_cable_helper.setup_grpc_channel_for_port' , MagicMock (return_value = (None ,None )))
@@ -6509,7 +6509,7 @@ def test_retry_setup_grpc_channel_for_port_correct_none_val(self):
6509
6509
port_tbl [asic_index ] = swsscommon .Table (
6510
6510
test_db [asic_index ], "PORT_INFO_TABLE" )
6511
6511
grpc_client , fwd_state_response_tbl = {}, {}
6512
- rc = retry_setup_grpc_channel_for_port ("Ethernet0" , 0 , port_tbl , grpc_client , fwd_state_response_tbl )
6512
+ rc = retry_setup_grpc_channel_for_port ("Ethernet0" , 0 , port_tbl , grpc_client )
6513
6513
assert (rc == False )
6514
6514
6515
6515
def test_process_loopback_interface_and_get_read_side_rc (self ):
@@ -6527,7 +6527,7 @@ def test_process_loopback_interface_and_get_read_side_rc(self):
6527
6527
port_tbl [asic_index ] = swsscommon .Table (
6528
6528
test_db [asic_index ], "PORT_INFO_TABLE" )
6529
6529
grpc_client , fwd_state_response_tbl = {}, {}
6530
- rc = retry_setup_grpc_channel_for_port ("Ethernet0" , 0 , port_tbl , grpc_client , fwd_state_response_tbl )
6530
+ rc = retry_setup_grpc_channel_for_port ("Ethernet0" , 0 , port_tbl , grpc_client )
6531
6531
assert (rc == False )
6532
6532
6533
6533
@patch ('ycable.ycable_utilities.y_cable_helper.setup_grpc_channel_for_port' , MagicMock (return_value = (True ,True )))
@@ -6545,7 +6545,7 @@ def test_retry_setup_grpc_channel_for_port_correct(self):
6545
6545
port_tbl [asic_index ] = swsscommon .Table (
6546
6546
test_db [asic_index ], "PORT_INFO_TABLE" )
6547
6547
grpc_client , fwd_state_response_tbl = {}, {}
6548
- rc = retry_setup_grpc_channel_for_port ("Ethernet0" , 0 , port_tbl , grpc_client , fwd_state_response_tbl )
6548
+ rc = retry_setup_grpc_channel_for_port ("Ethernet0" , 0 , port_tbl , grpc_client )
6549
6549
assert (rc == True )
6550
6550
6551
6551
@patch ('ycable.ycable_utilities.y_cable_helper.setup_grpc_channel_for_port' , MagicMock (return_value = (None ,None )))
@@ -6563,7 +6563,7 @@ def test_retry_setup_grpc_channel_for_port_correct_none_val(self):
6563
6563
port_tbl [asic_index ] = swsscommon .Table (
6564
6564
test_db [asic_index ], "PORT_INFO_TABLE" )
6565
6565
grpc_client , fwd_state_response_tbl = {}, {}
6566
- rc = retry_setup_grpc_channel_for_port ("Ethernet0" , 0 , port_tbl , grpc_client , fwd_state_response_tbl )
6566
+ rc = retry_setup_grpc_channel_for_port ("Ethernet0" , 0 , port_tbl , grpc_client )
6567
6567
assert (rc == False )
6568
6568
6569
6569
def test_process_loopback_interface_and_get_read_side_rc (self ):
@@ -6614,7 +6614,7 @@ def test_check_identifier_presence_and_setup_channel(self):
6614
6614
mux_tbl [asic_index ] = swsscommon .Table (
6615
6615
test_db [asic_index ], "MUX_INFO_TABLE" )
6616
6616
6617
- 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 )
6617
+ 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 )
6618
6618
6619
6619
assert (rc == None )
6620
6620
@@ -6650,7 +6650,7 @@ def test_check_identifier_presence_and_setup_channel_with_false_status(self):
6650
6650
mux_tbl [asic_index ] = swsscommon .Table (
6651
6651
test_db [asic_index ], "MUX_INFO_TABLE" )
6652
6652
6653
- 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 )
6653
+ 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 )
6654
6654
6655
6655
assert (rc == None )
6656
6656
@@ -6687,7 +6687,7 @@ def test_check_identifier_presence_and_setup_channel_with_mock(self):
6687
6687
mux_tbl [asic_index ] = swsscommon .Table (
6688
6688
test_db [asic_index ], "MUX_INFO_TABLE" )
6689
6689
6690
- 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 )
6690
+ 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 )
6691
6691
assert (rc == None )
6692
6692
6693
6693
@@ -6725,7 +6725,7 @@ def test_check_identifier_presence_and_setup_channel_with_mock_not_none(self):
6725
6725
mux_tbl [asic_index ] = swsscommon .Table (
6726
6726
test_db [asic_index ], "MUX_INFO_TABLE" )
6727
6727
6728
- 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 )
6728
+ 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 )
6729
6729
6730
6730
assert (rc == None )
6731
6731
@@ -6749,7 +6749,7 @@ def test_setup_grpc_channel_for_port(self):
6749
6749
with patch ('ycable.ycable_utilities.y_cable_helper.y_cable_platform_sfputil' ) as patched_util :
6750
6750
6751
6751
patched_util .get_asic_id_for_logical_port .return_value = 0
6752
- (channel , stub ) = setup_grpc_channel_for_port ("Ethernet0" , "192.168.0.1" , asic_index , grpc_client , fwd_state_response_tbl , False )
6752
+ (channel , stub ) = setup_grpc_channel_for_port ("Ethernet0" , "192.168.0.1" , asic_index , grpc_client , False )
6753
6753
6754
6754
assert (stub == True )
6755
6755
assert (channel != None )
@@ -6774,7 +6774,7 @@ def test_setup_grpc_channel_for_port_get_false(self):
6774
6774
with patch ('ycable.ycable_utilities.y_cable_helper.y_cable_platform_sfputil' ) as patched_util :
6775
6775
6776
6776
patched_util .get_asic_id_for_logical_port .return_value = 0
6777
- (channel , stub ) = setup_grpc_channel_for_port ("Ethernet0" , "192.168.0.1" , asic_index , grpc_client , fwd_state_response_tbl , False )
6777
+ (channel , stub ) = setup_grpc_channel_for_port ("Ethernet0" , "192.168.0.1" , asic_index , grpc_client , False )
6778
6778
6779
6779
assert (stub == True )
6780
6780
assert (channel != None )
@@ -6798,7 +6798,7 @@ def test_setup_grpc_channels(self):
6798
6798
patched_util .logical .return_value = ['Ethernet0' , 'Ethernet4' ]
6799
6799
patched_util .get_asic_id_for_logical_port .return_value = 0
6800
6800
loopback_keys , hw_mux_cable_tbl , hw_mux_cable_tbl_peer , port_tbl , loopback_tbl , port_table_keys , grpc_client , fwd_state_response_tbl = {}, {}, {}, {}, {}, {}, {}, {}
6801
- 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 )
6801
+ 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 )
6802
6802
6803
6803
assert (rc == None )
6804
6804
@@ -7759,3 +7759,25 @@ def test_ycable_helper_table_worker_toggle_active_active(self, mock_select, mock
7759
7759
assert swsscommon .Select .select .call_count == 1
7760
7760
7761
7761
7762
+ def test_ycable_wait_for_state_change (self ):
7763
+
7764
+ channel_conn = grpc .ChannelConnectivity .TRANSIENT_FAILURE
7765
+ port = 'Ethernet0'
7766
+ rc = wait_for_state_change (channel_conn , port )
7767
+
7768
+ assert (rc == None )
7769
+
7770
+ channel_conn = grpc .ChannelConnectivity .CONNECTING
7771
+ rc = wait_for_state_change (channel_conn , port )
7772
+
7773
+ assert (rc == None )
7774
+
7775
+ channel_conn = grpc .ChannelConnectivity .READY
7776
+ rc = wait_for_state_change (channel_conn , port )
7777
+
7778
+ assert (rc == None )
7779
+
7780
+ channel_conn = grpc .ChannelConnectivity .SHUTDOWN
7781
+ rc = wait_for_state_change (channel_conn , port )
7782
+
7783
+ assert (rc == None )
0 commit comments