From ad889ea19e474ba89cd1497bf3ea184d435e2cd4 Mon Sep 17 00:00:00 2001 From: Andriy Kokhan Date: Tue, 3 Oct 2023 11:50:11 +0300 Subject: [PATCH] Removed obsoleted exec option. Please use "--testbed" instead (#209) Signed-off-by: Andriy Kokhan Signed-off-by: selldinesh --- tests/conftest.py | 122 ++++++++++------------------------------------ 1 file changed, 25 insertions(+), 97 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 05ee7384..d5cb609c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -49,13 +49,8 @@ def prev_test_failed(): def pytest_addoption(parser): - parser.addoption("--sai-server", action="store", default='localhost', help="SAI server IP") - 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("--asic", action="store", default=os.getenv('SC_ASIC'), help="ASIC type") - parser.addoption("--target", action="store", default=os.getenv('SC_TARGET'), help="The target device with this NPU") - parser.addoption("--sku", action="store", default=None, help="SKU mode") - parser.addoption("--testbed", action="store", default=None, help="Testbed name") + parser.addoption("--traffic", action="store_false", help="run tests with traffic") + parser.addoption("--testbed", action="store", help="Testbed name", required=True) def pytest_sessionstart(session): @@ -69,119 +64,52 @@ def exec_params(request): # Generic parameters "traffic": request.config.getoption("--traffic"), "testbed": request.config.getoption("--testbed"), - # DUT specific parameters - "alias": "dut", - "asic": request.config.getoption("--asic"), - "target": request.config.getoption("--target"), - "sku": request.config.getoption("--sku"), - "client": { - "type": "redis", - "config": { - "ip": request.config.getoption("--sai-server"), - "port": "6379", - "loglevel": request.config.getoption("--loglevel") - } - } } return config_param @pytest.fixture(scope="session") def testbed_instance(exec_params): - testbed_name = exec_params.get("testbed", None) - if testbed_name is None: - yield None - else: - testbed = SaiTestbed(f"{curdir}/..", testbed_name, exec_params["traffic"]) - testbed.init() - yield testbed - testbed.deinit() + testbed = SaiTestbed(f"{curdir}/..", exec_params["testbed"], 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 + testbed_instance.setup() + yield testbed_instance + testbed_instance.teardown() @pytest.fixture(scope="session") -def npu(exec_params, testbed_instance): - if testbed_instance is not None: - if len(testbed_instance.npu) == 1: - return testbed_instance.npu[0] - return None - - npu = None - exec_params["asic_dir"] = None - - if exec_params["asic"] == "generic": - npu = SaiNpu(exec_params) - else: - npu = SaiTestbed.spawn_asic(f"{curdir}/..", exec_params, "npu") - - if npu is not None: - npu.reset() - return npu +def npu(testbed_instance): + if len(testbed_instance.npu) == 1: + return testbed_instance.npu[0] + return None @pytest.fixture(scope="session") -def dpu(exec_params, testbed_instance): - if testbed_instance is not None: - if len(testbed_instance.dpu) == 1: - return testbed_instance.dpu[0] - return None +def dpu(testbed_instance): + if len(testbed_instance.dpu) == 1: + return testbed_instance.dpu[0] + return None - dpu = None - exec_params["asic_dir"] = None - - if exec_params["asic"] == "generic": - dpu = SaiDpu(exec_params) - else: - dpu = SaiTestbed.spawn_asic(f"{curdir}/..", exec_params, "dpu") - - if dpu is not None: - dpu.reset() - return dpu @pytest.fixture(scope="session") -def phy(exec_params, testbed_instance): - if testbed_instance is not None: - if len(testbed_instance.phy) == 1: - return testbed_instance.phy[0] - return None +def phy(testbed_instance): + if len(testbed_instance.phy) == 1: + return testbed_instance.phy[0] + return None - phy = None - exec_params["asic_dir"] = None - - if exec_params["asic"] == "generic": - phy = SaiPhy(exec_params) - else: - phy = SaiTestbed.spawn_asic(f"{curdir}/..", exec_params, "phy") - - if phy is not None: - phy.reset() - return phy @pytest.fixture(scope="session") -def dataplane_instance(exec_params, testbed_instance): - if testbed_instance is not None: - if len(testbed_instance.dataplane) == 1: - yield testbed_instance.dataplane[0] - else: - yield None +def dataplane_instance(testbed_instance): + if len(testbed_instance.dataplane) == 1: + yield testbed_instance.dataplane[0] else: - cfg = { - "type": "ptf", - "traffic": exec_params["traffic"] - } - dp = SaiTestbed.spawn_dataplane(cfg) - dp.init() - yield dp - dp.deinit() + yield None @pytest.fixture(scope="function")