Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .azure-pipelines/pr_test_scripts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ t0:
- generic_config_updater/test_ecn_config_update.py
- iface_namingmode/test_iface_namingmode.py
- lldp/test_lldp.py
- memory_checker/test_memory_checker.py
- minigraph/test_masked_services.py
- monit/test_monit_status.py
- ntp/test_ntp.py
Expand Down
19 changes: 12 additions & 7 deletions tests/memory_checker/test_memory_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,27 +256,29 @@ def remove_and_restart_container(memory_checker_dut_and_container):
container.post_check()


@pytest.fixture(params=['telemetry'])
def enum_memory_checker_container(request):
return request.param
def get_test_container(duthost):
test_container = "telemetry"
cmd = "docker images | grep -w sonic-gnmi"
if duthost.shell(cmd, module_ignore_errors=True)['rc'] == 0:
test_container = "gnmi"
return test_container


@pytest.fixture
def memory_checker_dut_and_container(duthosts, enum_rand_one_per_hwsku_frontend_hostname,
enum_memory_checker_container):
def memory_checker_dut_and_container(duthosts, enum_rand_one_per_hwsku_frontend_hostname):
"""Perform some checks and return applicable duthost and container name

Args:
duthosts: The fixture returns list of DuTs.
enum_memory_checker_container: Fixture returning the name of the container to test
enum_rand_one_per_hwsku_frontend_hostname: The fixture randomly pick up
a frontend DuT from testbed.

Returns:
(duthost, container)
"""
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
container_name = enum_memory_checker_container

container_name = get_test_container(duthost)
container = MemoryCheckerContainer(container_name, duthost)

pytest_require("Celestica-E1031" not in duthost.facts["hwsku"]
Expand Down Expand Up @@ -399,6 +401,7 @@ class MemoryCheckerContainer(object):
# NOTE: these limits could be computed by reading the monit_$container config
MEMORY_LIMITS = {
'telemetry': 400 * 1024 * 1024,
'gnmi': 400 * 1024 * 1024,
}

def __init__(self, name, duthost):
Expand Down Expand Up @@ -461,6 +464,8 @@ def stop_consume_memory(self):

def get_restart_expected_logre(self):
cap_name = self.name.capitalize()
if self.name == "gnmi":
cap_name = "GNMI"
return [
r".*restart_service.*Restarting service '{}'.*".format(self.name),
r".*Stopping {} container.*".format(cap_name),
Expand Down