From 1f6b3dcd2d8f6e44a12b56dd7f5938b2c8445c00 Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Tue, 29 Jul 2025 09:42:15 +0800 Subject: [PATCH] Ignore error during config reload in BGP/QOS/FPC test cases (#19869) * Ignore error during config reload * Fix format issue --------- Co-authored-by: sonicbld --- tests/bgp/test_bgp_suppress_fib.py | 20 +++++++-------- tests/common/helpers/ptf_tests_helper.py | 9 ++++--- tests/pc/test_lag_member_forwarding.py | 5 ++-- tests/qos/test_qos_dscp_mapping.py | 31 +++++++++++++++--------- tests/qos/test_qos_sai.py | 7 +++--- 5 files changed, 41 insertions(+), 31 deletions(-) diff --git a/tests/bgp/test_bgp_suppress_fib.py b/tests/bgp/test_bgp_suppress_fib.py index 476abad9bad..0fe0416c5c0 100644 --- a/tests/bgp/test_bgp_suppress_fib.py +++ b/tests/bgp/test_bgp_suppress_fib.py @@ -317,7 +317,7 @@ def get_port_connected_with_vm(duthost, nbrhosts, vm_type='T0'): return port_list -def setup_vrf_cfg(duthost, cfg_facts, nbrhosts, tbinfo): +def setup_vrf_cfg(duthost, cfg_facts, nbrhosts, tbinfo, loganalyzer): """ Config vrf based configuration """ @@ -354,11 +354,11 @@ def setup_vrf_cfg(duthost, cfg_facts, nbrhosts, tbinfo): duthost.template(src="bgp/vrf_config_db.j2", dest="/tmp/config_db_vrf.json") duthost.shell("cp -f /tmp/config_db_vrf.json /etc/sonic/config_db.json") - config_reload(duthost, safe_reload=True) + config_reload(duthost, safe_reload=True, ignore_loganalyzer=loganalyzer) wait_until(120, 10, 0, check_interface_status, duthost) -def setup_vrf(duthost, nbrhosts, tbinfo): +def setup_vrf(duthost, nbrhosts, tbinfo, loganalyzer): """ Prepare vrf based environment """ @@ -366,7 +366,7 @@ def setup_vrf(duthost, nbrhosts, tbinfo): duthost.shell("mv /etc/sonic/config_db.json /etc/sonic/config_db.json.bak") cfg_t1 = get_cfg_facts(duthost) - setup_vrf_cfg(duthost, cfg_t1, nbrhosts, tbinfo) + setup_vrf_cfg(duthost, cfg_t1, nbrhosts, tbinfo, loganalyzer) def install_route_from_exabgp(operation, ptfip, route_list, port): @@ -715,7 +715,7 @@ def do_and_wait_reboot(duthost, localhost, reboot_type): ) -def param_reboot(request, duthost, localhost): +def param_reboot(request, duthost, localhost, loganalyzer): """ Read reboot_type from option bgp_suppress_fib_reboot_type If reboot_type is reload, do config reload @@ -729,7 +729,7 @@ def param_reboot(request, duthost, localhost): logger.info("Randomly choose {} from reload, cold, warm, fast".format(reboot_type)) if reboot_type == "reload": - config_reload(duthost, safe_reload=True) + config_reload(duthost, safe_reload=True, ignore_loganalyzer=loganalyzer) wait_until(120, 10, 0, check_interface_status, duthost) else: do_and_wait_reboot(duthost, localhost, reboot_type) @@ -822,7 +822,7 @@ def perf_sniffer_prepare(tcpdump_sniffer, duthost, nbrhosts, mg_facts, recv_port @pytest.mark.parametrize("vrf_type", VRF_TYPES) def test_bgp_route_with_suppress(duthost, tbinfo, nbrhosts, ptfadapter, localhost, restore_bgp_suppress_fib, prepare_param, vrf_type, continuous_boot_times, generate_route_and_traffic_data, - request): + request, loganalyzer): asic_name = duthost.get_asic_name() if vrf_type == USER_DEFINED_VRF and asic_name == 'th5': pytest.xfail("vrf testing not supported on TH5") @@ -830,7 +830,7 @@ def test_bgp_route_with_suppress(duthost, tbinfo, nbrhosts, ptfadapter, localhos try: if vrf_type == USER_DEFINED_VRF: with allure.step("Configure user defined vrf"): - setup_vrf(duthost, nbrhosts, tbinfo) + setup_vrf(duthost, nbrhosts, tbinfo, loganalyzer) with allure.step("Prepare needed parameters"): router_mac, mg_facts, ptf_ip, exabgp_port_list, exabgp_port_list_v6, recv_port_list = prepare_param @@ -852,7 +852,7 @@ def test_bgp_route_with_suppress(duthost, tbinfo, nbrhosts, ptfadapter, localhos format(continous_boot_index+1)) with allure.step("Do reload"): - param_reboot(request, duthost, localhost) + param_reboot(request, duthost, localhost, loganalyzer) for exabgp_port, exabgp_port_v6, recv_port in zip(exabgp_port_list, exabgp_port_list_v6, recv_port_list): try: @@ -906,7 +906,7 @@ def test_bgp_route_with_suppress(duthost, tbinfo, nbrhosts, ptfadapter, localhos if vrf_type == USER_DEFINED_VRF: with allure.step("Clean user defined vrf"): duthost.shell("cp -f /etc/sonic/config_db.json.bak /etc/sonic/config_db.json") - config_reload(duthost, safe_reload=True) + config_reload(duthost, safe_reload=True, ignore_loganalyzer=loganalyzer) wait_until(120, 10, 0, check_interface_status, duthost) diff --git a/tests/common/helpers/ptf_tests_helper.py b/tests/common/helpers/ptf_tests_helper.py index 6e894418352..929af709dc5 100644 --- a/tests/common/helpers/ptf_tests_helper.py +++ b/tests/common/helpers/ptf_tests_helper.py @@ -145,7 +145,7 @@ def filter(interface, neighbor, mg_facts, tbinfo): return links -def apply_dscp_cfg_setup(duthost, dscp_mode): +def apply_dscp_cfg_setup(duthost, dscp_mode, loganalyzer): """ Applies the DSCP decap configuration to the DUT. @@ -174,10 +174,11 @@ def apply_dscp_cfg_setup(duthost, dscp_mode): logger.info("DSCP decap mode changed from {} to {} on asic {}".format(default_decap_mode, dscp_mode, asic_id)) logger.info("SETUP: Reload required for dscp decap mode changes to take effect.") - config_reload(duthost, safe_reload=True, check_intf_up_ports=True, wait_for_bgp=True) + config_reload(duthost, safe_reload=True, check_intf_up_ports=True, wait_for_bgp=True, + ignore_loganalyzer=loganalyzer) -def apply_dscp_cfg_teardown(duthost): +def apply_dscp_cfg_teardown(duthost, loganalyzer): """ Removes the previously applied DSCP decap configuration from the DUT. @@ -200,7 +201,7 @@ def apply_dscp_cfg_teardown(duthost): if reload_required: logger.info("TEARDOWN: Reload required for dscp decap mode changes to take effect.") - config_reload(duthost, safe_reload=True) + config_reload(duthost, safe_reload=True, ignore_loganalyzer=loganalyzer) def find_links(duthost, tbinfo, filter): diff --git a/tests/pc/test_lag_member_forwarding.py b/tests/pc/test_lag_member_forwarding.py index 9ceed2a32e9..971b48d6c07 100644 --- a/tests/pc/test_lag_member_forwarding.py +++ b/tests/pc/test_lag_member_forwarding.py @@ -69,7 +69,8 @@ def build_pkt(dest_mac, ip_addr, ttl): return pkt, exp_packet -def test_lag_member_forwarding_packets(duthosts, enum_rand_one_per_hwsku_frontend_hostname, tbinfo, ptfadapter): +def test_lag_member_forwarding_packets(duthosts, enum_rand_one_per_hwsku_frontend_hostname, tbinfo, ptfadapter, + loganalyzer): duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] mg_facts = duthost.get_extended_minigraph_facts(tbinfo) lag_facts = duthost.lag_facts(host=duthost.hostname)['ansible_facts']['lag_facts'] @@ -205,4 +206,4 @@ def built_and_send_tcp_ip_packet(expected): pytest.fail("BGP is still enable on lag disable member for neighbor {}", ip) finally: duthost.shell('rm -f {}'.format(lag_member_file_dir)) - config_reload(duthost, config_source='config_db') + config_reload(duthost, config_source='config_db', ignore_loganalyzer=loganalyzer) diff --git a/tests/qos/test_qos_dscp_mapping.py b/tests/qos/test_qos_dscp_mapping.py index d1632c66b07..1699f99af30 100644 --- a/tests/qos/test_qos_dscp_mapping.py +++ b/tests/qos/test_qos_dscp_mapping.py @@ -154,9 +154,10 @@ class TestQoSSaiDSCPQueueMapping_IPIP_Base(): def _setup_test_params(self, duthost, tbinfo, - downstream_links, # noqa F811 - upstream_links, # noqa F811 - decap_mode): + downstream_links, # noqa: F811 + upstream_links, # noqa: F811 + decap_mode, + loganalyzer): """ Set up test parameters for the DSCP to Queue mapping test for IP-IP packets. @@ -188,7 +189,7 @@ def _setup_test_params(self, dst_mac = duthost.facts["router_mac"] # Setup DSCP decap config on DUT - apply_dscp_cfg_setup(duthost, decap_mode) + apply_dscp_cfg_setup(duthost, decap_mode, loganalyzer) pytest_assert(downlink is not None, "No downlink found") pytest_assert(uplink_ptf_ports is not None, "No uplink found") @@ -346,35 +347,41 @@ def _run_test(self, pytest_assert(not failed_once, "FAIL: Test failed. Please check table for details.") - def _teardown_test(self, duthost): + def _teardown_test(self, duthost, loganalyzer): """ Test teardown Args: duthost (AnsibleHost): The DUT host """ - apply_dscp_cfg_teardown(duthost) + apply_dscp_cfg_teardown(duthost, loganalyzer) def test_dscp_to_queue_mapping_pipe_mode(self, ptfadapter, rand_selected_dut, toggle_all_simulator_ports_to_rand_selected_tor, # noqa F811 setup_standby_ports_on_rand_unselected_tor, - tbinfo, downstream_links, upstream_links, dut_qos_maps_module): # noqa F811 + tbinfo, + downstream_links, upstream_links, dut_qos_maps_module, # noqa: F811 + loganalyzer): """ Test QoS SAI DSCP to queue mapping for IP-IP packets in DSCP "pipe" mode """ duthost = rand_selected_dut - test_params = self._setup_test_params(duthost, tbinfo, downstream_links, upstream_links, "pipe") + test_params = self._setup_test_params(duthost, tbinfo, downstream_links, upstream_links, "pipe", + loganalyzer) self._run_test(ptfadapter, duthost, tbinfo, test_params, dut_qos_maps_module, "pipe") - self._teardown_test(duthost) + self._teardown_test(duthost, loganalyzer) def test_dscp_to_queue_mapping_uniform_mode(self, ptfadapter, rand_selected_dut, toggle_all_simulator_ports_to_rand_selected_tor, # noqa F811 setup_standby_ports_on_rand_unselected_tor, - tbinfo, downstream_links, upstream_links, dut_qos_maps_module): # noqa F811 + tbinfo, + downstream_links, upstream_links, dut_qos_maps_module, # noqa: F811 + loganalyzer): """ Test QoS SAI DSCP to queue mapping for IP-IP packets in DSCP "uniform" mode """ duthost = rand_selected_dut - test_params = self._setup_test_params(duthost, tbinfo, downstream_links, upstream_links, "uniform") + test_params = self._setup_test_params(duthost, tbinfo, downstream_links, upstream_links, "uniform", + loganalyzer) self._run_test(ptfadapter, duthost, tbinfo, test_params, dut_qos_maps_module, "uniform") - self._teardown_test(duthost) + self._teardown_test(duthost, loganalyzer) diff --git a/tests/qos/test_qos_sai.py b/tests/qos/test_qos_sai.py index 66009934429..4f665a3315d 100644 --- a/tests/qos/test_qos_sai.py +++ b/tests/qos/test_qos_sai.py @@ -2065,7 +2065,8 @@ def testQosSaiDscpToPgMapping( @pytest.mark.parametrize("decap_mode", ["uniform", "pipe"]) def testIPIPQosSaiDscpToPgMapping( - self, duthost, ptfhost, dutTestParams, downstream_links, upstream_links, dut_qos_maps, decap_mode # noqa F811 + self, duthost, ptfhost, dutTestParams, downstream_links, upstream_links, dut_qos_maps, decap_mode, # noqa: F811 + loganalyzer ): """ Test QoS SAI DSCP to PG mapping ptf test @@ -2086,7 +2087,7 @@ def testIPIPQosSaiDscpToPgMapping( pytest.skip("Skip this test since separated DSCP_TO_TC_MAP is applied") # Setup DSCP decap config on DUT - apply_dscp_cfg_setup(duthost, decap_mode) + apply_dscp_cfg_setup(duthost, decap_mode, loganalyzer) loopback_ip = get_ipv4_loopback_ip(duthost) downlink = select_random_link(downstream_links) @@ -2128,7 +2129,7 @@ def testIPIPQosSaiDscpToPgMapping( logger.info(tabulate(data, headers=headers)) # Teardown DSCP decap config on DUT - apply_dscp_cfg_teardown(duthost) + apply_dscp_cfg_teardown(duthost, loganalyzer) if local_fail_logs: pytest.fail("Test Failed: {}".format(local_fail_logs))