From d45bde563141b51928c211a67faffcd1cf7e3574 Mon Sep 17 00:00:00 2001 From: Yaqiang Zhu Date: Tue, 31 Dec 2024 15:50:17 +0800 Subject: [PATCH] [sanity][bgp] Skip default route missing recover for multi-asic (#16264) What is the motivation for this PR? Default route check in sanity is added by #16235 It only supports single asic for now. But constraint for single asic in recover stage is missed It would cause keyError in multi-asic if there is bgp sanity check failure def adaptive_recover(dut, localhost, fanouthosts, nbrhosts, tbinfo, check_results, wait_time): outstanding_action = None for result in check_results: if result['failed']: if result['check_item'] == 'interfaces': action = _recover_interfaces(dut, fanouthosts, result, wait_time) elif result['check_item'] == 'services': action = _recover_services(dut, result) elif result['check_item'] == 'bgp': # If there is only default route missing issue, only need to re-announce routes to recover > if ("no_v4_default_route" in result['bgp'] and len(result['bgp']) == 1 or "no_v6_default_route" in result['bgp'] and len(result['bgp']) == 1 or ("no_v4_default_route" in result['bgp'] and "no_v6_default_route" in result['bgp'] and len(result['bgp']) == 2)): E KeyError: 'bgp' check_results = [{'bgp0': {'down_neighbors': ['2603:10e2:400:1::5', 'fc00::2']}, 'bgp3': {'down_neighbors': ['2603:10e2:400:1::6']}, 'check_item': 'bgp', 'failed': True, ...}] dut = fanouthosts = {} localhost = nbrhosts = {'ARISTA01T0': , 'ARISTA01T2': } outstanding_action = None result = {'bgp0': {'down_neighbors': ['2603:10e2:400:1::5', 'fc00::2']}, 'bgp3': {'down_neighbors': ['2603:10e2:400:1::6']}, 'check_item': 'bgp', 'failed': True, ...} tbinfo = {'auto_recover': 'False', 'comment': 'Tests multi-asic virtual switch vm', 'conf-name': 'vms-kvm-four-asic-t1-lag', 'duts': ['vlab-08'], ...} wait_time = 30 How did you do it? Add single asic constraint in recover How did you verify/test it? Run test --- tests/common/plugins/sanity_check/recover.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/common/plugins/sanity_check/recover.py b/tests/common/plugins/sanity_check/recover.py index 14fd2ca81f..42a4096d51 100644 --- a/tests/common/plugins/sanity_check/recover.py +++ b/tests/common/plugins/sanity_check/recover.py @@ -163,10 +163,12 @@ def adaptive_recover(dut, localhost, fanouthosts, nbrhosts, tbinfo, check_result action = _recover_services(dut, result) elif result['check_item'] == 'bgp': # If there is only default route missing issue, only need to re-announce routes to recover - if ("no_v4_default_route" in result['bgp'] and len(result['bgp']) == 1 or - "no_v6_default_route" in result['bgp'] and len(result['bgp']) == 1 or + # Currently only support single asic + if (dut.facts["num_asic"] == 1 and + ("no_v4_default_route" in result['bgp'] and len(result['bgp']) == 1 or + "no_v6_default_route" in result['bgp'] and len(result['bgp']) == 1 or ("no_v4_default_route" in result['bgp'] and "no_v6_default_route" in result['bgp'] and - len(result['bgp']) == 2)): + len(result['bgp']) == 2))): action = re_announce_routes(localhost, tbinfo["topo"]["name"], tbinfo["ptf_ip"]) else: action = neighbor_vm_restore(dut, nbrhosts, tbinfo, result)