From 4b26b05b9f97476f78136e77c24e28cb4bbd9ba0 Mon Sep 17 00:00:00 2001 From: Slawomir Jankowski Date: Tue, 7 Apr 2020 13:13:48 +0200 Subject: [PATCH] Rebuild test for *help* command Test all *help* call cases, even wrong. Signed-off-by: Slawomir Jankowski --- test/functional/tests/cli/test_cli_help.py | 22 ---- .../tests/cli/test_cli_help_and_version.py | 100 ++++++++++++++++++ 2 files changed, 100 insertions(+), 22 deletions(-) delete mode 100644 test/functional/tests/cli/test_cli_help.py create mode 100644 test/functional/tests/cli/test_cli_help_and_version.py diff --git a/test/functional/tests/cli/test_cli_help.py b/test/functional/tests/cli/test_cli_help.py deleted file mode 100644 index ebfdb69..0000000 --- a/test/functional/tests/cli/test_cli_help.py +++ /dev/null @@ -1,22 +0,0 @@ -# -# Copyright(c) 2019-2020 Intel Corporation -# SPDX-License-Identifier: BSD-3-Clause-Clear -# - - -import logging -import pytest -from api.cas import casadm - - -LOGGER = logging.getLogger(__name__) - - -@pytest.mark.parametrize("shortcut", [True, False]) -def test_cli_help(shortcut): - LOGGER.info("Test run") - output = casadm.help(shortcut) - LOGGER.info(output.stdout) # TODO:this is tmp, every ssh command shall be logged via executor - assert output.stdout[0:33] == "Cache Acceleration Software Linux" - # TODO: create yml config for every help command and match the output with it - # TODO: for now the assert above is purely for testing flow in the casadm api diff --git a/test/functional/tests/cli/test_cli_help_and_version.py b/test/functional/tests/cli/test_cli_help_and_version.py new file mode 100644 index 0000000..74bf340 --- /dev/null +++ b/test/functional/tests/cli/test_cli_help_and_version.py @@ -0,0 +1,100 @@ +# +# Copyright(c) 2020 Intel Corporation +# SPDX-License-Identifier: BSD-3-Clause-Clear +# + +import pytest +from api.cas import casadm +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_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" + (" -E" if shortcut else " --flush-core") + + (" -H" if shortcut else " --help")) + check_stdout_msg(output, flush_core_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" + (" -N" if shortcut else " --nvme") + + (" -H" if shortcut else " --help")) + check_stdout_msg(output, nvme_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" + " --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)