Merge pull request #1596 from Kamoppl/kamilg/update_tests_dec
Update cli help test and remove duplicated test
This commit is contained in:
commit
f37f5afd7b
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# Copyright(c) 2020-2022 Intel Corporation
|
# Copyright(c) 2020-2022 Intel Corporation
|
||||||
# Copyright(c) 2024 Huawei Technologies
|
# Copyright(c) 2024-2025 Huawei Technologies
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
#
|
#
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ remove_core_help = [
|
|||||||
|
|
||||||
|
|
||||||
remove_inactive_help = [
|
remove_inactive_help = [
|
||||||
r"casadm --remove-inactive --cache-id \<ID\> --core-id \<ID\> \[option\.\.\.\]",
|
r"Usage: casadm --remove-inactive --cache-id \<ID\> --core-id \<ID\> \[option\.\.\.\]",
|
||||||
r"Remove inactive core device from cache instance",
|
r"Remove inactive core device from cache instance",
|
||||||
r"Options that are valid with --remove-inactive are:",
|
r"Options that are valid with --remove-inactive are:",
|
||||||
r"-i --cache-id \<ID\> Identifier of cache instance \<1-16384\>",
|
r"-i --cache-id \<ID\> Identifier of cache instance \<1-16384\>",
|
||||||
|
61
test/functional/tests/cli/test_cli_help.py
Normal file
61
test/functional/tests/cli/test_cli_help.py
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#
|
||||||
|
# Copyright(c) 2020-2022 Intel Corporation
|
||||||
|
# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd.
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
#
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from api.cas.cli_help_messages import *
|
||||||
|
from api.cas.cli_messages import check_stderr_msg, check_stdout_msg
|
||||||
|
from core.test_run import TestRun
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("shortcut", [True, False])
|
||||||
|
def test_cli_help(shortcut):
|
||||||
|
"""
|
||||||
|
title: Test for 'help' command.
|
||||||
|
description: |
|
||||||
|
Verifies that running command with 'help' param displays correct message for each
|
||||||
|
available command.
|
||||||
|
pass_criteria:
|
||||||
|
- Proper help message is displayed for every command.
|
||||||
|
- Proper help message is displayed after running command with wrong param.
|
||||||
|
"""
|
||||||
|
check_list_cmd = [
|
||||||
|
(" -S", " --start-cache", start_cache_help),
|
||||||
|
(None, " --attach-cache", attach_cache_help),
|
||||||
|
(None, " --detach-cache", detach_cache_help),
|
||||||
|
(" -T", " --stop-cache", stop_cache_help),
|
||||||
|
(" -X", " --set-param", set_params_help),
|
||||||
|
(" -G", " --get-param", get_params_help),
|
||||||
|
(" -Q", " --set-cache-mode", set_cache_mode_help),
|
||||||
|
(" -A", " --add-core", add_core_help),
|
||||||
|
(" -R", " --remove-core", remove_core_help),
|
||||||
|
(None, " --remove-inactive", remove_inactive_help),
|
||||||
|
(None, " --remove-detached", remove_detached_help),
|
||||||
|
(" -L", " --list-caches", list_caches_help),
|
||||||
|
(" -P", " --stats", stats_help),
|
||||||
|
(" -Z", " --reset-counters", reset_counters_help),
|
||||||
|
(" -F", " --flush-cache", flush_cache_help),
|
||||||
|
(" -C", " --io-class", ioclass_help),
|
||||||
|
(" -V", " --version", version_help),
|
||||||
|
# (None, " --standby", standby_help),
|
||||||
|
(" -H", " --help", help_help),
|
||||||
|
(None, " --zero-metadata", zero_metadata_help),
|
||||||
|
]
|
||||||
|
help = " -H" if shortcut else " --help"
|
||||||
|
|
||||||
|
with TestRun.step("Run 'help' for every 'casadm' command and check output"):
|
||||||
|
for cmds in check_list_cmd:
|
||||||
|
cmd = cmds[0] if shortcut else cmds[1]
|
||||||
|
|
||||||
|
if cmd:
|
||||||
|
output = TestRun.executor.run("casadm" + cmd + help)
|
||||||
|
check_stdout_msg(output, cmds[-1])
|
||||||
|
|
||||||
|
with TestRun.step("Run 'help' for command that doesn`t exist and check output"):
|
||||||
|
cmd = " -Y" if shortcut else " --yell"
|
||||||
|
output = TestRun.executor.run("casadm" + cmd + help)
|
||||||
|
check_stderr_msg(output, unrecognized_stderr)
|
||||||
|
check_stdout_msg(output, unrecognized_stdout)
|
@ -1,127 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright(c) 2020-2022 Intel Corporation
|
|
||||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
#
|
|
||||||
|
|
||||||
import re
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
from api.cas import casadm
|
|
||||||
from api.cas.casadm_params import OutputFormat
|
|
||||||
from api.cas.cli_help_messages import *
|
|
||||||
from api.cas.cli_messages import check_stderr_msg, check_stdout_msg
|
|
||||||
from core.test_run import TestRun
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("shortcut", [True, False])
|
|
||||||
def test_cli_help(shortcut):
|
|
||||||
"""
|
|
||||||
title: Test for 'help' command.
|
|
||||||
description: Test if help for commands displays.
|
|
||||||
pass_criteria:
|
|
||||||
- Proper help displays for every command.
|
|
||||||
"""
|
|
||||||
TestRun.LOGGER.info("Run 'help' for every 'casadm' command.")
|
|
||||||
output = casadm.help(shortcut)
|
|
||||||
check_stdout_msg(output, casadm_help)
|
|
||||||
|
|
||||||
output = TestRun.executor.run("casadm" + (" -S" if shortcut else " --start-cache")
|
|
||||||
+ (" -H" if shortcut else " --help"))
|
|
||||||
check_stdout_msg(output, start_cache_help)
|
|
||||||
|
|
||||||
output = TestRun.executor.run("casadm" + (" -T" if shortcut else " --stop-cache")
|
|
||||||
+ (" -H" if shortcut else " --help"))
|
|
||||||
check_stdout_msg(output, stop_cache_help)
|
|
||||||
|
|
||||||
output = TestRun.executor.run("casadm" + (" -X" if shortcut else " --set-param")
|
|
||||||
+ (" -H" if shortcut else " --help"))
|
|
||||||
check_stdout_msg(output, set_params_help)
|
|
||||||
|
|
||||||
output = TestRun.executor.run("casadm" + (" -G" if shortcut else " --get-param")
|
|
||||||
+ (" -H" if shortcut else " --help"))
|
|
||||||
check_stdout_msg(output, get_params_help)
|
|
||||||
|
|
||||||
output = TestRun.executor.run("casadm" + (" -Q" if shortcut else " --set-cache-mode")
|
|
||||||
+ (" -H" if shortcut else " --help"))
|
|
||||||
check_stdout_msg(output, set_cache_mode_help)
|
|
||||||
|
|
||||||
output = TestRun.executor.run("casadm" + (" -A" if shortcut else " --add-core")
|
|
||||||
+ (" -H" if shortcut else " --help"))
|
|
||||||
check_stdout_msg(output, add_core_help)
|
|
||||||
|
|
||||||
output = TestRun.executor.run("casadm" + (" -R" if shortcut else " --remove-core")
|
|
||||||
+ (" -H" if shortcut else " --help"))
|
|
||||||
check_stdout_msg(output, remove_core_help)
|
|
||||||
|
|
||||||
output = TestRun.executor.run("casadm" + " --remove-detached"
|
|
||||||
+ (" -H" if shortcut else " --help"))
|
|
||||||
check_stdout_msg(output, remove_detached_help)
|
|
||||||
|
|
||||||
output = TestRun.executor.run("casadm" + (" -L" if shortcut else " --list-caches")
|
|
||||||
+ (" -H" if shortcut else " --help"))
|
|
||||||
check_stdout_msg(output, list_caches_help)
|
|
||||||
|
|
||||||
output = TestRun.executor.run("casadm" + (" -P" if shortcut else " --stats")
|
|
||||||
+ (" -H" if shortcut else " --help"))
|
|
||||||
check_stdout_msg(output, stats_help)
|
|
||||||
|
|
||||||
output = TestRun.executor.run("casadm" + (" -Z" if shortcut else " --reset-counters")
|
|
||||||
+ (" -H" if shortcut else " --help"))
|
|
||||||
check_stdout_msg(output, reset_counters_help)
|
|
||||||
|
|
||||||
output = TestRun.executor.run("casadm" + (" -F" if shortcut else " --flush-cache")
|
|
||||||
+ (" -H" if shortcut else " --help"))
|
|
||||||
check_stdout_msg(output, flush_cache_help)
|
|
||||||
|
|
||||||
output = TestRun.executor.run("casadm" + (" -C" if shortcut else " --io-class")
|
|
||||||
+ (" -H" if shortcut else " --help"))
|
|
||||||
check_stdout_msg(output, ioclass_help)
|
|
||||||
|
|
||||||
output = TestRun.executor.run("casadm" + (" -V" if shortcut else " --version")
|
|
||||||
+ (" -H" if shortcut else " --help"))
|
|
||||||
check_stdout_msg(output, version_help)
|
|
||||||
|
|
||||||
output = TestRun.executor.run("casadm" + (" -H" if shortcut else " --help")
|
|
||||||
+ (" -H" if shortcut else " --help"))
|
|
||||||
check_stdout_msg(output, help_help)
|
|
||||||
|
|
||||||
output = TestRun.executor.run("casadm" + " --standby"
|
|
||||||
+ (" -H" if shortcut else " --help"))
|
|
||||||
check_stdout_msg(output, standby_help)
|
|
||||||
|
|
||||||
output = TestRun.executor.run("casadm" + " --zero-metadata"
|
|
||||||
+ (" -H" if shortcut else " --help"))
|
|
||||||
check_stdout_msg(output, zero_metadata_help)
|
|
||||||
|
|
||||||
output = TestRun.executor.run("casadm" + (" -Y" if shortcut else " --yell")
|
|
||||||
+ (" -H" if shortcut else " --help"))
|
|
||||||
check_stderr_msg(output, unrecognized_stderr)
|
|
||||||
check_stdout_msg(output, unrecognized_stdout)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("output_format", OutputFormat)
|
|
||||||
@pytest.mark.parametrize("shortcut", [True, False])
|
|
||||||
def test_cli_version(shortcut, output_format):
|
|
||||||
"""
|
|
||||||
title: Test for 'version' command.
|
|
||||||
description: Test if version displays.
|
|
||||||
pass_criteria:
|
|
||||||
- Proper OCL's components names displays in table with its versions.
|
|
||||||
"""
|
|
||||||
TestRun.LOGGER.info("Check OCL's version.")
|
|
||||||
output = casadm.print_version(output_format, shortcut).stdout
|
|
||||||
TestRun.LOGGER.info(output)
|
|
||||||
if not names_in_output(output) or not versions_in_output(output):
|
|
||||||
TestRun.fail("'Version' command failed.")
|
|
||||||
|
|
||||||
|
|
||||||
def names_in_output(output):
|
|
||||||
return ("CAS Cache Kernel Module" in output
|
|
||||||
and "CAS CLI Utility" in output)
|
|
||||||
|
|
||||||
|
|
||||||
def versions_in_output(output):
|
|
||||||
version_pattern = re.compile(r"(\d){2}\.(\d){2}\.(\d)\.(\d){4}.(\S)")
|
|
||||||
return len(version_pattern.findall(output)) == 2
|
|
Loading…
Reference in New Issue
Block a user