@@ -611,3 +611,69 @@ def test_check_neighbor_consistency_zero_mac_neighbor(self, mock_log_functions):
611
611
assert res is True
612
612
mock_log_warn .assert_has_calls (expected_log_warn_calls )
613
613
mock_log_error .assert_not_called ()
614
+
615
+ def test_check_neighbor_consistency_zero_mac_expired_neighbor (self , mock_log_functions ):
616
+ mock_log_error , mock_log_warn , _ , _ = mock_log_functions
617
+ neighbors = {"192.168.0.102" : "00:00:00:00:00:00" }
618
+ mux_states = {"Ethernet4" : "active" }
619
+ hw_mux_states = {"Ethernet4" : "active" }
620
+ mac_to_port_name_map = {"ee:86:d8:46:7d:01" : "Ethernet4" }
621
+ asic_route_table = []
622
+ asic_neigh_table = ["{\" ip\" :\" 192.168.0.102\" ,\" rif\" :\" oid:0x6000000000671\" ,\" switch_id\" :\" oid:0x21000000000000\" }" ]
623
+ mux_server_to_port_map = {"192.168.0.2" : "Ethernet4" }
624
+ expected_output = ["192.168.0.102" , "00:00:00:00:00:00" , "N/A" , "N/A" , "N/A" , "yes" , "no" , "consistent" ]
625
+ expected_log_output = tabulate .tabulate (
626
+ [expected_output ],
627
+ headers = dualtor_neighbor_check .NEIGHBOR_ATTRIBUTES ,
628
+ tablefmt = "simple"
629
+ ).split ("\n " )
630
+ expected_log_warn_calls = [call (line ) for line in expected_log_output ]
631
+
632
+ check_results = dualtor_neighbor_check .check_neighbor_consistency (
633
+ neighbors ,
634
+ mux_states ,
635
+ hw_mux_states ,
636
+ mac_to_port_name_map ,
637
+ asic_route_table ,
638
+ asic_neigh_table ,
639
+ mux_server_to_port_map
640
+ )
641
+ res = dualtor_neighbor_check .parse_check_results (check_results )
642
+
643
+ assert res is True
644
+ mock_log_warn .assert_has_calls (expected_log_warn_calls )
645
+ mock_log_error .assert_not_called ()
646
+
647
+ def test_check_neighbor_consistency_inconsistent_zero_mac_neighbor (self , mock_log_functions ):
648
+ mock_log_error , mock_log_warn , _ , _ = mock_log_functions
649
+ neighbors = {"192.168.0.102" : "00:00:00:00:00:00" }
650
+ mux_states = {"Ethernet4" : "active" }
651
+ hw_mux_states = {"Ethernet4" : "active" }
652
+ mac_to_port_name_map = {"ee:86:d8:46:7d:01" : "Ethernet4" }
653
+ asic_route_table = []
654
+ asic_neigh_table = []
655
+ mux_server_to_port_map = {"192.168.0.2" : "Ethernet4" }
656
+ expected_output = ["192.168.0.102" , "00:00:00:00:00:00" , "N/A" , "N/A" , "N/A" , "no" , "no" , "inconsistent" ]
657
+ expected_log_output = tabulate .tabulate (
658
+ [expected_output ],
659
+ headers = dualtor_neighbor_check .NEIGHBOR_ATTRIBUTES ,
660
+ tablefmt = "simple"
661
+ ).split ("\n " )
662
+ expected_log_warn_calls = [call (line ) for line in expected_log_output ]
663
+ expected_log_error_calls = [call ("Found neighbors that are inconsistent with mux states: %s" , ["192.168.0.102" ])]
664
+ expected_log_error_calls .extend ([call (line ) for line in expected_log_output ])
665
+
666
+ check_results = dualtor_neighbor_check .check_neighbor_consistency (
667
+ neighbors ,
668
+ mux_states ,
669
+ hw_mux_states ,
670
+ mac_to_port_name_map ,
671
+ asic_route_table ,
672
+ asic_neigh_table ,
673
+ mux_server_to_port_map
674
+ )
675
+ res = dualtor_neighbor_check .parse_check_results (check_results )
676
+
677
+ assert res is False
678
+ mock_log_warn .assert_has_calls (expected_log_warn_calls )
679
+ mock_log_error .assert_has_calls (expected_log_error_calls )
0 commit comments