Skip to content

Commit 0b347e0

Browse files
okaravasirraghav-cisco
authored andcommitted
[Chassis] Adding new Tests for Chassis/Multi-ASIC GCU (sonic-net#14887)
Description of PR Summary: This PR adds Multi-ASIC new tests for generic config updater (GCU). The changes of this PR have dependency on below PRs: sonic-net#15182 - merged sonic-net#20913 - open sonic-net#20914 - merged Type of change Bug fix Testbed and Framework(new/improvement) [X ] Test case(new/improvement) Back port request 202012 202205 202305 202311 [X ] 202405 Approach What is the motivation for this PR? To add new tests for Multi-ASIC/Chassis test support for GCU functionality. How did you do it? How did you verify/test it? Verified new tests in t2 testbeds. Signed-off-by: Raghavendran Ramanathan <[email protected]>
1 parent 873b122 commit 0b347e0

8 files changed

Lines changed: 1770 additions & 4 deletions

File tree

tests/common/plugins/conditional_mark/tests_mark_conditions.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2464,6 +2464,12 @@ generic_config_updater:
24642464
conditions:
24652465
- "('t2' == topo_type) and (release in ['201811', '201911', '202012', '202205', '202211', '202305', '202311'])"
24662466

2467+
generic_config_updater/add_cluster/test_add_cluster.py:
2468+
skip:
2469+
reason: This test case either cannot pass or should be skipped on virtual chassis
2470+
conditions:
2471+
- asic_type in ['vs']
2472+
24672473
generic_config_updater/test_bgp_prefix.py::test_bgp_prefix_tc1_suite:
24682474
skip:
24692475
reason: "Cisco 8122 backend compute ai platform is not supported. Skip on VS platform due to low success rate."

tests/common/plugins/conditional_mark/tests_mark_conditions_vs_t2.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,11 @@ everflow/test_everflow_testbed.py:
255255
- asic_type in ['vs'] and 't2' in topo_name
256256
- https://github.com/sonic-net/sonic-mgmt/issues/20257
257257
reason: This test case takes too much time on virtual chassis
258+
generic_config_updater/add_cluster/test_add_cluster.py:
259+
skip:
260+
conditions:
261+
- asic_type in ['vs'] and 't2' in topo_name
262+
reason: This test case either cannot pass or should be skipped on virtual chassis
258263
generic_config_updater/test_bgp_prefix.py:
259264
skip:
260265
conditions:

tests/common/snappi_tests/common_helpers.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
from ipaddress import IPv6Network, IPv6Address
2626
import ipaddress
2727
from random import getrandbits
28+
from tests.common.helpers.assertions import pytest_assert
2829
from tests.common.portstat_utilities import parse_portstat
2930
from collections import defaultdict
3031
from tests.conftest import parse_override
31-
from tests.common.helpers.assertions import pytest_assert
3232
from tests.common.utilities import wait_until
3333

3434
logger = logging.getLogger(__name__)
@@ -1322,12 +1322,13 @@ def start_pfcwd_fwd(duthost, asic_value=None):
13221322
format(asic_value))
13231323

13241324

1325-
def clear_counters(duthost, port):
1325+
def clear_counters(duthost, port=None, namespace=None):
13261326
"""
13271327
Clear PFC, Queuecounters, Drop and generic counters from SONiC CLI.
13281328
Args:
13291329
duthost (Ansible host instance): Device under test
13301330
port (str): port name
1331+
namespace (str): namespace name in case of multi asic duthost
13311332
Returns:
13321333
None
13331334
"""
@@ -1343,8 +1344,15 @@ def clear_counters(duthost, port):
13431344
duthost.command("sonic-clear queue watermark all \n")
13441345

13451346
if (duthost.is_multi_asic):
1346-
asic = duthost.get_port_asic_instance(port).get_asic_namespace()
1347-
duthost.command("sudo ip netns exec {} sonic-clear dropcounters \n".format(asic))
1347+
pytest_assert(
1348+
port or namespace,
1349+
'Cannot clear counters in case of multi asic, either port or namespace needs to be provided.'
1350+
)
1351+
if not namespace:
1352+
namespace = duthost.get_port_asic_instance(port).get_asic_namespace()
1353+
duthost.command("sudo ip netns exec {} sonic-clear dropcounters \n".format(namespace))
1354+
else:
1355+
duthost.command("sonic-clear dropcounters \n")
13481356

13491357

13501358
def get_interface_stats(duthost, port):

tests/generic_config_updater/add_cluster/__init__.py

Whitespace-only changes.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"acl": {
3+
"acl-sets": {
4+
"acl-set": {
5+
"L3_TRANSPORT_TEST": {
6+
"acl-entries": {
7+
"acl-entry": {
8+
"100": {
9+
"actions": {
10+
"config": {
11+
"forwarding-action": "ACCEPT"
12+
}
13+
},
14+
"config": {
15+
"sequence-id": 100
16+
},
17+
"transport": {
18+
"config": {
19+
"source-port": "5000"
20+
}
21+
}
22+
},
23+
"200": {
24+
"actions": {
25+
"config": {
26+
"forwarding-action": "DROP"
27+
}
28+
},
29+
"config": {
30+
"sequence-id": 200
31+
},
32+
"transport": {
33+
"config": {
34+
"destination-port": "8080"
35+
}
36+
}
37+
}
38+
}
39+
}
40+
}
41+
}
42+
}
43+
}
44+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import logging
2+
import pytest
3+
from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload
4+
from tests.common.gu_utils import restore_backup_test_config, save_backup_test_config
5+
6+
logger = logging.getLogger(__name__)
7+
8+
9+
# -----------------------------
10+
# Fixtures that return random values for selected asic namespace, neighbors and cfg data for these selections
11+
# -----------------------------
12+
13+
@pytest.fixture(scope="module")
14+
def enum_rand_one_asic_namespace(enum_rand_one_frontend_asic_index):
15+
return None if enum_rand_one_frontend_asic_index is None else 'asic{}'.format(enum_rand_one_frontend_asic_index)
16+
17+
18+
@pytest.fixture(scope="module")
19+
def config_facts(duthosts, enum_downstream_dut_hostname, enum_rand_one_asic_namespace):
20+
duthost = duthosts[enum_downstream_dut_hostname]
21+
return duthost.config_facts(
22+
host=duthost.hostname, source="running", namespace=enum_rand_one_asic_namespace
23+
)['ansible_facts']
24+
25+
26+
@pytest.fixture(scope="module")
27+
def config_facts_localhost(duthosts, enum_downstream_dut_hostname):
28+
duthost = duthosts[enum_downstream_dut_hostname]
29+
return duthost.config_facts(host=duthost.hostname, source="running", namespace=None)['ansible_facts']
30+
31+
32+
@pytest.fixture(scope="module")
33+
def mg_facts(duthosts, enum_downstream_dut_hostname, enum_rand_one_asic_namespace, tbinfo):
34+
duthost = duthosts[enum_downstream_dut_hostname]
35+
return duthost.get_extended_minigraph_facts(tbinfo, namespace=enum_rand_one_asic_namespace)
36+
37+
38+
@pytest.fixture(scope="module")
39+
def rand_bgp_neigh_ip_name(config_facts):
40+
'''Returns a random bgp neighbor ip, name from the namespace'''
41+
bgp_neighbors = config_facts["BGP_NEIGHBOR"]
42+
random_bgp_neigh_ip = list(bgp_neighbors.keys())[0]
43+
random_bgp_neigh_name = config_facts['BGP_NEIGHBOR'][random_bgp_neigh_ip]['name']
44+
logger.info("rand_bgp_neigh_ip_name : {}, {} "
45+
.format(random_bgp_neigh_ip, random_bgp_neigh_name))
46+
return random_bgp_neigh_ip, random_bgp_neigh_name
47+
48+
49+
# -----------------------------
50+
# Setup Fixtures
51+
# -----------------------------
52+
53+
@pytest.fixture(scope="module", autouse=True)
54+
def setup_env(duthosts, rand_one_dut_front_end_hostname):
55+
"""
56+
Setup/teardown fixture for add cluster test cases.
57+
Args:
58+
duthosts: list of DUTs.
59+
rand_one_dut_front_end_hostname: A random linecard.
60+
"""
61+
62+
duthost = duthosts[rand_one_dut_front_end_hostname]
63+
create_checkpoint(duthost)
64+
save_backup_test_config(duthost, file_postfix="{}_before_add_cluster_test".format(duthost.hostname))
65+
66+
yield
67+
68+
restore_backup_test_config(duthost, file_postfix="{}_before_add_cluster_test".format(duthost.hostname),
69+
config_reload=False)
70+
try:
71+
logger.info("{}:Rolling back to original checkpoint".format(duthost.hostname))
72+
rollback_or_reload(duthost)
73+
finally:
74+
delete_checkpoint(duthost)

0 commit comments

Comments
 (0)