@@ -5456,8 +5456,9 @@ def __init__(self):
5456
5456
5457
5457
5458
5458
response = Response_Helper ()
5459
+ port = "Ethernet4"
5459
5460
5460
- rc = parse_grpc_response_forwarding_state (False , None , 0 )
5461
+ rc = parse_grpc_response_forwarding_state (False , None , 0 , port )
5461
5462
assert (rc == ("unknown" , "unknown" ))
5462
5463
5463
5464
@@ -5470,8 +5471,9 @@ def __init__(self):
5470
5471
5471
5472
5472
5473
response = Response_Helper ()
5474
+ port = "Ethernet4"
5473
5475
5474
- rc = parse_grpc_response_forwarding_state (True , response , 0 )
5476
+ rc = parse_grpc_response_forwarding_state (True , response , 0 , port )
5475
5477
assert (rc == ("active" , "standby" ))
5476
5478
5477
5479
@@ -5484,8 +5486,9 @@ def __init__(self):
5484
5486
5485
5487
5486
5488
response = Response_Helper ()
5489
+ port = "Ethernet4"
5487
5490
5488
- rc = parse_grpc_response_forwarding_state (True , response , 0 )
5491
+ rc = parse_grpc_response_forwarding_state (True , response , 0 , port )
5489
5492
assert (rc == ("active" , "active" ))
5490
5493
5491
5494
@@ -5498,8 +5501,9 @@ def __init__(self):
5498
5501
5499
5502
5500
5503
response = Response_Helper ()
5504
+ port = "Ethernet4"
5501
5505
5502
- rc = parse_grpc_response_forwarding_state (True , response , 1 )
5506
+ rc = parse_grpc_response_forwarding_state (True , response , 1 , port )
5503
5507
assert (rc == ("standby" , "active" ))
5504
5508
5505
5509
@@ -5512,8 +5516,9 @@ def __init__(self):
5512
5516
5513
5517
5514
5518
response = Response_Helper ()
5519
+ port = "Ethernet4"
5515
5520
5516
- rc = parse_grpc_response_forwarding_state (True , response , 1 )
5521
+ rc = parse_grpc_response_forwarding_state (True , response , 1 , port )
5517
5522
assert (rc == ("active" , "active" ))
5518
5523
5519
5524
@@ -5526,8 +5531,9 @@ def __init__(self):
5526
5531
5527
5532
5528
5533
response = Response_Helper ()
5534
+ port = "Ethernet4"
5529
5535
5530
- rc = parse_grpc_response_forwarding_state (True , response , 1 )
5536
+ rc = parse_grpc_response_forwarding_state (True , response , 1 , port )
5531
5537
assert (rc == ("active" , "active" ))
5532
5538
5533
5539
@@ -5540,8 +5546,9 @@ def __init__(self):
5540
5546
5541
5547
5542
5548
response = Response_Helper ()
5549
+ port = "Ethernet4"
5543
5550
5544
- rc = parse_grpc_response_forwarding_state (True , response , 1 )
5551
+ rc = parse_grpc_response_forwarding_state (True , response , 1 , port )
5545
5552
assert (rc == ("standby" , "active" ))
5546
5553
5547
5554
@@ -5554,8 +5561,9 @@ def __init__(self):
5554
5561
5555
5562
5556
5563
response = Response_Helper ()
5564
+ port = "Ethernet4"
5557
5565
5558
- rc = parse_grpc_response_forwarding_state (True , response , 0 )
5566
+ rc = parse_grpc_response_forwarding_state (True , response , 0 , port )
5559
5567
assert (rc == ("standby" , "active" ))
5560
5568
5561
5569
@@ -5568,8 +5576,9 @@ def __init__(self):
5568
5576
5569
5577
5570
5578
response = Response_Helper ()
5579
+ port = "Ethernet4"
5571
5580
5572
- rc = parse_grpc_response_forwarding_state (True , response , 1 )
5581
+ rc = parse_grpc_response_forwarding_state (True , response , 1 , port )
5573
5582
assert (rc == ("standby" , "standby" ))
5574
5583
5575
5584
@@ -5582,8 +5591,9 @@ def __init__(self):
5582
5591
5583
5592
5584
5593
response = Response_Helper ()
5594
+ port = "Ethernet4"
5585
5595
5586
- rc = parse_grpc_response_forwarding_state (True , response , 0 )
5596
+ rc = parse_grpc_response_forwarding_state (True , response , 0 , port )
5587
5597
assert (rc == ("standby" , "standby" ))
5588
5598
5589
5599
@@ -5596,8 +5606,9 @@ def __init__(self):
5596
5606
5597
5607
5598
5608
response = Response_Helper ()
5609
+ port = "Ethernet4"
5599
5610
5600
- rc = parse_grpc_response_forwarding_state (True , response , 0 )
5611
+ rc = parse_grpc_response_forwarding_state (True , response , 0 , port )
5601
5612
assert (rc == ("active" , "active" ))
5602
5613
5603
5614
@@ -5610,8 +5621,9 @@ def __init__(self):
5610
5621
5611
5622
5612
5623
response = Response_Helper ()
5624
+ port = "Ethernet4"
5613
5625
5614
- rc = parse_grpc_response_forwarding_state (True , response , 1 )
5626
+ rc = parse_grpc_response_forwarding_state (True , response , 1 , port )
5615
5627
assert (rc == ("standby" , "standby" ))
5616
5628
5617
5629
@@ -5747,3 +5759,182 @@ def test_handle_ycable_active_standby_probe_notification(self):
5747
5759
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 )
5748
5760
assert (rc == True )
5749
5761
5762
+
5763
+ def test_parse_grpc_response_link_and_oper_state_down_down (self ):
5764
+
5765
+ class Response_Helper ():
5766
+ def __init__ (self ):
5767
+ self .portid = [0 ,1 ]
5768
+ self .state = [False ,False ]
5769
+
5770
+
5771
+ response = Response_Helper ()
5772
+
5773
+ rc = parse_grpc_response_link_and_oper_state (True , response , 1 , "oper_state" , "Ethernet4" )
5774
+ assert (rc == ("down" , "down" ))
5775
+
5776
+ def test_parse_grpc_response_link_and_oper_state_up_down (self ):
5777
+
5778
+ class Response_Helper ():
5779
+ def __init__ (self ):
5780
+ self .portid = [0 ,1 ]
5781
+ self .state = [True ,False ]
5782
+
5783
+
5784
+ response = Response_Helper ()
5785
+
5786
+ rc = parse_grpc_response_link_and_oper_state (True , response , 1 , "oper_state" , "Ethernet4" )
5787
+ assert (rc == ("down" , "up" ))
5788
+
5789
+ def test_parse_grpc_response_link_and_oper_state_up_up (self ):
5790
+
5791
+ class Response_Helper ():
5792
+ def __init__ (self ):
5793
+ self .portid = [0 ,1 ]
5794
+ self .state = [True , True ]
5795
+
5796
+
5797
+ response = Response_Helper ()
5798
+
5799
+ rc = parse_grpc_response_link_and_oper_state (True , response , 1 , "oper_state" , "Ethernet4" )
5800
+ assert (rc == ("up" , "up" ))
5801
+
5802
+ def test_parse_grpc_response_link_and_oper_state_down_down_read_side_zero (self ):
5803
+
5804
+ class Response_Helper ():
5805
+ def __init__ (self ):
5806
+ self .portid = [0 ,1 ]
5807
+ self .state = [False ,False ]
5808
+
5809
+
5810
+ response = Response_Helper ()
5811
+
5812
+ rc = parse_grpc_response_link_and_oper_state (True , response , 0 , "oper_state" , "Ethernet4" )
5813
+ assert (rc == ("down" , "down" ))
5814
+
5815
+ def test_parse_grpc_response_link_and_oper_state_up_down_read_side_zero (self ):
5816
+
5817
+ class Response_Helper ():
5818
+ def __init__ (self ):
5819
+ self .portid = [0 ,1 ]
5820
+ self .state = [True ,False ]
5821
+
5822
+
5823
+ response = Response_Helper ()
5824
+
5825
+ rc = parse_grpc_response_link_and_oper_state (True , response , 0 , "oper_state" , "Ethernet4" )
5826
+ assert (rc == ("up" , "down" ))
5827
+
5828
+ def test_parse_grpc_response_link_and_oper_state_up_up_read_side_zero (self ):
5829
+
5830
+ class Response_Helper ():
5831
+ def __init__ (self ):
5832
+ self .portid = [0 ,1 ]
5833
+ self .state = [True , True ]
5834
+
5835
+
5836
+ response = Response_Helper ()
5837
+
5838
+ rc = parse_grpc_response_link_and_oper_state (True , response , 0 , "oper_state" , "Ethernet4" )
5839
+ assert (rc == ("up" , "up" ))
5840
+
5841
+ def test_parse_grpc_response_link_and_oper_state_down_down_read_side_zero_unknown (self ):
5842
+
5843
+ class Response_Helper ():
5844
+ def __init__ (self ):
5845
+ self .portid = [0 ,1 ]
5846
+ self .state = [False ,False ]
5847
+
5848
+
5849
+ response = Response_Helper ()
5850
+
5851
+ rc = parse_grpc_response_link_and_oper_state (False , response , 0 , "oper_state" , "Ethernet4" )
5852
+ assert (rc == ("unknown" , "unknown" ))
5853
+
5854
+ def test_parse_grpc_response_link_and_oper_state_up_down_read_side_zero (self ):
5855
+
5856
+ class Response_Helper ():
5857
+ def __init__ (self ):
5858
+ self .portid = [0 ]
5859
+ self .state = [False ]
5860
+
5861
+
5862
+ response = Response_Helper ()
5863
+
5864
+ rc = parse_grpc_response_link_and_oper_state (True , response , 0 , "oper_state" , "Ethernet4" )
5865
+ assert (rc == ("unknown" , "unknown" ))
5866
+
5867
+ def test_parse_grpc_response_link_and_oper_state_up_up_read_side_zero (self ):
5868
+
5869
+ class Response_Helper ():
5870
+ def __init__ (self ):
5871
+ self .portid = [0 ,1 ]
5872
+ self .state = [True ]
5873
+
5874
+
5875
+ response = Response_Helper ()
5876
+
5877
+ rc = parse_grpc_response_link_and_oper_state (True , response , 0 , "link_state" , "Ethernet4" )
5878
+ assert (rc == ("unknown" , "unknown" ))
5879
+
5880
+ def test_parse_grpc_response_link_and_oper_state_down_down_read_side_zero_link_state (self ):
5881
+
5882
+ class Response_Helper ():
5883
+ def __init__ (self ):
5884
+ self .portid = [0 ,1 ]
5885
+ self .state = [False ,False ]
5886
+
5887
+
5888
+ response = Response_Helper ()
5889
+
5890
+ rc = parse_grpc_response_link_and_oper_state (True , response , 0 , "link_state" , "Ethernet4" )
5891
+ assert (rc == ("down" , "down" ))
5892
+
5893
+ def test_parse_grpc_response_link_and_oper_state_up_down_read_side_zero_link_state (self ):
5894
+
5895
+ class Response_Helper ():
5896
+ def __init__ (self ):
5897
+ self .portid = [0 ,1 ]
5898
+ self .state = [True ,False ]
5899
+
5900
+
5901
+ response = Response_Helper ()
5902
+
5903
+ rc = parse_grpc_response_link_and_oper_state (True , response , 0 , "link_state" , "Ethernet4" )
5904
+ assert (rc == ("up" , "down" ))
5905
+
5906
+ def test_parse_grpc_response_link_and_oper_state_up_up_read_side_zero_link_state (self ):
5907
+
5908
+ class Response_Helper ():
5909
+ def __init__ (self ):
5910
+ self .portid = [0 ,1 ]
5911
+ self .state = [True , True ]
5912
+
5913
+
5914
+ response = Response_Helper ()
5915
+
5916
+ rc = parse_grpc_response_link_and_oper_state (True , response , 0 , "link_state" , "Ethernet4" )
5917
+ assert (rc == ("up" , "up" ))
5918
+
5919
+ def test_get_muxcable_info_for_active_active (self ):
5920
+ physical_port = 20
5921
+
5922
+ logical_port_name = "Ethernet20"
5923
+ swsscommon .Table .return_value .get .return_value = (
5924
+ True , {"read_side" : "1" })
5925
+ asic_index = 0
5926
+ y_cable_tbl = {}
5927
+ mux_tbl = {}
5928
+ test_db = "TEST_DB"
5929
+ status = True
5930
+ fvs = [('state' , "auto" ), ('read_side' , 1 )]
5931
+ y_cable_tbl [asic_index ] = swsscommon .Table (
5932
+ test_db [asic_index ], "Y_CABLE_TABLE" )
5933
+ y_cable_tbl [asic_index ].get .return_value = (status , fvs )
5934
+
5935
+ rc = get_muxcable_info_for_active_active (physical_port , logical_port_name , mux_tbl , asic_index , y_cable_tbl )
5936
+
5937
+ assert (rc ['self_mux_direction' ] == 'unknown' )
5938
+ assert (rc ['peer_mux_direction' ] == 'unknown' )
5939
+ assert (rc ['mux_direction_probe_count' ] == 'unknown' )
5940
+ assert (rc ['peer_mux_direction_probe_count' ] == 'unknown' )
0 commit comments