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
2 changes: 2 additions & 0 deletions tests/kvmtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ test_t0() {
generic_config_updater/test_vlan_interface.py \
process_monitoring/test_critical_process_monitoring.py \
show_techsupport/test_techsupport_no_secret.py \
platform_tests/cli/test_sonic_installer.py \
platform_tests/cli/test_show.py \
system_health/test_system_status.py \
radv/test_radv_ipv6_ra.py"

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

from tests.common.helpers.assertions import pytest_assert
from tests.common.utilities import skip_release
from .test_sonic_installer import stop_database_docker

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

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

# shutdown database docker before test
show_result = duthost.command("sudo show")
pytest_assert(show_result["stdout_lines"][0].startswith("Usage: show"),
"show command failed, stdout: {}, stderr: {}".format(show_result["stdout_lines"], show_result["stderr_lines"]))
52 changes: 52 additions & 0 deletions tests/platform_tests/cli/test_sonic_installer.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
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_sonic_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"])

# shutdown database docker before test
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"]))