Skip to content

Commit

Permalink
Fix dualtor t0 mock orch crash (#15628)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
justin-wong-ce authored and mssonicbld committed Dec 28, 2024
1 parent 664951b commit bd60fc2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/common/dualtor/dual_tor_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand All @@ -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)

0 comments on commit bd60fc2

Please sign in to comment.