Skip to content

Commit be3a2b2

Browse files
Parameterize gNMI CONFIG DB tests with different VRF binding scenarios
1 parent c9eff9a commit be3a2b2

File tree

13 files changed

+330
-105
lines changed

13 files changed

+330
-105
lines changed

docs/testplan/Container-Upgrade-test-plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ We will have a source testcase file container_upgrade/testcases.json that will h
112112
snmp/test_snmp_loopback.py
113113
gnmi/test_gnmi.py
114114
gnmi/test_gnmi_appIdb.py
115-
gnmi/test_gnmi_configdb.py
116115
gnmi/test_gnmi_countersdb.py
117116
gnmi/test_gnoi_killprocess.py
117+
gnmi/vrf_aware_tests/test_gnmi_configdb.py
118118
]
119119
```
120120

tests/common/helpers/gnmi_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def create_revoked_cert_and_crl(localhost, ptfhost):
181181
localhost.shell(local_command)
182182

183183

184-
def create_gnmi_certs(duthost, localhost, ptfhost):
184+
def create_gnmi_certs(duthost, localhost, ptfhost, dut_ip=None):
185185
'''
186186
Create GNMI client certificates
187187
'''
@@ -214,7 +214,7 @@ def create_gnmi_certs(duthost, localhost, ptfhost):
214214
localhost.shell(local_command)
215215

216216
# Sign server certificate
217-
create_ext_conf(duthost.mgmt_ip, "extfile.cnf")
217+
create_ext_conf(dut_ip or duthost.mgmt_ip, "extfile.cnf")
218218
local_command = "openssl x509 \
219219
-req \
220220
-in gnmiserver.csr \

tests/common/plugins/conditional_mark/tests_mark_conditions.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,34 +2194,34 @@ gnmi:
21942194
conditions:
21952195
- "release in ['202412']"
21962196

2197-
gnmi/test_gnmi_configdb.py:
2197+
gnmi/test_gnoi_killprocess.py:
21982198
skip:
2199-
reason: "This feature is not supported for multi asic. Skipping these test for T2 and multi asic."
2199+
reason: "Test noisy due to restart issue not relevant to GNOI. Disabling them to rewrite."
2200+
2201+
gnmi/test_gnoi_system_reboot.py::test_gnoi_system_reboot_warm:
2202+
skip:
2203+
reason: "Warm reboot should only run on t0 topology but not on dualtor"
22002204
conditions_logical_operator: or
22012205
conditions:
2202-
- "'t2' in topo_name"
2203-
- "is_multi_asic==True"
2206+
- "topo_type not in ['t0']"
2207+
- "topo_name in ['dualtor', 'dualtor-56', 'dualtor-120', 'dualtor-aa', 'dualtor-aa-56', 'dualtor-aa-64-breakout']"
22042208
- "release in ['202412']"
22052209

2206-
gnmi/test_gnmi_configdb.py::test_gnmi_configdb_full_01:
2210+
gnmi/vrf_aware_tests/test_gnmi_configdb.py:
22072211
skip:
2208-
reason: "The test refers to a stale implementation of GNOI.System.Reboot."
2212+
reason: "This feature is not supported for multi asic. Skipping these test for T2 and multi asic."
22092213
conditions_logical_operator: or
22102214
conditions:
2211-
- "https://github.com/sonic-net/sonic-mgmt/issues/17436"
2215+
- "'t2' in topo_name"
2216+
- "is_multi_asic==True"
22122217
- "release in ['202412']"
22132218

2214-
gnmi/test_gnoi_killprocess.py:
2219+
gnmi/vrf_aware_tests/test_gnmi_configdb.py::test_gnmi_configdb_full_01:
22152220
skip:
2216-
reason: "Test noisy due to restart issue not relevant to GNOI. Disabling them to rewrite."
2217-
2218-
gnmi/test_gnoi_system_reboot.py::test_gnoi_system_reboot_warm:
2219-
skip:
2220-
reason: "Warm reboot should only run on t0 topology but not on dualtor"
2221+
reason: "The test refers to a stale implementation of GNOI.System.Reboot."
22212222
conditions_logical_operator: or
22222223
conditions:
2223-
- "topo_type not in ['t0']"
2224-
- "topo_name in ['dualtor', 'dualtor-56', 'dualtor-120', 'dualtor-aa', 'dualtor-aa-56', 'dualtor-aa-64-breakout']"
2224+
- "https://github.com/sonic-net/sonic-mgmt/issues/17436"
22252225
- "release in ['202412']"
22262226

22272227
#######################################

tests/common/plugins/conditional_mark/tests_mark_conditions_sonic_vpp.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -551,87 +551,87 @@ gnmi/test_gnmi_appldb.py::test_gnmi_appldb_01:
551551
#######################################
552552
##### GNMI #####
553553
#######################################
554-
gnmi/test_gnmi_configdb.py::test_gnmi_configdb_full_01:
554+
gnmi/test_gnmi_countersdb.py::test_gnmi_counterdb_streaming_sample_01:
555555
skip:
556556
reason: >
557557
Failed/Errored: To be included
558558
conditions_logical_operator: or
559559
conditions:
560560
- "asic_type in ['vpp']"
561561

562-
gnmi/test_gnmi_configdb.py::test_gnmi_configdb_incremental_01:
562+
gnmi/test_gnmi_countersdb.py::test_gnmi_counterdb_streaming_sample_02:
563563
skip:
564564
reason: >
565565
Failed/Errored: To be included
566566
conditions_logical_operator: or
567567
conditions:
568568
- "asic_type in ['vpp']"
569569

570-
gnmi/test_gnmi_configdb.py::test_gnmi_configdb_incremental_02:
570+
gnmi/test_gnmi_countersdb.py::test_gnmi_output:
571571
skip:
572572
reason: >
573573
Failed/Errored: To be included
574574
conditions_logical_operator: or
575575
conditions:
576576
- "asic_type in ['vpp']"
577577

578-
gnmi/test_gnmi_configdb.py::test_gnmi_configdb_streaming_onchange_01:
578+
gnmi/test_gnmi_countersdb.py::test_gnmi_queue_buffer_cnt:
579579
skip:
580580
reason: >
581581
Failed/Errored: To be included
582582
conditions_logical_operator: or
583583
conditions:
584584
- "asic_type in ['vpp']"
585585

586-
gnmi/test_gnmi_configdb.py::test_gnmi_configdb_streaming_onchange_02:
586+
gnmi/test_gnoi_killprocess.py::test_gnoi_killprocess_then_restart:
587587
skip:
588588
reason: >
589589
Failed/Errored: To be included
590590
conditions_logical_operator: or
591591
conditions:
592592
- "asic_type in ['vpp']"
593593

594-
gnmi/test_gnmi_configdb.py::test_gnmi_configdb_streaming_sample_01:
594+
gnmi/vrf_aware_tests/test_gnmi_configdb.py::test_gnmi_configdb_full_01:
595595
skip:
596596
reason: >
597597
Failed/Errored: To be included
598598
conditions_logical_operator: or
599599
conditions:
600600
- "asic_type in ['vpp']"
601601

602-
gnmi/test_gnmi_countersdb.py::test_gnmi_counterdb_streaming_sample_01:
602+
gnmi/vrf_aware_tests/test_gnmi_configdb.py::test_gnmi_configdb_incremental_01:
603603
skip:
604604
reason: >
605605
Failed/Errored: To be included
606606
conditions_logical_operator: or
607607
conditions:
608608
- "asic_type in ['vpp']"
609609

610-
gnmi/test_gnmi_countersdb.py::test_gnmi_counterdb_streaming_sample_02:
610+
gnmi/vrf_aware_tests/test_gnmi_configdb.py::test_gnmi_configdb_incremental_02:
611611
skip:
612612
reason: >
613613
Failed/Errored: To be included
614614
conditions_logical_operator: or
615615
conditions:
616616
- "asic_type in ['vpp']"
617617

618-
gnmi/test_gnmi_countersdb.py::test_gnmi_output:
618+
gnmi/vrf_aware_tests/test_gnmi_configdb.py::test_gnmi_configdb_streaming_onchange_01:
619619
skip:
620620
reason: >
621621
Failed/Errored: To be included
622622
conditions_logical_operator: or
623623
conditions:
624624
- "asic_type in ['vpp']"
625625

626-
gnmi/test_gnmi_countersdb.py::test_gnmi_queue_buffer_cnt:
626+
gnmi/vrf_aware_tests/test_gnmi_configdb.py::test_gnmi_configdb_streaming_onchange_02:
627627
skip:
628628
reason: >
629629
Failed/Errored: To be included
630630
conditions_logical_operator: or
631631
conditions:
632632
- "asic_type in ['vpp']"
633633

634-
gnmi/test_gnoi_killprocess.py::test_gnoi_killprocess_then_restart:
634+
gnmi/vrf_aware_tests/test_gnmi_configdb.py::test_gnmi_configdb_streaming_sample_01:
635635
skip:
636636
reason: >
637637
Failed/Errored: To be included

tests/common/plugins/conditional_mark/tests_mark_conditions_vs_t2.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,6 @@ gnmi/test_gnmi_appldb.py:
243243
conditions:
244244
- asic_type in ['vs'] and 't2' in topo_name
245245
reason: This test case either cannot pass or should be skipped on virtual chassis
246-
gnmi/test_gnmi_configdb.py:
247-
skip:
248-
conditions:
249-
- asic_type in ['vs'] and 't2' in topo_name
250-
reason: This test case either cannot pass or should be skipped on virtual chassis
251246
gnmi/test_gnmi_countersdb.py:
252247
skip:
253248
conditions:
@@ -298,6 +293,11 @@ gnmi/test_mimic_hwproxy_cert_rotation.py:
298293
conditions:
299294
- asic_type in ['vs'] and 't2' in topo_name
300295
reason: This test case either cannot pass or should be skipped on virtual chassis
296+
gnmi/vrf_aware_tests/test_gnmi_configdb.py:
297+
skip:
298+
conditions:
299+
- asic_type in ['vs'] and 't2' in topo_name
300+
reason: This test case either cannot pass or should be skipped on virtual chassis
301301
golden_config_infra/test_config_reload_with_rendered_golden_config.py:
302302
skip:
303303
conditions:

tests/common/utilities.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
# Wait 300 seconds because sometime 'interfaces-config' service take 45 seconds to response
5050
# interfaces-config service issue track by: https://github.com/sonic-net/sonic-buildimage/issues/19045
5151
FILE_CHANGE_TIMEOUT = 300
52+
DEFAULT_VRF_NAME = "default"
53+
MGMT_VRF_NAME = "mgmt"
5254

5355
NON_USER_CONFIG_TABLES = ["FLEX_COUNTER_TABLE", "ASIC_SENSORS", "LOGGER"]
5456

tests/container_upgrade/testcases.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"bmp/test_bmp_statedb.py": 0,
66
"bmp/test_docker_restart.py": 0,
77
"gnmi/test_gnmi.py": 0,
8-
"gnmi/test_gnmi_configdb.py": 0,
8+
"gnmi/vrf_aware_tests/test_gnmi_configdb.py": 0,
99
"gnmi/test_gnmi_appldb.py": 0,
1010
"telemetry/test_telemetry.py::test_config_db_parameters": 0,
1111
"tacacs/test_accounting.py": 3

tests/gnmi/conftest.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
from tests.common.helpers.assertions import pytest_require as pyrequire
1111
from tests.common.helpers.dut_utils import check_container_state
12-
from tests.gnmi.helper import gnmi_container, apply_cert_config, recover_cert_config
12+
from tests.common.helpers.gnmi_utils import gnmi_container
13+
from tests.gnmi.helper import apply_cert_config, recover_cert_config
1314
from tests.gnmi.helper import GNMI_SERVER_START_WAIT_TIME, check_ntp_sync_status
1415
from tests.common.gu_utils import create_checkpoint, rollback
1516
from tests.common.helpers.gnmi_utils import GNMIEnvironment, create_revoked_cert_and_crl, \
@@ -20,6 +21,24 @@
2021
logger = logging.getLogger(__name__)
2122
SETUP_ENV_CP = "test_setup_checkpoint"
2223

24+
VRF_SCENARIOS = [
25+
{"name": "default_1", "vrf": None, "description": "Default (no VRF)"},
26+
]
27+
28+
29+
@pytest.fixture(scope="module", params=VRF_SCENARIOS, ids=lambda scenario: f"vrf_{scenario['name']}")
30+
def vrf_config(request):
31+
return request.param
32+
33+
34+
@pytest.fixture(scope="module", autouse=True)
35+
def setup_vrf_configuration(vrf_config):
36+
"""
37+
This fixture runs before setup_gnmi_server to ensure VRF config is in place.
38+
It gets overridden in vrf_aware_tests/conftest.py.
39+
"""
40+
return vrf_config
41+
2342

2443
@pytest.fixture(scope="function", autouse=True)
2544
def skip_non_x86_platform(duthosts, rand_one_dut_hostname):
@@ -63,7 +82,7 @@ def setup_gnmi_ntp_client_server(duthosts, rand_one_dut_hostname, ptfhost):
6382

6483

6584
@pytest.fixture(scope="module", autouse=True)
66-
def setup_gnmi_server(duthosts, rand_one_dut_hostname, localhost, ptfhost):
85+
def setup_gnmi_server(duthosts, rand_one_dut_hostname, localhost, ptfhost, vrf_config, setup_vrf_configuration):
6786
'''
6887
Setup GNMI server with client certificates
6988
'''
@@ -74,10 +93,10 @@ def setup_gnmi_server(duthosts, rand_one_dut_hostname, localhost, ptfhost):
7493
check_container_state(duthost, gnmi_container(duthost), should_be_running=True),
7594
"Test was not supported on devices which do not support GNMI!")
7695

77-
create_gnmi_certs(duthost, localhost, ptfhost)
96+
create_gnmi_certs(duthost, localhost, ptfhost, dut_ip=vrf_config.get("dut_ip"))
7897

7998
create_checkpoint(duthost, SETUP_ENV_CP)
80-
apply_cert_config(duthost)
99+
apply_cert_config(duthost, vrf_config.get("vrf"))
81100

82101
yield
83102

@@ -92,7 +111,7 @@ def setup_gnmi_server(duthosts, rand_one_dut_hostname, localhost, ptfhost):
92111

93112

94113
@pytest.fixture(scope="module", autouse=True)
95-
def setup_gnmi_rotated_server(duthosts, rand_one_dut_hostname, localhost, ptfhost):
114+
def setup_gnmi_rotated_server(duthosts, rand_one_dut_hostname, localhost, ptfhost, vrf_config={}):
96115
'''
97116
Create GNMI client certificates
98117
'''
@@ -133,7 +152,8 @@ def setup_gnmi_rotated_server(duthosts, rand_one_dut_hostname, localhost, ptfhos
133152
localhost.shell(local_command)
134153

135154
# Sign server certificate
136-
create_ext_conf(duthost.mgmt_ip, "extfile.cnf")
155+
dut_ip = vrf_config.get("dut_ip") or duthost.mgmt_ip
156+
create_ext_conf(dut_ip, "extfile.cnf")
137157
local_command = "openssl x509 \
138158
-req \
139159
-in gnmiserver.csr \

0 commit comments

Comments
 (0)