Skip to content

Commit

Permalink
Removed obsoleted exec option. Please use "--testbed" instead (openco…
Browse files Browse the repository at this point in the history
…mputeproject#209)

Signed-off-by: Andriy Kokhan <[email protected]>
Signed-off-by: selldinesh <[email protected]>
  • Loading branch information
andriy-kokhan authored and selldinesh committed Oct 16, 2023
1 parent 9996808 commit a590c57
Showing 1 changed file with 25 additions and 97 deletions.
122 changes: 25 additions & 97 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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")
Expand Down

0 comments on commit a590c57

Please sign in to comment.