@@ -5529,8 +5529,9 @@ def __init__(self):
5529
5529
5530
5530
5531
5531
response = Response_Helper ()
5532
+ port = "Ethernet4"
5532
5533
5533
- rc = parse_grpc_response_forwarding_state (False , None , 0 )
5534
+ rc = parse_grpc_response_forwarding_state (False , None , 0 , port )
5534
5535
assert (rc == ("unknown" , "unknown" ))
5535
5536
5536
5537
@@ -5543,8 +5544,9 @@ def __init__(self):
5543
5544
5544
5545
5545
5546
response = Response_Helper ()
5547
+ port = "Ethernet4"
5546
5548
5547
- rc = parse_grpc_response_forwarding_state (True , response , 0 )
5549
+ rc = parse_grpc_response_forwarding_state (True , response , 0 , port )
5548
5550
assert (rc == ("active" , "standby" ))
5549
5551
5550
5552
@@ -5557,8 +5559,9 @@ def __init__(self):
5557
5559
5558
5560
5559
5561
response = Response_Helper ()
5562
+ port = "Ethernet4"
5560
5563
5561
- rc = parse_grpc_response_forwarding_state (True , response , 0 )
5564
+ rc = parse_grpc_response_forwarding_state (True , response , 0 , port )
5562
5565
assert (rc == ("active" , "active" ))
5563
5566
5564
5567
@@ -5571,8 +5574,9 @@ def __init__(self):
5571
5574
5572
5575
5573
5576
response = Response_Helper ()
5577
+ port = "Ethernet4"
5574
5578
5575
- rc = parse_grpc_response_forwarding_state (True , response , 1 )
5579
+ rc = parse_grpc_response_forwarding_state (True , response , 1 , port )
5576
5580
assert (rc == ("standby" , "active" ))
5577
5581
5578
5582
@@ -5585,8 +5589,9 @@ def __init__(self):
5585
5589
5586
5590
5587
5591
response = Response_Helper ()
5592
+ port = "Ethernet4"
5588
5593
5589
- rc = parse_grpc_response_forwarding_state (True , response , 1 )
5594
+ rc = parse_grpc_response_forwarding_state (True , response , 1 , port )
5590
5595
assert (rc == ("active" , "active" ))
5591
5596
5592
5597
@@ -5599,8 +5604,9 @@ def __init__(self):
5599
5604
5600
5605
5601
5606
response = Response_Helper ()
5607
+ port = "Ethernet4"
5602
5608
5603
- rc = parse_grpc_response_forwarding_state (True , response , 1 )
5609
+ rc = parse_grpc_response_forwarding_state (True , response , 1 , port )
5604
5610
assert (rc == ("active" , "active" ))
5605
5611
5606
5612
@@ -5613,8 +5619,9 @@ def __init__(self):
5613
5619
5614
5620
5615
5621
response = Response_Helper ()
5622
+ port = "Ethernet4"
5616
5623
5617
- rc = parse_grpc_response_forwarding_state (True , response , 1 )
5624
+ rc = parse_grpc_response_forwarding_state (True , response , 1 , port )
5618
5625
assert (rc == ("standby" , "active" ))
5619
5626
5620
5627
@@ -5627,8 +5634,9 @@ def __init__(self):
5627
5634
5628
5635
5629
5636
response = Response_Helper ()
5637
+ port = "Ethernet4"
5630
5638
5631
- rc = parse_grpc_response_forwarding_state (True , response , 0 )
5639
+ rc = parse_grpc_response_forwarding_state (True , response , 0 , port )
5632
5640
assert (rc == ("standby" , "active" ))
5633
5641
5634
5642
@@ -5641,8 +5649,9 @@ def __init__(self):
5641
5649
5642
5650
5643
5651
response = Response_Helper ()
5652
+ port = "Ethernet4"
5644
5653
5645
- rc = parse_grpc_response_forwarding_state (True , response , 1 )
5654
+ rc = parse_grpc_response_forwarding_state (True , response , 1 , port )
5646
5655
assert (rc == ("standby" , "standby" ))
5647
5656
5648
5657
@@ -5655,8 +5664,9 @@ def __init__(self):
5655
5664
5656
5665
5657
5666
response = Response_Helper ()
5667
+ port = "Ethernet4"
5658
5668
5659
- rc = parse_grpc_response_forwarding_state (True , response , 0 )
5669
+ rc = parse_grpc_response_forwarding_state (True , response , 0 , port )
5660
5670
assert (rc == ("standby" , "standby" ))
5661
5671
5662
5672
@@ -5669,8 +5679,9 @@ def __init__(self):
5669
5679
5670
5680
5671
5681
response = Response_Helper ()
5682
+ port = "Ethernet4"
5672
5683
5673
- rc = parse_grpc_response_forwarding_state (True , response , 0 )
5684
+ rc = parse_grpc_response_forwarding_state (True , response , 0 , port )
5674
5685
assert (rc == ("active" , "active" ))
5675
5686
5676
5687
@@ -5683,8 +5694,9 @@ def __init__(self):
5683
5694
5684
5695
5685
5696
response = Response_Helper ()
5697
+ port = "Ethernet4"
5686
5698
5687
- rc = parse_grpc_response_forwarding_state (True , response , 1 )
5699
+ rc = parse_grpc_response_forwarding_state (True , response , 1 , port )
5688
5700
assert (rc == ("standby" , "standby" ))
5689
5701
5690
5702
@@ -5820,3 +5832,182 @@ def test_handle_ycable_active_standby_probe_notification(self):
5820
5832
rc = handle_ycable_active_standby_probe_notification ("active-standby" , fvp_dict , test_db , hw_mux_cable_tbl , port_m , asic_index , y_cable_response_tbl )
5821
5833
assert (rc == True )
5822
5834
5835
+
5836
+ def test_parse_grpc_response_link_and_oper_state_down_down (self ):
5837
+
5838
+ class Response_Helper ():
5839
+ def __init__ (self ):
5840
+ self .portid = [0 ,1 ]
5841
+ self .state = [False ,False ]
5842
+
5843
+
5844
+ response = Response_Helper ()
5845
+
5846
+ rc = parse_grpc_response_link_and_oper_state (True , response , 1 , "oper_state" , "Ethernet4" )
5847
+ assert (rc == ("down" , "down" ))
5848
+
5849
+ def test_parse_grpc_response_link_and_oper_state_up_down (self ):
5850
+
5851
+ class Response_Helper ():
5852
+ def __init__ (self ):
5853
+ self .portid = [0 ,1 ]
5854
+ self .state = [True ,False ]
5855
+
5856
+
5857
+ response = Response_Helper ()
5858
+
5859
+ rc = parse_grpc_response_link_and_oper_state (True , response , 1 , "oper_state" , "Ethernet4" )
5860
+ assert (rc == ("down" , "up" ))
5861
+
5862
+ def test_parse_grpc_response_link_and_oper_state_up_up (self ):
5863
+
5864
+ class Response_Helper ():
5865
+ def __init__ (self ):
5866
+ self .portid = [0 ,1 ]
5867
+ self .state = [True , True ]
5868
+
5869
+
5870
+ response = Response_Helper ()
5871
+
5872
+ rc = parse_grpc_response_link_and_oper_state (True , response , 1 , "oper_state" , "Ethernet4" )
5873
+ assert (rc == ("up" , "up" ))
5874
+
5875
+ def test_parse_grpc_response_link_and_oper_state_down_down_read_side_zero (self ):
5876
+
5877
+ class Response_Helper ():
5878
+ def __init__ (self ):
5879
+ self .portid = [0 ,1 ]
5880
+ self .state = [False ,False ]
5881
+
5882
+
5883
+ response = Response_Helper ()
5884
+
5885
+ rc = parse_grpc_response_link_and_oper_state (True , response , 0 , "oper_state" , "Ethernet4" )
5886
+ assert (rc == ("down" , "down" ))
5887
+
5888
+ def test_parse_grpc_response_link_and_oper_state_up_down_read_side_zero (self ):
5889
+
5890
+ class Response_Helper ():
5891
+ def __init__ (self ):
5892
+ self .portid = [0 ,1 ]
5893
+ self .state = [True ,False ]
5894
+
5895
+
5896
+ response = Response_Helper ()
5897
+
5898
+ rc = parse_grpc_response_link_and_oper_state (True , response , 0 , "oper_state" , "Ethernet4" )
5899
+ assert (rc == ("up" , "down" ))
5900
+
5901
+ def test_parse_grpc_response_link_and_oper_state_up_up_read_side_zero (self ):
5902
+
5903
+ class Response_Helper ():
5904
+ def __init__ (self ):
5905
+ self .portid = [0 ,1 ]
5906
+ self .state = [True , True ]
5907
+
5908
+
5909
+ response = Response_Helper ()
5910
+
5911
+ rc = parse_grpc_response_link_and_oper_state (True , response , 0 , "oper_state" , "Ethernet4" )
5912
+ assert (rc == ("up" , "up" ))
5913
+
5914
+ def test_parse_grpc_response_link_and_oper_state_down_down_read_side_zero_unknown (self ):
5915
+
5916
+ class Response_Helper ():
5917
+ def __init__ (self ):
5918
+ self .portid = [0 ,1 ]
5919
+ self .state = [False ,False ]
5920
+
5921
+
5922
+ response = Response_Helper ()
5923
+
5924
+ rc = parse_grpc_response_link_and_oper_state (False , response , 0 , "oper_state" , "Ethernet4" )
5925
+ assert (rc == ("unknown" , "unknown" ))
5926
+
5927
+ def test_parse_grpc_response_link_and_oper_state_up_down_read_side_zero (self ):
5928
+
5929
+ class Response_Helper ():
5930
+ def __init__ (self ):
5931
+ self .portid = [0 ]
5932
+ self .state = [False ]
5933
+
5934
+
5935
+ response = Response_Helper ()
5936
+
5937
+ rc = parse_grpc_response_link_and_oper_state (True , response , 0 , "oper_state" , "Ethernet4" )
5938
+ assert (rc == ("unknown" , "unknown" ))
5939
+
5940
+ def test_parse_grpc_response_link_and_oper_state_up_up_read_side_zero (self ):
5941
+
5942
+ class Response_Helper ():
5943
+ def __init__ (self ):
5944
+ self .portid = [0 ,1 ]
5945
+ self .state = [True ]
5946
+
5947
+
5948
+ response = Response_Helper ()
5949
+
5950
+ rc = parse_grpc_response_link_and_oper_state (True , response , 0 , "link_state" , "Ethernet4" )
5951
+ assert (rc == ("unknown" , "unknown" ))
5952
+
5953
+ def test_parse_grpc_response_link_and_oper_state_down_down_read_side_zero_link_state (self ):
5954
+
5955
+ class Response_Helper ():
5956
+ def __init__ (self ):
5957
+ self .portid = [0 ,1 ]
5958
+ self .state = [False ,False ]
5959
+
5960
+
5961
+ response = Response_Helper ()
5962
+
5963
+ rc = parse_grpc_response_link_and_oper_state (True , response , 0 , "link_state" , "Ethernet4" )
5964
+ assert (rc == ("down" , "down" ))
5965
+
5966
+ def test_parse_grpc_response_link_and_oper_state_up_down_read_side_zero_link_state (self ):
5967
+
5968
+ class Response_Helper ():
5969
+ def __init__ (self ):
5970
+ self .portid = [0 ,1 ]
5971
+ self .state = [True ,False ]
5972
+
5973
+
5974
+ response = Response_Helper ()
5975
+
5976
+ rc = parse_grpc_response_link_and_oper_state (True , response , 0 , "link_state" , "Ethernet4" )
5977
+ assert (rc == ("up" , "down" ))
5978
+
5979
+ def test_parse_grpc_response_link_and_oper_state_up_up_read_side_zero_link_state (self ):
5980
+
5981
+ class Response_Helper ():
5982
+ def __init__ (self ):
5983
+ self .portid = [0 ,1 ]
5984
+ self .state = [True , True ]
5985
+
5986
+
5987
+ response = Response_Helper ()
5988
+
5989
+ rc = parse_grpc_response_link_and_oper_state (True , response , 0 , "link_state" , "Ethernet4" )
5990
+ assert (rc == ("up" , "up" ))
5991
+
5992
+ def test_get_muxcable_info_for_active_active (self ):
5993
+ physical_port = 20
5994
+
5995
+ logical_port_name = "Ethernet20"
5996
+ swsscommon .Table .return_value .get .return_value = (
5997
+ True , {"read_side" : "1" })
5998
+ asic_index = 0
5999
+ y_cable_tbl = {}
6000
+ mux_tbl = {}
6001
+ test_db = "TEST_DB"
6002
+ status = True
6003
+ fvs = [('state' , "auto" ), ('read_side' , 1 )]
6004
+ y_cable_tbl [asic_index ] = swsscommon .Table (
6005
+ test_db [asic_index ], "Y_CABLE_TABLE" )
6006
+ y_cable_tbl [asic_index ].get .return_value = (status , fvs )
6007
+
6008
+ rc = get_muxcable_info_for_active_active (physical_port , logical_port_name , mux_tbl , asic_index , y_cable_tbl )
6009
+
6010
+ assert (rc ['self_mux_direction' ] == 'unknown' )
6011
+ assert (rc ['peer_mux_direction' ] == 'unknown' )
6012
+ assert (rc ['mux_direction_probe_count' ] == 'unknown' )
6013
+ assert (rc ['peer_mux_direction_probe_count' ] == 'unknown' )
0 commit comments