Skip to content

Commit

Permalink
Restore the conftest.py
Browse files Browse the repository at this point in the history
  • Loading branch information
xumia committed Jan 11, 2024
1 parent 424db3b commit ce81533
Showing 1 changed file with 5 additions and 31 deletions.
36 changes: 5 additions & 31 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ def pytest_addoption(parser):
default=None,
help="Namespace for the Virtual Chassis Topology")

parser.addoption("--mounts",
action="store",
default=None,
help="Mount options of the container")

parser.addoption("--topo",
action="store",
default=None,
Expand Down Expand Up @@ -399,7 +394,7 @@ def __init__(
vols = {self.mount: {"bind": "/var/run/redis", "mode": "rw"}}
if ctnmounts:
for k, v in ctnmounts.items():
vols[k] = {"bind": v, "mode": "rw"}
vols[k] = v
kwargs["volumes"] = vols

# create virtual switch container
Expand Down Expand Up @@ -1405,8 +1400,7 @@ def __init__(
log_path=None,
max_cpu=2,
forcedvs=None,
topoFile=None,
ctnmounts=None
topoFile=None
):
self.ns = namespace
self.chassbr = "br4chs"
Expand Down Expand Up @@ -1576,8 +1570,6 @@ def create_vct_ctn(self, ctndir):
ctnname = defcfg["hostname"] + "." + self.ns
vol = {}
vol[chassis_config_dir] = {"bind": "/usr/share/sonic/virtual_chassis", "mode": "ro"}
if self.ctnmounts:
vol.update(self.ctnmounts)

# pass self.ns into the vs to be use for vs restarts by swss conftest.
# connection to chassbr is setup by chassis_connect.py within the vs
Expand Down Expand Up @@ -1767,12 +1759,6 @@ def manage_dvs(request) -> str:
buffer_model = request.config.getoption("--buffer_model")
force_recreate = request.config.getoption("--force-recreate-dvs")
graceful_stop = request.config.getoption("--graceful-stop")
mounts = request.config.getoption("--mounts")
ctnmounts = {}
if mounts:
for mount in mounts.split("|"):
items = mount.split(":")
ctnmounts[items[0]] = items[1]

dvs = None
curr_dvs_env = [] # lgtm[py/unused-local-variable]
Expand Down Expand Up @@ -1804,7 +1790,7 @@ def update_dvs(log_path, new_dvs_env=[]):
dvs.get_logs()
dvs.destroy()

dvs = DockerVirtualSwitch(name, imgname, keeptb, new_dvs_env, log_path, max_cpu, forcedvs, buffer_model = buffer_model, ctnmounts=ctnmounts)
dvs = DockerVirtualSwitch(name, imgname, keeptb, new_dvs_env, log_path, max_cpu, forcedvs, buffer_model = buffer_model)

curr_dvs_env = new_dvs_env

Expand Down Expand Up @@ -1853,19 +1839,13 @@ def vst(request):
keeptb = request.config.getoption("--keeptb")
imgname = request.config.getoption("--imgname")
max_cpu = request.config.getoption("--max_cpu")
mounts = request.config.getoption("--mounts")
log_path = vctns if vctns else request.module.__name__
dvs_env = getattr(request.module, "DVS_ENV", [])
if not topo:
# use ecmp topology as default
topo = "virtual_chassis/chassis_supervisor.json"
ctnmounts = {}
if mounts:
for mount in mounts.split("|"):
items = mount.split(":")
ctnmounts[items[0]] = items[1]
vct = DockerVirtualChassisTopology(vctns, imgname, keeptb, dvs_env, log_path, max_cpu,
forcedvs, topo, ctnmounts)
forcedvs, topo)
yield vct
vct.get_logs(request.module.__name__)
vct.destroy()
Expand All @@ -1878,19 +1858,13 @@ def vct(request):
keeptb = request.config.getoption("--keeptb")
imgname = request.config.getoption("--imgname")
max_cpu = request.config.getoption("--max_cpu")
mounts = request.config.getoption("--mounts")
log_path = vctns if vctns else request.module.__name__
dvs_env = getattr(request.module, "DVS_ENV", [])
if not topo:
# use ecmp topology as default
topo = "virtual_chassis/chassis_with_ecmp_neighbors.json"
ctnmounts = {}
if mounts:
for mount in mounts.split("|"):
items = mount.split(":")
ctnmounts[items[0]] = items[1]
vct = DockerVirtualChassisTopology(vctns, imgname, keeptb, dvs_env, log_path, max_cpu,
forcedvs, topo, ctnmounts)
forcedvs, topo)
yield vct
vct.get_logs(request.module.__name__)
vct.destroy()
Expand Down

0 comments on commit ce81533

Please sign in to comment.