Skip to content

Commit

Permalink
Support the CLI option by which dynamic buffer model can be enabled
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Sun <stephens@nvidia.com>
  • Loading branch information
stephenxs committed Nov 30, 2020
1 parent c6765b6 commit bfc28a9
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from dvslib import dvs_mirror
from dvslib import dvs_policer

from buffer_model import enable_dynamic_buffer

# FIXME: For the sake of stabilizing the PR pipeline we currently assume there are 32 front-panel
# ports in the system (much like the rest of the test suite). This should be adjusted to accomodate
# a dynamic number of ports. GitHub Issue: Azure/sonic-swss#1384.
Expand Down Expand Up @@ -71,6 +73,11 @@ def pytest_addoption(parser):
default=None,
help="Topology file for the Virtual Chassis Topology")

parser.addoption("--buffer_model",
action="store",
default="traditional",
help="Buffer model")


def random_string(size=4, chars=string.ascii_uppercase + string.digits):
return "".join(random.choice(chars) for x in range(size))
Expand Down Expand Up @@ -221,7 +228,8 @@ def __init__(
forcedvs: bool = None,
vct: str = None,
newctnname: str = None,
ctnmounts: Dict[str, str] = None
ctnmounts: Dict[str, str] = None,
buffer_model: str = None,
):
self.basicd = ["redis-server", "rsyslogd"]
self.swssd = [
Expand Down Expand Up @@ -366,6 +374,10 @@ def __init__(
# Make sure everything is up and running before turning over control to the caller
self.check_ready_status_and_init_db()

# Switch buffer model to dynamic if necessary
if buffer_model == 'dynamic':
enable_dynamic_buffer(self.get_config_db(), self.runcmd)

def destroy(self) -> None:
if self.appldb:
del self.appldb
Expand Down Expand Up @@ -1477,10 +1489,11 @@ def dvs(request) -> DockerVirtualSwitch:
keeptb = request.config.getoption("--keeptb")
imgname = request.config.getoption("--imgname")
max_cpu = request.config.getoption("--max_cpu")
buffer_model = request.config.getoption("--buffer_model")
fakeplatform = getattr(request.module, "DVS_FAKE_PLATFORM", None)
log_path = name if name else request.module.__name__

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

yield dvs

Expand Down

0 comments on commit bfc28a9

Please sign in to comment.