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

DPU test cases with GNMI and Protobuf #9238

Merged
merged 18 commits into from
Sep 27, 2023
Merged
6 changes: 6 additions & 0 deletions .azure-pipelines/pr_test_scripts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,16 @@ wan-pub:
- tacacs/test_authorization.py
- tacacs/test_accounting.py

dpu:
- dash/test_dash_vnet.py

specific_param:
t0-sonic:
- name: bgp/test_bgp_fact.py
param: "--neighbor_type=sonic --enable_macsec --macsec_profile=128_SCI,256_XPN_SCI"
# all the test modules under macsec directory
- name: macsec
param: "--neighbor_type=sonic --enable_macsec --macsec_profile=128_SCI,256_XPN_SCI"
dpu:
- name: dash/test_dash_vnet.py
param: " --skip_dataplane_checking "
14 changes: 14 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,20 @@ stages:
MGMT_BRANCH: "master"
SCRIPTS_EXCLUDE: "bgp/test_bgp_fact.py"

- job: dpu_elastictest
displayName: "kvmtest-dpu by Elastictest"
timeoutInMinutes: 240
continueOnError: false
pool: ubuntu-20.04
steps:
- template: .azure-pipelines/run-test-elastictest-template.yml
parameters:
TOPOLOGY: dpu
MIN_WORKER: $(T0_SONIC_INSTANCE_NUM)
MAX_WORKER: $(T0_SONIC_INSTANCE_NUM)
KVM_IMAGE_BRANCH: "master"
MGMT_BRANCH: "master"

# - job: wan_elastictest
# displayName: "kvmtest-wan by Elastictest"
# timeoutInMinutes: 240
Expand Down
45 changes: 43 additions & 2 deletions tests/dash/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
REMOTE_PA_IP, REMOTE_PTF_INTF, REMOTE_PTF_MAC, REMOTE_PA_PREFIX, VNET1_NAME, VNET2_NAME, ROUTING_ACTION, \
ROUTING_ACTION_TYPE, LOOKUP_OVERLAY_IP
from dash_utils import render_template_to_host, apply_swssconfig_file
from gnmi_utils import generate_gnmi_cert, apply_gnmi_cert, recover_gnmi_cert, apply_gnmi_file

logger = logging.getLogger(__name__)

ENABLE_GNMI_API = True
# ENABLE_GNMI_API = False
ganglyu marked this conversation as resolved.
Show resolved Hide resolved


def pytest_addoption(parser):
"""
Expand All @@ -34,6 +38,12 @@ def pytest_addoption(parser):
help="Skip config cleanup after test"
)

parser.addoption(
"--skip_dataplane_checking",
action="store_true",
help="Skip dataplane checking"
)


@pytest.fixture(scope="module")
def config_only(request):
Expand All @@ -50,6 +60,11 @@ def skip_cleanup(request):
return request.config.getoption("--skip_cleanup")


@pytest.fixture(scope="module")
def skip_dataplane_checking(request):
return request.config.getoption("--skip_dataplane_checking")


@pytest.fixture(scope="module")
def config_facts(duthost):
return duthost.config_facts(host=duthost.hostname, source="running")['ansible_facts']
Expand Down Expand Up @@ -126,7 +141,7 @@ def dash_config_info(duthost, config_facts, minigraph_facts):


@pytest.fixture(scope="function")
def apply_config(duthost, skip_config, skip_cleanup):
def apply_config(duthost, ptfhost, skip_config, skip_cleanup):
configs = []
op = "SET"

Expand All @@ -140,7 +155,10 @@ def _apply_config(config_info):
template_name = "{}.j2".format(config)
dest_path = "/tmp/{}.json".format(config)
render_template_to_host(template_name, duthost, dest_path, config_info, op=op)
apply_swssconfig_file(duthost, dest_path)
if ENABLE_GNMI_API is True:
ganglyu marked this conversation as resolved.
Show resolved Hide resolved
apply_gnmi_file(duthost, ptfhost, dest_path)
else:
apply_swssconfig_file(duthost, dest_path)

yield _apply_config

Expand Down Expand Up @@ -202,3 +220,26 @@ def apply_direct_configs(dash_outbound_configs, apply_config):
del dash_outbound_configs[VNET2_NAME]

apply_config(dash_outbound_configs)


@pytest.fixture(scope="module", autouse=True)
def setup_gnmi_server(duthosts, rand_one_dut_hostname, localhost, ptfhost):
if ENABLE_GNMI_API is False:
ganglyu marked this conversation as resolved.
Show resolved Hide resolved
yield
return

duthost = duthosts[rand_one_dut_hostname]
duthost.shell("docker exec gnmi rm /usr/local/yang-models/sonic-dash.yang", module_ignore_errors=True)
ganglyu marked this conversation as resolved.
Show resolved Hide resolved
generate_gnmi_cert(localhost, duthost)
apply_gnmi_cert(duthost, ptfhost)
yield
recover_gnmi_cert(localhost, duthost)


@pytest.fixture(scope="function")
def asic_db_checker(duthost):
def _check_asic_db(tables):
for table in tables:
output = duthost.shell("sonic-db-cli ASIC_DB keys 'ASIC_STATE:{}:*'".format(table))
assert output["stdout"].strip() != "", "No entries found in ASIC_DB table {}".format(table)
yield _check_asic_db
Loading