From 35f20beb7c1c6c4d422030d76ef447f19cc08958 Mon Sep 17 00:00:00 2001 From: Justin Wong <51811017+justin-wong-ce@users.noreply.github.com> Date: Sun, 8 Dec 2024 23:26:54 -0800 Subject: [PATCH] Fix dualtor t0 mock orch crash (#15628) * Fix orchagent crash when setting up mock dualtor environment for t0 When running dualtor tests on t0 topo, the DUT has to enter a mocked dualtor state. Part of this setup is adding a tunnel table to CONFIG_DB, which involves a Broadcom SAI attribute that is only supported when `sai_tunnel_support=1` is set in `syncd:/etc/sai.d/config.bcm` - this attribute is not set until `apply_peer_switch_table_to_dut()` is run. Changing an unsupported Broadcom SAI attribute will cause orchagent to crash. Fix this issue by first running the setup function `apply_peer_switch_table_to_dut()` that will set `sai_tunnel_support=1`, before adding the tunnel table with `apply_tunnel_table_to_dut()`. * Fix dualtor tests overwriting /etc/sonic/config_db.json When running dualtor tests on a t0 topology, the test will overwrite `/etc/sonic/config_db.json` during the test, causing `config_reload()` at the end of the test to not restore the pre-test state of CONFIG_DB. Fix by adding a fixture to backup `/etc/sonic/config_db.json` before the test, then restore and `config reload -y` it after the test. * Change to reuse old config restore and use running_golden_config source --- tests/common/dualtor/dual_tor_mock.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/common/dualtor/dual_tor_mock.py b/tests/common/dualtor/dual_tor_mock.py index b883d28e6c4..02d70e4f059 100644 --- a/tests/common/dualtor/dual_tor_mock.py +++ b/tests/common/dualtor/dual_tor_mock.py @@ -458,8 +458,8 @@ def apply_mock_dual_tor_tables(request, tbinfo): ''' if is_t0_mocked_dualtor(tbinfo): request.getfixturevalue("apply_mux_cable_table_to_dut") - request.getfixturevalue("apply_tunnel_table_to_dut") request.getfixturevalue("apply_peer_switch_table_to_dut") + request.getfixturevalue("apply_tunnel_table_to_dut") logger.info("Done applying database tables for dual ToR mock") @@ -482,4 +482,4 @@ def cleanup_mocked_configs(duthost, tbinfo): if is_t0_mocked_dualtor(tbinfo): logger.info("Load minigraph to reset the DUT %s", duthost.hostname) - config_reload(duthost, config_source="minigraph", safe_reload=True) + config_reload(duthost, config_source="running_golden_config", safe_reload=True)