|
| 1 | +import pytest |
| 2 | +import logging |
| 3 | +from tests.common.helpers.assertions import pytest_assert |
| 4 | +from tests.ha.ha_utils import set_ha_scope_dead, verify_ha_state, activate_primary_dash_ha, activate_secondary_dash_ha |
| 5 | + |
| 6 | +pytestmark = [ |
| 7 | + pytest.mark.topology("t1-smartswitch-ha") |
| 8 | +] |
| 9 | + |
| 10 | +logger = logging.getLogger(__name__) |
| 11 | + |
| 12 | + |
| 13 | +""" |
| 14 | +The assumption for the test is that duthosts has primary and secondary in this order |
| 15 | +""" |
| 16 | + |
| 17 | + |
| 18 | +def test_ha_states(duthosts, setup_ha_config, setup_dash_ha_from_json, activate_dash_ha_from_json): |
| 19 | + |
| 20 | + """ |
| 21 | + Set primary to dead and verify that it gets to dead state and secondary to standalone |
| 22 | + After that, bring back the primary and verify it was done |
| 23 | + """ |
| 24 | + set_ha_scope_dead(duthosts[0], "vdpu0_0:haset0_0") |
| 25 | + |
| 26 | + pytest_assert(verify_ha_state(duthosts[0], "vdpu0_0:haset0_0", "dead"), |
| 27 | + "Primary HA state is not dead") |
| 28 | + |
| 29 | + pytest_assert(verify_ha_state(duthosts[1], "vdpu1_0:haset0_0", "standalone"), |
| 30 | + "Secondary HA state is not standalone") |
| 31 | + |
| 32 | + pytest_assert(activate_primary_dash_ha(duthosts[0], "vdpu0_0:haset0_0"), |
| 33 | + "Failed to activate HA on primary") |
| 34 | + |
| 35 | + logger.info(f"{duthosts[0].hostname} state transitions OK") |
| 36 | + """ |
| 37 | + Set secondary to dead and verify that it gets to dead state and primary to standalone |
| 38 | + After that, bring back secondary and verify it was done |
| 39 | + """ |
| 40 | + set_ha_scope_dead(duthosts[1], "vdpu1_0:haset0_0") |
| 41 | + |
| 42 | + pytest_assert(verify_ha_state(duthosts[1], "vdpu1_0:haset0_0", "dead"), |
| 43 | + "Secondary HA state is not dead") |
| 44 | + |
| 45 | + pytest_assert(verify_ha_state(duthosts[0], "vdpu0_0:haset0_0", "standalone"), |
| 46 | + "Primary HA state is not standalone") |
| 47 | + |
| 48 | + pytest_assert(activate_secondary_dash_ha(duthosts[1], "vdpu1_0:haset0_0"), |
| 49 | + "Failed to activate HA on secondary") |
| 50 | + |
| 51 | + logger.info(f"{duthosts[1].hostname} state transitions OK") |
0 commit comments