diff --git a/.gitmodules b/.gitmodules index f10d24641..42aae0be4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,4 +5,4 @@ [submodule "test/SAI-Challenger"] path = test/SAI-Challenger url = https://github.com/opencomputeproject/SAI-Challenger - branch = multiple-api-support + branch = main diff --git a/dash-pipeline/Makefile b/dash-pipeline/Makefile index 161ffffa7..20d6b8a45 100644 --- a/dash-pipeline/Makefile +++ b/dash-pipeline/Makefile @@ -592,7 +592,7 @@ DOCKER_SAI_CHALLENGER_CLIENT_BLDR_IMG = $(DOCKER_SAI_CHALLENGER_CLIENT_BLDR_IMG_ docker-saichallenger-client-bldr: { [ x$(ENABLE_DOCKER_PULL) == xy ] && docker pull $(DOCKER_SAI_CHALLENGER_CLIENT_BLDR_IMG); } || \ - { pushd $(SAI_CHALLENGER_PATH) && ./build.sh -i client && popd; \ + { pushd $(SAI_CHALLENGER_PATH) && git submodule update --init && ./build.sh -i client && popd; \ docker build \ -f dockerfiles/Dockerfile.saichallenger-client-bldr \ -t $(DOCKER_SAI_CHALLENGER_CLIENT_BLDR_IMG) \ @@ -609,8 +609,7 @@ docker-publish-saichallenger-client-bldr: docker-pull-saichallenger-client-bldr: docker pull $(DOCKER_SAI_CHALLENGER_CLIENT_BLDR_IMG) -docker-saichallenger-client: - cd $(SAI_CHALLENGER_PATH) && ./build.sh -i client +docker-saichallenger-client: docker-saichallenger-client-bldr docker build \ -f dockerfiles/Dockerfile.saichallenger-client \ -t $(DOCKER_SAI_CHALLENGER_CLIENT_IMG) \ @@ -666,4 +665,4 @@ run-saichallenger-scale-tests: deploy-ixiac install-docker-compose: sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$$(uname -s)-$$(uname -m)" -o /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose \ No newline at end of file + sudo chmod +x /usr/local/bin/docker-compose diff --git a/dash-pipeline/dockerfiles/DOCKER_SAI_CHALLENGER_CLIENT_BLDR_IMG.env b/dash-pipeline/dockerfiles/DOCKER_SAI_CHALLENGER_CLIENT_BLDR_IMG.env index c94dd0dc5..21441e845 100644 --- a/dash-pipeline/dockerfiles/DOCKER_SAI_CHALLENGER_CLIENT_BLDR_IMG.env +++ b/dash-pipeline/dockerfiles/DOCKER_SAI_CHALLENGER_CLIENT_BLDR_IMG.env @@ -2,4 +2,4 @@ # Changing this will cause build/publish to occur in CI actions export DASH_ACR_REGISTRY=sonicdash.azurecr.io export DOCKER_SAI_CHALLENGER_CLIENT_BLDR_IMG_NAME=${DASH_ACR_REGISTRY}/dash-saichallenger-client-bldr -export DOCKER_SAI_CHALLENGER_CLIENT_BLDR_IMG_CTAG?=221209 +export DOCKER_SAI_CHALLENGER_CLIENT_BLDR_IMG_CTAG?=221228 diff --git a/dash-pipeline/dockerfiles/Dockerfile.saichallenger-client b/dash-pipeline/dockerfiles/Dockerfile.saichallenger-client index e7688ff7c..12d5a8b52 100644 --- a/dash-pipeline/dockerfiles/Dockerfile.saichallenger-client +++ b/dash-pipeline/dockerfiles/Dockerfile.saichallenger-client @@ -1,4 +1,4 @@ -FROM sonicdash.azurecr.io/dash-saichallenger-client-bldr:221109 +FROM sonicdash.azurecr.io/dash-saichallenger-client-bldr:221228 ENV SAI_CHALLENGER_PATH /sai-challenger ENV DASH_PATH /dash @@ -20,7 +20,6 @@ RUN cd /saithrift-0.9 && \ rm -rf thrift-0.11.0 && \ cd /SAI/test/ptf && \ python3 setup.py install && \ - ln -s ${SAI_CHALLENGER_PATH} /usr/local/lib/python3.7/dist-packages/saichallenger && \ ln -s ${DASH_PATH}/test/test-cases/scale/saic ${SAI_CHALLENGER_PATH}/dash_tests CMD ["/usr/bin/supervisord"] diff --git a/dash-pipeline/dockerfiles/Dockerfile.saichallenger-client-bldr b/dash-pipeline/dockerfiles/Dockerfile.saichallenger-client-bldr index 74ac210d1..ce25999f3 100644 --- a/dash-pipeline/dockerfiles/Dockerfile.saichallenger-client-bldr +++ b/dash-pipeline/dockerfiles/Dockerfile.saichallenger-client-bldr @@ -1,3 +1,4 @@ +# Requires or something FROM sc-client ADD tests/ /tests/ diff --git a/test/SAI-Challenger b/test/SAI-Challenger index e1f1d5bac..8e608c147 160000 --- a/test/SAI-Challenger +++ b/test/SAI-Challenger @@ -1 +1 @@ -Subproject commit e1f1d5bac518f92dae4d0700931e65a280c7bb99 +Subproject commit 8e608c147442ca92777b32a12867ab9f195ea64e diff --git a/test/test-cases/functional/saic/conftest.py b/test/test-cases/functional/saic/conftest.py index bbd92ecee..e5b67b19d 100644 --- a/test/test-cases/functional/saic/conftest.py +++ b/test/test-cases/functional/saic/conftest.py @@ -1,49 +1,74 @@ -import logging +import os import pytest + +curdir = os.path.dirname(os.path.realpath(__file__)) + from saichallenger.common.sai_dpu import SaiDpu -from saichallenger.common.sai_environment import init_setup +from saichallenger.common.sai_testbed import SaiTestbed def pytest_addoption(parser): parser.addoption("--traffic", action="store_true", default=False, help="run tests with traffic") - parser.addoption("--loglevel", action="store", default='NOTICE', help="syncd logging level") parser.addoption("--setup", action="store", default=None, help="Setup description (Path to the json file).") @pytest.fixture(scope="session") def exec_params(request): - config_param = {} - config_param["setup"] = init_setup(request.config) - config_param["traffic"] = request.config.getoption("--traffic") - config_param["loglevel"] = request.config.getoption("--loglevel") - logging.getLogger().setLevel(getattr(logging, config_param["loglevel"].upper(), "INFO")) + config_param = { + # Generic parameters + "traffic": request.config.getoption("--traffic"), + "testbed": request.config.getoption("--setup"), + } return config_param @pytest.fixture(scope="session") -def dpu(exec_params) -> SaiDpu: - dpu = exec_params["setup"]["DPU"][0] - if dpu is not None: - dpu.reset() - return dpu +def testbed_instance(exec_params): + testbed_json = exec_params.get("testbed", None) + if testbed_json is None: + yield None + else: + testbed = SaiTestbed(f"{curdir}/../..", testbed_json, exec_params["traffic"]) + testbed.init() + yield testbed + testbed.deinit() + + +@pytest.fixture(scope="function") +def testbed(testbed_instance): + if testbed_instance: + testbed_instance.setup() + yield testbed_instance + testbed_instance.teardown() + else: + yield None @pytest.fixture(scope="session") -def dataplane_session(exec_params): - dataplane = exec_params["setup"]["DATAPLANE"][0] - # Set up the dataplane - dataplane.init() - yield dataplane - # Shutdown the dataplane - dataplane.remove() +def dpu(exec_params, testbed_instance) -> SaiDpu: + if len(testbed_instance.dpu) == 1: + return testbed_instance.dpu[0] + return None + + +@pytest.fixture(scope="session") +def dataplane_instance(testbed_instance): + if len(testbed_instance.dataplane) == 1: + yield testbed_instance.dataplane[0] + else: + yield None @pytest.fixture(scope="session") def confgen(): return dpugen.sai.SaiConfig() + @pytest.fixture(scope="function") -def dataplane(dataplane_session): - dataplane_session.setUp() - yield dataplane_session - dataplane_session.tearDown() +def dataplane(dataplane_instance): + if dataplane_instance: + dataplane_instance.setup() + yield dataplane_instance + dataplane_instance.teardown() + else: + yield None diff --git a/test/test-cases/functional/saic/sai_dpu_client_server_ptf.json b/test/test-cases/functional/saic/sai_dpu_client_server_ptf.json index 80c55496a..585c91ca8 100755 --- a/test/test-cases/functional/saic/sai_dpu_client_server_ptf.json +++ b/test/test-cases/functional/saic/sai_dpu_client_server_ptf.json @@ -1,41 +1,30 @@ -{"DPU": [ - { - "alias": "dash", - "asic": "generic", - "target": "bmv2", - "type": null, - "sku": null, - "mode": "client-server", - "sai_server_ip": "127.0.0.1", - "client": { +{ + "dpu": [ + { + "alias": "dash", + "asic": "generic", + "target": "bmv2", + "sku": null, + "client": { "type": "thrift", "config": { - "ip": "127.0.0.1", - "port": "9092" + "ip": "127.0.0.1", + "port": "9092" } - }, - "port_groups": [{"1x10G": "Ethernet0", "init": "1x10G", "alias": 0}, - {"1x10G": "Ethernet1", "init": "1x10G", "alias": 1} - ], - "sai_dataplane": "ptf_nn" - } -], + } + } + ], -"DATAPLANE": [ - { - "alias": "ptf", - "type": "ptf", - "mode": "eth", - "port_groups": [{"10G": "veth1", "init": "10G", "alias": 0}, - {"10G": "veth2", "init": "10G", "alias": 1} - ] - } -], - -"CONNECTIONS": { - "ptf->dash": [[0, 0], - [1, 1] - ] -} + "dataplane": [ + { + "alias": "ptf", + "type": "ptf", + "mode": "eth", + "port_groups": [ + {"alias": 0, "name": "veth1"}, + {"alias": 1, "name": "veth2"} + ] + } + ] } diff --git a/test/test-cases/functional/saic/sai_dpu_client_server_snappi.json b/test/test-cases/functional/saic/sai_dpu_client_server_snappi.json index 67abe70e4..035743583 100755 --- a/test/test-cases/functional/saic/sai_dpu_client_server_snappi.json +++ b/test/test-cases/functional/saic/sai_dpu_client_server_snappi.json @@ -1,42 +1,31 @@ -{"DPU": [ - { - "alias": "dash", - "asic": "generic", - "target": "bmv2", - "type": null, - "sku": null, - "mode": "client-server", - "sai_server_ip": "127.0.0.1", - "client": { +{ + "dpu": [ + { + "alias": "dash", + "asic": "generic", + "target": "bmv2", + "sku": null, + "client": { "type": "thrift", "config": { - "ip": "127.0.0.1", - "port": "9092" + "ip": "127.0.0.1", + "port": "9092" } - }, - "port_groups": [{"1x10G": "Ethernet0", "init": "1x10G", "alias": 0}, - {"1x10G": "Ethernet1", "init": "1x10G", "alias": 1} - ], - "sai_dataplane": "ptf_nn" - } -], + } + } + ], -"DATAPLANE": [ - { - "alias": "ixia", - "type": "snappi", - "mode": "ixia_c", - "controller": "https://127.0.0.1:443", - "port_groups": [{"10G": "veth1", "init": "10G", "alias": 0}, - {"10G": "veth3", "init": "10G", "alias": 1} - ] - } -], - -"CONNECTIONS": { - "ixia->dash": [[0, 0], - [1, 1] - ] -} + "dataplane": [ + { + "alias": "ixia", + "type": "snappi", + "mode": "ixia_c", + "controller": "https://127.0.0.1:443", + "port_groups": [ + {"alias": 0, "name": "veth1", "speed": "10G"}, + {"alias": 1, "name": "veth3", "speed": "10G"} + ] + } + ] } diff --git a/test/test-cases/scale/saic/conftest.py b/test/test-cases/scale/saic/conftest.py index 5832c99dd..e5b67b19d 100644 --- a/test/test-cases/scale/saic/conftest.py +++ b/test/test-cases/scale/saic/conftest.py @@ -1,49 +1,74 @@ -import logging +import os import pytest + +curdir = os.path.dirname(os.path.realpath(__file__)) + from saichallenger.common.sai_dpu import SaiDpu -from saichallenger.common.sai_environment import init_setup +from saichallenger.common.sai_testbed import SaiTestbed def pytest_addoption(parser): parser.addoption("--traffic", action="store_true", default=False, help="run tests with traffic") - parser.addoption("--loglevel", action="store", default='NOTICE', help="syncd logging level") parser.addoption("--setup", action="store", default=None, help="Setup description (Path to the json file).") @pytest.fixture(scope="session") def exec_params(request): - config_param = {} - config_param["setup"] = init_setup(request.config) - config_param["traffic"] = request.config.getoption("--traffic") - config_param["loglevel"] = request.config.getoption("--loglevel") - logging.getLogger().setLevel(getattr(logging, config_param["loglevel"].upper(), "INFO")) + config_param = { + # Generic parameters + "traffic": request.config.getoption("--traffic"), + "testbed": request.config.getoption("--setup"), + } return config_param @pytest.fixture(scope="session") -def dpu(exec_params) -> SaiDpu: - dpu = exec_params["setup"]["DPU"][0] - if dpu is not None: - dpu.reset() - return dpu +def testbed_instance(exec_params): + testbed_json = exec_params.get("testbed", None) + if testbed_json is None: + yield None + else: + testbed = SaiTestbed(f"{curdir}/../..", testbed_json, exec_params["traffic"]) + testbed.init() + yield testbed + testbed.deinit() + + +@pytest.fixture(scope="function") +def testbed(testbed_instance): + if testbed_instance: + testbed_instance.setup() + yield testbed_instance + testbed_instance.teardown() + else: + yield None + + +@pytest.fixture(scope="session") +def dpu(exec_params, testbed_instance) -> SaiDpu: + if len(testbed_instance.dpu) == 1: + return testbed_instance.dpu[0] + return None @pytest.fixture(scope="session") -def dataplane_session(exec_params): - dataplane = exec_params["setup"]["DATAPLANE"][0] - # Set up the dataplane - dataplane.init() - yield dataplane - # Shutdown the dataplane - dataplane.remove() +def dataplane_instance(testbed_instance): + if len(testbed_instance.dataplane) == 1: + yield testbed_instance.dataplane[0] + else: + yield None @pytest.fixture(scope="session") def confgen(): return dpugen.sai.SaiConfig() - + + @pytest.fixture(scope="function") -def dataplane(dataplane_session): - dataplane_session.setUp() - yield dataplane_session - dataplane_session.tearDown() +def dataplane(dataplane_instance): + if dataplane_instance: + dataplane_instance.setup() + yield dataplane_instance + dataplane_instance.teardown() + else: + yield None diff --git a/test/test-cases/scale/saic/dash_helper/vnet2vnet_helper.py b/test/test-cases/scale/saic/dash_helper/vnet2vnet_helper.py index d7cb53ce4..4ae3fe26f 100644 --- a/test/test-cases/scale/saic/dash_helper/vnet2vnet_helper.py +++ b/test/test-cases/scale/saic/dash_helper/vnet2vnet_helper.py @@ -1,5 +1,5 @@ import snappi -import saichallenger.dataplane.traffic_utils as tu +import saichallenger.common.sai_dataplane.utils.traffic_utils as tu from collections import namedtuple diff --git a/test/test-cases/scale/saic/sai_dpu_client_server_ptf.json b/test/test-cases/scale/saic/sai_dpu_client_server_ptf.json index 80c55496a..585c91ca8 100755 --- a/test/test-cases/scale/saic/sai_dpu_client_server_ptf.json +++ b/test/test-cases/scale/saic/sai_dpu_client_server_ptf.json @@ -1,41 +1,30 @@ -{"DPU": [ - { - "alias": "dash", - "asic": "generic", - "target": "bmv2", - "type": null, - "sku": null, - "mode": "client-server", - "sai_server_ip": "127.0.0.1", - "client": { +{ + "dpu": [ + { + "alias": "dash", + "asic": "generic", + "target": "bmv2", + "sku": null, + "client": { "type": "thrift", "config": { - "ip": "127.0.0.1", - "port": "9092" + "ip": "127.0.0.1", + "port": "9092" } - }, - "port_groups": [{"1x10G": "Ethernet0", "init": "1x10G", "alias": 0}, - {"1x10G": "Ethernet1", "init": "1x10G", "alias": 1} - ], - "sai_dataplane": "ptf_nn" - } -], + } + } + ], -"DATAPLANE": [ - { - "alias": "ptf", - "type": "ptf", - "mode": "eth", - "port_groups": [{"10G": "veth1", "init": "10G", "alias": 0}, - {"10G": "veth2", "init": "10G", "alias": 1} - ] - } -], - -"CONNECTIONS": { - "ptf->dash": [[0, 0], - [1, 1] - ] -} + "dataplane": [ + { + "alias": "ptf", + "type": "ptf", + "mode": "eth", + "port_groups": [ + {"alias": 0, "name": "veth1"}, + {"alias": 1, "name": "veth2"} + ] + } + ] } diff --git a/test/test-cases/scale/saic/sai_dpu_client_server_snappi.json b/test/test-cases/scale/saic/sai_dpu_client_server_snappi.json index 67abe70e4..035743583 100755 --- a/test/test-cases/scale/saic/sai_dpu_client_server_snappi.json +++ b/test/test-cases/scale/saic/sai_dpu_client_server_snappi.json @@ -1,42 +1,31 @@ -{"DPU": [ - { - "alias": "dash", - "asic": "generic", - "target": "bmv2", - "type": null, - "sku": null, - "mode": "client-server", - "sai_server_ip": "127.0.0.1", - "client": { +{ + "dpu": [ + { + "alias": "dash", + "asic": "generic", + "target": "bmv2", + "sku": null, + "client": { "type": "thrift", "config": { - "ip": "127.0.0.1", - "port": "9092" + "ip": "127.0.0.1", + "port": "9092" } - }, - "port_groups": [{"1x10G": "Ethernet0", "init": "1x10G", "alias": 0}, - {"1x10G": "Ethernet1", "init": "1x10G", "alias": 1} - ], - "sai_dataplane": "ptf_nn" - } -], + } + } + ], -"DATAPLANE": [ - { - "alias": "ixia", - "type": "snappi", - "mode": "ixia_c", - "controller": "https://127.0.0.1:443", - "port_groups": [{"10G": "veth1", "init": "10G", "alias": 0}, - {"10G": "veth3", "init": "10G", "alias": 1} - ] - } -], - -"CONNECTIONS": { - "ixia->dash": [[0, 0], - [1, 1] - ] -} + "dataplane": [ + { + "alias": "ixia", + "type": "snappi", + "mode": "ixia_c", + "controller": "https://127.0.0.1:443", + "port_groups": [ + {"alias": 0, "name": "veth1", "speed": "10G"}, + {"alias": 1, "name": "veth3", "speed": "10G"} + ] + } + ] } diff --git a/test/test-cases/scale/saic/test_sai_vnet_inbound.py b/test/test-cases/scale/saic/test_sai_vnet_inbound.py index 30fccdd2b..d71488462 100644 --- a/test/test-cases/scale/saic/test_sai_vnet_inbound.py +++ b/test/test-cases/scale/saic/test_sai_vnet_inbound.py @@ -7,10 +7,10 @@ from pprint import pprint import pytest -from saichallenger.dataplane.ptf_testutils import (send_packet, - simple_udp_packet, - simple_vxlan_packet, - verify_packet) +from saichallenger.common.sai_dataplane.utils.ptf_testutils import (send_packet, + simple_udp_packet, + simple_vxlan_packet, + verify_packet) current_file_dir = Path(__file__).parent diff --git a/test/test-cases/scale/saic/test_sai_vnet_outbound_scale.py b/test/test-cases/scale/saic/test_sai_vnet_outbound_scale.py index 3b9e1a242..d282fb4b2 100755 --- a/test/test-cases/scale/saic/test_sai_vnet_outbound_scale.py +++ b/test/test-cases/scale/saic/test_sai_vnet_outbound_scale.py @@ -29,7 +29,7 @@ from pprint import pprint import pytest -import saichallenger.dataplane.snappi.snappi_traffic_utils as stu +import saichallenger.common.sai_dataplane.snappi.snappi_traffic_utils as stu import dash_helper.vnet2vnet_helper as dh current_file_dir = Path(__file__).parent diff --git a/test/test-cases/scale/saic/test_sai_vnet_outbound_simple.py b/test/test-cases/scale/saic/test_sai_vnet_outbound_simple.py index 38f2d352f..effc17dfe 100644 --- a/test/test-cases/scale/saic/test_sai_vnet_outbound_simple.py +++ b/test/test-cases/scale/saic/test_sai_vnet_outbound_simple.py @@ -4,12 +4,12 @@ from pprint import pprint import pytest -import saichallenger.dataplane.snappi.snappi_traffic_utils as stu -from saichallenger.dataplane.ptf_testutils import (send_packet, - simple_udp_packet, - simple_vxlan_packet, - verify_no_other_packets, - verify_packet) +import saichallenger.common.sai_dataplane.snappi.snappi_traffic_utils as stu +from saichallenger.common.sai_dataplane.utils.ptf_testutils import (send_packet, + simple_udp_packet, + simple_vxlan_packet, + verify_no_other_packets, + verify_packet) import dash_helper.vnet2vnet_helper as dh