Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dualtor t0 mock orch crash #15628

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion tests/common/dualtor/dual_tor_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
'del_dual_tor_state_from_orchagent',
'is_t0_mocked_dualtor',
'is_mocked_dualtor',
'restore_original_config_db',
'set_mux_state'
]

Expand Down Expand Up @@ -458,8 +459,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 @@ -483,3 +484,23 @@ 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)


@pytest.fixture(scope="module")
def restore_original_config_db(duthost, tbinfo):
'''
Make a config_db.json backup at the start, and restore it at the end.
This fixture should only be executed once as the first priority.
'''
tmp_config_db = ''
if is_t0_mocked_dualtor(tbinfo):
tmp_config_db = duthost.shell("mktemp")['stdout']
logger.info(f"Make config_db.json backup to {tmp_config_db}")
duthost.shell(f"sudo cp /etc/sonic/config_db.json {tmp_config_db}")

yield

if is_t0_mocked_dualtor(tbinfo):
logger.info("Restore config_db.json from backup")
duthost.shell(f"sudo mv {tmp_config_db} /etc/sonic/config_db.json")
config_reload(duthost, safe_reload=True)
3 changes: 3 additions & 0 deletions tests/dualtor/test_orch_stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def config_crm_polling_interval(rand_selected_dut):


def test_change_mux_state(
restore_original_config_db,
apply_mock_dual_tor_tables,
apply_mock_dual_tor_kernel_configs,
rand_selected_dut,
Expand Down Expand Up @@ -217,6 +218,7 @@ def add_neighbors(dut, neighbors, interface):


def test_flap_neighbor_entry_active(
restore_original_config_db,
apply_mock_dual_tor_tables,
apply_mock_dual_tor_kernel_configs,
rand_selected_dut,
Expand Down Expand Up @@ -251,6 +253,7 @@ def test_flap_neighbor_entry_active(


def test_flap_neighbor_entry_standby(
restore_original_config_db,
apply_mock_dual_tor_tables,
apply_mock_dual_tor_kernel_configs,
rand_selected_dut,
Expand Down
3 changes: 2 additions & 1 deletion tests/dualtor/test_orchagent_active_tor_downstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

pytestmark = [
pytest.mark.topology('t0'),
pytest.mark.usefixtures('apply_mock_dual_tor_tables',
pytest.mark.usefixtures('restore_original_config_db',
'apply_mock_dual_tor_tables',
'apply_mock_dual_tor_kernel_configs',
'apply_active_state_to_orchagent',
'run_garp_service',
Expand Down
3 changes: 2 additions & 1 deletion tests/dualtor/test_orchagent_mac_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

pytestmark = [
pytest.mark.topology('t0'),
pytest.mark.usefixtures('apply_mock_dual_tor_tables',
pytest.mark.usefixtures('restore_original_config_db',
'apply_mock_dual_tor_tables',
'apply_mock_dual_tor_kernel_configs',
'run_garp_service',
'run_icmp_responder')
Expand Down
3 changes: 2 additions & 1 deletion tests/dualtor/test_orchagent_standby_tor_downstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@

pytestmark = [
pytest.mark.topology('t0'),
pytest.mark.usefixtures('apply_mock_dual_tor_tables',
pytest.mark.usefixtures('restore_original_config_db',
'apply_mock_dual_tor_tables',
'apply_mock_dual_tor_kernel_configs',
'apply_standby_state_to_orchagent',
'run_garp_service',
Expand Down
4 changes: 2 additions & 2 deletions tests/dualtor/test_standby_tor_upstream_mux_toggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

pytestmark = [
pytest.mark.topology('t0'),
pytest.mark.usefixtures('apply_mock_dual_tor_tables', 'apply_mock_dual_tor_kernel_configs',
'run_garp_service', 'run_icmp_responder')
pytest.mark.usefixtures('restore_original_config_db', 'apply_mock_dual_tor_tables',
'apply_mock_dual_tor_kernel_configs', 'run_garp_service', 'run_icmp_responder')
]

PAUSE_TIME = 10
Expand Down
Loading