Skip to content
Closed
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 tests/kvmtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ test_t0_sonic() {
# TODO: Use a marker to select these tests rather than providing a hard-coded list here.
tgname=t0-sonic
tests="\
platform_tests/cli/test_not_depends_on_database.py \
bgp/test_bgp_fact.py \
macsec/test_macsec.py"

Expand Down
52 changes: 52 additions & 0 deletions tests/platform_tests/cli/test_not_depends_on_database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""
Tests for the `sonic_installer` commands in SONiC
"""
import logging
import paramiko
import pytest
import time

from tests.common.helpers.assertions import pytest_assert
from tests.common.utilities import skip_release, wait_until
from tests.common.platform.processes_utils import wait_critical_processes
from tests.common.config_reload import config_reload

pytestmark = [
pytest.mark.disable_loganalyzer,
pytest.mark.topology('any'),
pytest.mark.device_type('vs')
]

DOCKER_WAIT_TIME = 10

@pytest.fixture(scope='function')
def stop_database_docker(duthosts, enum_rand_one_per_hwsku_hostname):
duthost = duthosts[enum_rand_one_per_hwsku_hostname]

# save config for reload later
duthost.shell('sudo config save -y')

# shutdown database docker before test
duthost.command("sudo docker stop database", module_ignore_errors=True)
time.sleep(DOCKER_WAIT_TIME)

yield

# start database docker after test
duthost.command("sudo docker start database", module_ignore_errors=True)
time.sleep(DOCKER_WAIT_TIME)

# reload config, because some critical process not work after database docker restart
config_reload(duthost, config_source='config_db', safe_reload=True)

def test_installer_not_depends_on_database_docker(duthosts, enum_rand_one_per_hwsku_hostname, stop_database_docker):
"""
@summary: Test sonic-installer command can work when database docker not running
"""
duthost = duthosts[enum_rand_one_per_hwsku_hostname]
skip_release(duthost, ["201811", "201911", "202012", "202106", "202111"])

# test installer command
sonic_installer_result = duthost.command("sudo sonic-installer list")
pytest_assert(sonic_installer_result["stdout_lines"][0].startswith("Current:"),
"sonic-installer command failed, stdout: {}, stderr: {}".format(sonic_installer_result["stdout_lines"], sonic_installer_result["stderr_lines"]))