Skip to content

Commit

Permalink
[vstest]: add --imgname option to specify vs image to test (#996)
Browse files Browse the repository at this point in the history
default image is docker-sonic-vs:latest

Signed-off-by: Guohan Lu <gulv@microsoft.com>
  • Loading branch information
lguohan authored Jul 27, 2019
1 parent cadc5bd commit 5c54393
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def pytest_addoption(parser):
help="dvs name")
parser.addoption("--keeptb", action="store_true", default=False,
help="keep testbed after test")
parser.addoption("--imgname", action="store", default="docker-sonic-vs",
help="image name")

class AsicDbValidator(object):
def __init__(self, dvs):
Expand Down Expand Up @@ -142,7 +144,7 @@ def runcmd_output(self, cmd):
return subprocess.check_output("ip netns exec %s %s" % (self.nsname, cmd), shell=True)

class DockerVirtualSwitch(object):
def __init__(self, name=None, keeptb=False, fakeplatform=None):
def __init__(self, name=None, imgname=None, keeptb=False, fakeplatform=None):
self.basicd = ['redis-server',
'rsyslogd']
self.swssd = ['orchagent',
Expand Down Expand Up @@ -214,7 +216,7 @@ def __init__(self, name=None, keeptb=False, fakeplatform=None):
self.environment = ["fake_platform={}".format(fakeplatform)] if fakeplatform else []

# create virtual switch container
self.ctn = self.client.containers.run('docker-sonic-vs', privileged=True, detach=True,
self.ctn = self.client.containers.run(imgname, privileged=True, detach=True,
environment=self.environment,
network_mode="container:%s" % self.ctn_sw.name,
volumes={ self.mount: { 'bind': '/var/run/redis', 'mode': 'rw' } })
Expand Down Expand Up @@ -794,8 +796,9 @@ def setReadOnlyAttr(self, obj, attr, val):
def dvs(request):
name = request.config.getoption("--dvsname")
keeptb = request.config.getoption("--keeptb")
imgname = request.config.getoption("--imgname")
fakeplatform = getattr(request.module, "DVS_FAKE_PLATFORM", None)
dvs = DockerVirtualSwitch(name, keeptb, fakeplatform)
dvs = DockerVirtualSwitch(name, imgname, keeptb, fakeplatform)
yield dvs
if name == None:
dvs.get_logs(request.module.__name__)
Expand Down

0 comments on commit 5c54393

Please sign in to comment.