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