[Docs] improve cli docs
* add docstring for `rally-manage db recreate`. * updates `deprecated_args` to handle release and alternative arg. * rename `--verification` and `task` to `--uuid` in `rally verify use` and `rally task use`.(these arguments should have the same name across one category). The old names are deprecated. * rename destination of `--uuid`, `--uuid-1`, `uuid-2` arguments to `verification`, `verification1`, `verification2` for consistent with other destinations. * remove `required=False` attribute setting for task_id in `rally task use`. * fix attribute name in `default_from_global` for `report` Change-Id: Ib2edb32443f59f8168ff124bddb77950881dcd5e
This commit is contained in:
parent
118019a5b6
commit
8a75a175aa
@ -44,7 +44,7 @@ _rally()
|
|||||||
OPTS["task_sla_check"]="--uuid --json"
|
OPTS["task_sla_check"]="--uuid --json"
|
||||||
OPTS["task_start"]="--deployment --task --task-args --task-args-file --tag --no-use --abort-on-sla-failure"
|
OPTS["task_start"]="--deployment --task --task-args --task-args-file --tag --no-use --abort-on-sla-failure"
|
||||||
OPTS["task_status"]="--uuid"
|
OPTS["task_status"]="--uuid"
|
||||||
OPTS["task_use"]="--task"
|
OPTS["task_use"]="--uuid"
|
||||||
OPTS["task_validate"]="--deployment --task --task-args --task-args-file"
|
OPTS["task_validate"]="--deployment --task --task-args --task-args-file"
|
||||||
OPTS["verify_compare"]="--uuid-1 --uuid-2 --csv --html --json --output-file --threshold"
|
OPTS["verify_compare"]="--uuid-1 --uuid-2 --csv --html --json --output-file --threshold"
|
||||||
OPTS["verify_detailed"]="--uuid --sort-by"
|
OPTS["verify_detailed"]="--uuid --sort-by"
|
||||||
@ -58,7 +58,7 @@ _rally()
|
|||||||
OPTS["verify_showconfig"]="--deployment"
|
OPTS["verify_showconfig"]="--deployment"
|
||||||
OPTS["verify_start"]="--deployment --set --regex --tests-file --tempest-config --xfails-file --no-use --system-wide --concurrency"
|
OPTS["verify_start"]="--deployment --set --regex --tests-file --tempest-config --xfails-file --no-use --system-wide --concurrency"
|
||||||
OPTS["verify_uninstall"]="--deployment"
|
OPTS["verify_uninstall"]="--deployment"
|
||||||
OPTS["verify_use"]="--verification"
|
OPTS["verify_use"]="--uuid"
|
||||||
|
|
||||||
for OPT in ${!OPTS[*]} ; do
|
for OPT in ${!OPTS[*]} ; do
|
||||||
CMD=${OPT%%_*}
|
CMD=${OPT%%_*}
|
||||||
|
@ -326,12 +326,19 @@ def alias(command_name):
|
|||||||
|
|
||||||
def deprecated_args(*args, **kwargs):
|
def deprecated_args(*args, **kwargs):
|
||||||
def _decorator(func):
|
def _decorator(func):
|
||||||
|
if "release" not in kwargs:
|
||||||
|
raise ValueError("'release' is required keyword argument of "
|
||||||
|
"'deprecated_args' decorator.")
|
||||||
func.__dict__.setdefault("args", []).insert(0, (args, kwargs))
|
func.__dict__.setdefault("args", []).insert(0, (args, kwargs))
|
||||||
func.__dict__.setdefault("deprecated_args", [])
|
func.__dict__.setdefault("deprecated_args", [])
|
||||||
func.deprecated_args.append(args[0])
|
func.deprecated_args.append(args[0])
|
||||||
if "help" in kwargs.keys():
|
|
||||||
warn_message = "DEPRECATED!"
|
help_msg = "[Deprecated since Rally %s] " % kwargs.pop("release")
|
||||||
kwargs["help"] = " ".join([warn_message, kwargs["help"]])
|
if "alternative" in kwargs:
|
||||||
|
help_msg += "Use '%s' instead. " % kwargs.pop("alternative")
|
||||||
|
if "help" in kwargs:
|
||||||
|
help_msg += kwargs["help"]
|
||||||
|
kwargs["help"] = help_msg
|
||||||
return func
|
return func
|
||||||
return _decorator
|
return _decorator
|
||||||
|
|
||||||
|
@ -574,7 +574,7 @@ class TaskCommands(object):
|
|||||||
@cliutils.args("--junit", dest="out_format",
|
@cliutils.args("--junit", dest="out_format",
|
||||||
action="store_const", const="junit",
|
action="store_const", const="junit",
|
||||||
help="Generate the report in the JUnit format.")
|
help="Generate the report in the JUnit format.")
|
||||||
@envutils.default_from_global("tasks", envutils.ENV_TASK, "uuid")
|
@envutils.default_from_global("tasks", envutils.ENV_TASK, "tasks")
|
||||||
@cliutils.suppress_warnings
|
@cliutils.suppress_warnings
|
||||||
def report(self, tasks=None, out=None, open_it=False, out_format="html"):
|
def report(self, tasks=None, out=None, open_it=False, out_format="html"):
|
||||||
"""Generate report file for specified task.
|
"""Generate report file for specified task.
|
||||||
@ -717,13 +717,15 @@ class TaskCommands(object):
|
|||||||
"status", "detail"))
|
"status", "detail"))
|
||||||
return failed_criteria
|
return failed_criteria
|
||||||
|
|
||||||
@cliutils.args("--task", type=str, dest="task", required=False,
|
@cliutils.args("--uuid", type=str, dest="task_id",
|
||||||
help="UUID of the task")
|
help="UUID of the task")
|
||||||
def use(self, task):
|
@cliutils.deprecated_args("--task", dest="task_id", type=str,
|
||||||
|
release="0.2.0", alternative="--uuid")
|
||||||
|
def use(self, task_id):
|
||||||
"""Set active task.
|
"""Set active task.
|
||||||
|
|
||||||
:param task: Task uuid.
|
:param task_id: Task uuid.
|
||||||
"""
|
"""
|
||||||
print("Using task: %s" % task)
|
print("Using task: %s" % task_id)
|
||||||
api.Task.get(task)
|
api.Task.get(task_id)
|
||||||
fileutils.update_globals_file("RALLY_TASK", task)
|
fileutils.update_globals_file("RALLY_TASK", task_id)
|
||||||
|
@ -70,8 +70,8 @@ class VerifyCommands(object):
|
|||||||
"the local env!",
|
"the local env!",
|
||||||
required=False, action="store_true")
|
required=False, action="store_true")
|
||||||
@cliutils.deprecated_args("--system-wide-install", dest="system_wide",
|
@cliutils.deprecated_args("--system-wide-install", dest="system_wide",
|
||||||
help="Use --system-wide instead",
|
required=False, action="store_true",
|
||||||
required=False, action="store_true")
|
release="0.1.2", alternative="--system-wide")
|
||||||
@cliutils.args("--concurrency", dest="concur", type=int, required=False,
|
@cliutils.args("--concurrency", dest="concur", type=int, required=False,
|
||||||
help="How many processes to use to run Tempest tests. "
|
help="How many processes to use to run Tempest tests. "
|
||||||
"The default value (0) auto-detects your CPU count")
|
"The default value (0) auto-detects your CPU count")
|
||||||
@ -183,7 +183,7 @@ class VerifyCommands(object):
|
|||||||
print(_("No verification was started yet. "
|
print(_("No verification was started yet. "
|
||||||
"To start verification use:\nrally verify start"))
|
"To start verification use:\nrally verify start"))
|
||||||
|
|
||||||
@cliutils.args("--uuid", type=str, dest="verification_uuid",
|
@cliutils.args("--uuid", type=str, dest="verification",
|
||||||
help="UUID of a verification")
|
help="UUID of a verification")
|
||||||
@cliutils.args("--html", action="store_true", dest="output_html",
|
@cliutils.args("--html", action="store_true", dest="output_html",
|
||||||
help="Display results in HTML format")
|
help="Display results in HTML format")
|
||||||
@ -194,17 +194,17 @@ class VerifyCommands(object):
|
|||||||
help="Path to a file to save results")
|
help="Path to a file to save results")
|
||||||
@envutils.with_default_verification_id
|
@envutils.with_default_verification_id
|
||||||
@cliutils.suppress_warnings
|
@cliutils.suppress_warnings
|
||||||
def results(self, verification_uuid=None, output_file=None,
|
def results(self, verification=None, output_file=None,
|
||||||
output_html=None, output_json=None):
|
output_html=None, output_json=None):
|
||||||
"""Display results of a verification.
|
"""Display results of a verification.
|
||||||
|
|
||||||
:param verification_uuid: UUID of a verification
|
:param verification: UUID of a verification
|
||||||
:param output_file: Path to a file to save results
|
:param output_file: Path to a file to save results
|
||||||
:param output_html: Display results in HTML format
|
:param output_html: Display results in HTML format
|
||||||
:param output_json: Display results in JSON format (Default)
|
:param output_json: Display results in JSON format (Default)
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
results = api.Verification.get(verification_uuid).get_results()
|
results = api.Verification.get(verification).get_results()
|
||||||
except exceptions.NotFoundException as e:
|
except exceptions.NotFoundException as e:
|
||||||
print(six.text_type(e))
|
print(six.text_type(e))
|
||||||
return 1
|
return 1
|
||||||
@ -225,7 +225,7 @@ class VerifyCommands(object):
|
|||||||
else:
|
else:
|
||||||
print(result)
|
print(result)
|
||||||
|
|
||||||
@cliutils.args("--uuid", dest="verification_uuid", type=str,
|
@cliutils.args("--uuid", dest="verification", type=str,
|
||||||
required=False,
|
required=False,
|
||||||
help="UUID of a verification")
|
help="UUID of a verification")
|
||||||
@cliutils.args("--sort-by", dest="sort_by", type=str, required=False,
|
@cliutils.args("--sort-by", dest="sort_by", type=str, required=False,
|
||||||
@ -234,10 +234,10 @@ class VerifyCommands(object):
|
|||||||
required=False,
|
required=False,
|
||||||
help="Display detailed errors of failed tests")
|
help="Display detailed errors of failed tests")
|
||||||
@envutils.with_default_verification_id
|
@envutils.with_default_verification_id
|
||||||
def show(self, verification_uuid=None, sort_by="name", detailed=False):
|
def show(self, verification=None, sort_by="name", detailed=False):
|
||||||
"""Display results table of a verification.
|
"""Display results table of a verification.
|
||||||
|
|
||||||
:param verification_uuid: UUID of a verification
|
:param verification: UUID of a verification
|
||||||
:param sort_by: Sort results by 'name' or 'duration'
|
:param sort_by: Sort results by 'name' or 'duration'
|
||||||
:param detailed: Display detailed errors of failed tests
|
:param detailed: Display detailed errors of failed tests
|
||||||
"""
|
"""
|
||||||
@ -248,7 +248,7 @@ class VerifyCommands(object):
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
verification = api.Verification.get(verification_uuid)
|
verification = api.Verification.get(verification)
|
||||||
tests = verification.get_results()
|
tests = verification.get_results()
|
||||||
except exceptions.NotFoundException as e:
|
except exceptions.NotFoundException as e:
|
||||||
print(six.text_type(e))
|
print(six.text_type(e))
|
||||||
@ -278,22 +278,22 @@ class VerifyCommands(object):
|
|||||||
"log": test["traceback"]}
|
"log": test["traceback"]}
|
||||||
print(formatted_test)
|
print(formatted_test)
|
||||||
|
|
||||||
@cliutils.args("--uuid", dest="verification_uuid", type=str,
|
@cliutils.args("--uuid", dest="verification", type=str,
|
||||||
required=False, help="UUID of a verification")
|
required=False, help="UUID of a verification")
|
||||||
@cliutils.args("--sort-by", dest="sort_by", type=str, required=False,
|
@cliutils.args("--sort-by", dest="sort_by", type=str, required=False,
|
||||||
help="Sort results by 'name' or 'duration'")
|
help="Sort results by 'name' or 'duration'")
|
||||||
@envutils.with_default_verification_id
|
@envutils.with_default_verification_id
|
||||||
def detailed(self, verification_uuid=None, sort_by="name"):
|
def detailed(self, verification=None, sort_by="name"):
|
||||||
"""Display results table of a verification with detailed errors.
|
"""Display results table of a verification with detailed errors.
|
||||||
|
|
||||||
:param verification_uuid: UUID of a verification
|
:param verification: UUID of a verification
|
||||||
:param sort_by: Sort results by 'name' or 'duration'
|
:param sort_by: Sort results by 'name' or 'duration'
|
||||||
"""
|
"""
|
||||||
self.show(verification_uuid, sort_by, True)
|
self.show(verification, sort_by, True)
|
||||||
|
|
||||||
@cliutils.args("--uuid-1", type=str, required=True, dest="uuid1",
|
@cliutils.args("--uuid-1", type=str, required=True, dest="verification1",
|
||||||
help="UUID of the first verification")
|
help="UUID of the first verification")
|
||||||
@cliutils.args("--uuid-2", type=str, required=True, dest="uuid2",
|
@cliutils.args("--uuid-2", type=str, required=True, dest="verification2",
|
||||||
help="UUID of the second verification")
|
help="UUID of the second verification")
|
||||||
@cliutils.args("--csv", action="store_true", dest="output_csv",
|
@cliutils.args("--csv", action="store_true", dest="output_csv",
|
||||||
help="Display results in CSV format")
|
help="Display results in CSV format")
|
||||||
@ -307,13 +307,13 @@ class VerifyCommands(object):
|
|||||||
dest="threshold", default=0,
|
dest="threshold", default=0,
|
||||||
help="If specified, timing differences must exceed this "
|
help="If specified, timing differences must exceed this "
|
||||||
"percentage threshold to be included in output")
|
"percentage threshold to be included in output")
|
||||||
def compare(self, uuid1=None, uuid2=None,
|
def compare(self, verification1=None, verification2=None,
|
||||||
output_file=None, output_csv=None, output_html=None,
|
output_file=None, output_csv=None, output_html=None,
|
||||||
output_json=None, threshold=0):
|
output_json=None, threshold=0):
|
||||||
"""Compare two verification results.
|
"""Compare two verification results.
|
||||||
|
|
||||||
:param uuid1: UUID of the first verification
|
:param verification1: UUID of the first verification
|
||||||
:param uuid2: UUID of the second verification
|
:param verification2: UUID of the second verification
|
||||||
:param output_file: Path to a file to save results
|
:param output_file: Path to a file to save results
|
||||||
:param output_csv: Display results in CSV format
|
:param output_csv: Display results in CSV format
|
||||||
:param output_html: Display results in HTML format
|
:param output_html: Display results in HTML format
|
||||||
@ -321,8 +321,10 @@ class VerifyCommands(object):
|
|||||||
:param threshold: Timing difference threshold percentage
|
:param threshold: Timing difference threshold percentage
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
res_1 = api.Verification.get(uuid1).get_results()["test_cases"]
|
res_1 = api.Verification.get(
|
||||||
res_2 = api.Verification.get(uuid2).get_results()["test_cases"]
|
verification1).get_results()["test_cases"]
|
||||||
|
res_2 = api.Verification.get(
|
||||||
|
verification2).get_results()["test_cases"]
|
||||||
_diff = diff.Diff(res_1, res_2, threshold)
|
_diff = diff.Diff(res_1, res_2, threshold)
|
||||||
except exceptions.NotFoundException as e:
|
except exceptions.NotFoundException as e:
|
||||||
print(six.text_type(e))
|
print(six.text_type(e))
|
||||||
@ -350,8 +352,12 @@ class VerifyCommands(object):
|
|||||||
else:
|
else:
|
||||||
print(result)
|
print(result)
|
||||||
|
|
||||||
@cliutils.args("--verification", type=str, dest="verification",
|
@cliutils.args("--uuid", type=str, dest="verification",
|
||||||
required=False, help="UUID of a verification")
|
required=False, help="UUID of a verification")
|
||||||
|
@cliutils.deprecated_args("--verification", dest="verification",
|
||||||
|
required=False, type=str,
|
||||||
|
release="0.2.0",
|
||||||
|
alternative="--uuid")
|
||||||
def use(self, verification):
|
def use(self, verification):
|
||||||
"""Set active verification.
|
"""Set active verification.
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ def with_default_deployment(cli_arg_name="uuid"):
|
|||||||
|
|
||||||
with_default_task_id = default_from_global("task_id", ENV_TASK, "uuid")
|
with_default_task_id = default_from_global("task_id", ENV_TASK, "uuid")
|
||||||
with_default_verification_id = default_from_global(
|
with_default_verification_id = default_from_global(
|
||||||
"verification_uuid", ENV_VERIFICATION, "uuid")
|
"verification", ENV_VERIFICATION, "uuid")
|
||||||
|
|
||||||
|
|
||||||
def get_creds_from_env_vars():
|
def get_creds_from_env_vars():
|
||||||
|
@ -28,6 +28,7 @@ class DBCommands(object):
|
|||||||
"""Commands for DB management."""
|
"""Commands for DB management."""
|
||||||
|
|
||||||
def recreate(self):
|
def recreate(self):
|
||||||
|
"""Drop and create Rally database."""
|
||||||
db.db_drop()
|
db.db_drop()
|
||||||
db.db_create()
|
db.db_create()
|
||||||
envutils.clear_env()
|
envutils.clear_env()
|
||||||
|
Loading…
Reference in New Issue
Block a user