Skip to content

Commit f048cef

Browse files
committed
add the HA states test without traffic
Signed-off-by: Mihut Aronovici <aronovic@cisco.com>
1 parent faea291 commit f048cef

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

tests/ha/ha_utils.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,27 @@
88
logger = logging.getLogger(__name__)
99

1010

11+
def set_ha_scope_dead(duthost, scope_key):
12+
"""
13+
Set DASH_HA_SCOPE_CONFIG_TABLE entry to "dead" state
14+
scope_key example: vdpu0_0:haset0_0
15+
"""
16+
17+
fields = {
18+
"version": "1",
19+
"disabled": "true",
20+
"desired_ha_state": "dead",
21+
"ha_set_id": "haset0_0",
22+
"owner": "dpu",
23+
}
24+
proto_utils_hset(
25+
duthost,
26+
table="DASH_HA_SCOPE_CONFIG_TABLE",
27+
key=scope_key,
28+
args=build_dash_ha_scope_args(fields),
29+
)
30+
31+
1132
def build_dash_ha_scope_args(fields):
1233
"""
1334
Build args for DASH_HA_SCOPE_CONFIG_TABLE

tests/ha/test_ha_states.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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

Comments
 (0)