Skip to content

Commit

Permalink
Support the DVS 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 <[email protected]>
  • Loading branch information
stephenxs committed Dec 3, 2020
1 parent cb78de3 commit 5b89593
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 0 additions & 1 deletion tests/buffer_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pytest
import re
import time

Expand Down
17 changes: 15 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,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 @@ -73,6 +75,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 @@ -229,7 +236,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 @@ -374,6 +382,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 @@ -1497,10 +1509,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 5b89593

Please sign in to comment.