Merge "Remove a bunch of deprecated stuff from CLI"

This commit is contained in:
Zuul 2019-09-10 14:21:08 +00:00 committed by Gerrit Code Review
commit 9b792b8282
10 changed files with 81 additions and 131 deletions

View File

@ -17,11 +17,35 @@ Changelog
.. Release notes for existing releases are MUTABLE! If there is something that .. Release notes for existing releases are MUTABLE! If there is something that
was missed or can be improved, feel free to change it! was missed or can be improved, feel free to change it!
[unreleased]
------------
Removed
~~~~~~~
* *rally task sla_check* command was deprecated in Rally 0.8.0 in favor of
*rally task sla-check*.
* *rally-manage db* command (and the whole *rally-manage* entry-point) was
deprecated in Rally 0.10.0 in favor of *rally db* command.
* *--namespace* argument was deprecated in Rally 0.10.0 in favor of
*--platform* which has better meaning.
Affected commands: *rally plugin show*, *rally plugin list*,
*rally verify list-plugins*, *rally verify create-verifier*.
* *--tasks* argument of *rally task report* command and *--task* argument of
*rally task use* command were deprecated in Rally 0.10.0 in favor of
unified *--uuid* argument.
* *--junit* argument of *rally task report* command is deprecated in
Rally 0.10.0 in favor of *rally task export --type junit-xml*
[1.6.0] - 2019-06-19 [1.6.0] - 2019-06-19
-------------------- --------------------
Added Added
~~~~~~~ ~~~~~
A list of tests to skip while running verification now supports regular A list of tests to skip while running verification now supports regular
expressions. expressions.

View File

@ -52,7 +52,6 @@ _rally()
OPTS["task_report"]="--out --open --html --html-static --json --uuid --deployment" OPTS["task_report"]="--out --open --html --html-static --json --uuid --deployment"
OPTS["task_results"]="--uuid" OPTS["task_results"]="--uuid"
OPTS["task_sla-check"]="--uuid --json" 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_trends"]="--out --open --tasks --html-static" OPTS["task_trends"]="--out --open --tasks --html-static"
@ -106,4 +105,4 @@ _rally()
return 0 return 0
} }
complete -o filenames -F _rally rally complete -o filenames -F _rally rally

View File

@ -42,8 +42,6 @@ class PluginCommands(object):
help="Plugin name.") help="Plugin name.")
@cliutils.args("--platform", dest="platform", type=str, @cliutils.args("--platform", dest="platform", type=str,
help="Plugin platform.") help="Plugin platform.")
@cliutils.deprecated_args("--namespace", dest="platform",
release="0.10.0", alternative="--platform")
@plugins.ensure_plugins_are_loaded @plugins.ensure_plugins_are_loaded
def show(self, api, name, platform=None): def show(self, api, name, platform=None):
"""Show detailed information about a Rally plugin.""" """Show detailed information about a Rally plugin."""
@ -88,8 +86,6 @@ class PluginCommands(object):
@cliutils.args( @cliutils.args(
"--platform", dest="platform", type=str, "--platform", dest="platform", type=str,
help="List only plugins that are in the specified platform.") help="List only plugins that are in the specified platform.")
@cliutils.deprecated_args("--namespace", dest="platform",
release="0.10.0", alternative="--platform")
@cliutils.args( @cliutils.args(
"--plugin-base", dest="base_cls", type=str, "--plugin-base", dest="base_cls", type=str,
help="Plugin base class.") help="Plugin base class.")

View File

@ -836,8 +836,6 @@ class TaskCommands(object):
output_dest=kwargs.get("out"), output_dest=kwargs.get("out"),
open_it=kwargs.get("open_it", False)) open_it=kwargs.get("open_it", False))
@cliutils.deprecated_args("--tasks", dest="tasks", nargs="+",
release="0.10.0", alternative="--uuid")
@cliutils.args("--out", metavar="<path>", @cliutils.args("--out", metavar="<path>",
type=str, dest="out", required=False, type=str, dest="out", required=False,
help="Report destination. Can be a path to a file (in case" help="Report destination. Can be a path to a file (in case"
@ -851,11 +849,6 @@ class TaskCommands(object):
action="store_const", const="html-static") action="store_const", const="html-static")
@cliutils.args("--json", dest="out_format", @cliutils.args("--json", dest="out_format",
action="store_const", const="json") action="store_const", const="json")
@cliutils.deprecated_args("--junit", dest="out_format",
action="store_const", const="junit-xml",
release="0.10.0",
alternative=("rally task export "
"--type junit-xml"))
@cliutils.args("--uuid", dest="tasks", nargs="+", type=str, @cliutils.args("--uuid", dest="tasks", nargs="+", type=str,
help="UUIDs of tasks or json reports of tasks") help="UUIDs of tasks or json reports of tasks")
@cliutils.args("--deployment", dest="deployment", type=str, @cliutils.args("--deployment", dest="deployment", type=str,
@ -895,17 +888,6 @@ class TaskCommands(object):
else: else:
_delete_single_task(task_id, force) _delete_single_task(task_id, force)
@cliutils.args("--uuid", type=str, dest="task_id", help="UUID of task.")
@cliutils.args("--json", dest="tojson",
action="store_true",
help="Output in JSON format.")
@envutils.with_default_task_id
@cliutils.alias("sla_check")
def sla_check_deprecated(self, api, task_id=None, tojson=False):
"""DEPRECATED since Rally 0.8.0, use `rally task sla-check` instead."""
return self.sla_check(api, task_id=task_id, tojson=tojson)
@cliutils.args("--uuid", type=str, dest="task_id", help="UUID of task.") @cliutils.args("--uuid", type=str, dest="task_id", help="UUID of task.")
@cliutils.args("--json", dest="tojson", @cliutils.args("--json", dest="tojson",
action="store_true", action="store_true",
@ -938,8 +920,6 @@ class TaskCommands(object):
@cliutils.args("--uuid", type=str, dest="task_id", @cliutils.args("--uuid", type=str, dest="task_id",
help="UUID of the task") help="UUID of the task")
@cliutils.deprecated_args("--task", dest="task_id", type=str,
release="0.2.0", alternative="--uuid")
def use(self, api, task_id): def use(self, api, task_id):
"""Set active task.""" """Set active task."""

View File

@ -91,8 +91,6 @@ class VerifyCommands(object):
@cliutils.args("--platform", dest="platform", type=str, @cliutils.args("--platform", dest="platform", type=str,
help="Requried patform (e.g. openstack).") help="Requried patform (e.g. openstack).")
@cliutils.deprecated_args("--namespace", dest="platform",
release="0.10.0", alternative="--platform")
@plugins.ensure_plugins_are_loaded @plugins.ensure_plugins_are_loaded
def list_plugins(self, api, platform=None): def list_plugins(self, api, platform=None):
"""List all plugins for verifiers management.""" """List all plugins for verifiers management."""
@ -120,8 +118,6 @@ class VerifyCommands(object):
help="Verifier plugin platform. Should be specified in " help="Verifier plugin platform. Should be specified in "
"case of two verifier plugins with equal names but " "case of two verifier plugins with equal names but "
"in different platforms.") "in different platforms.")
@cliutils.deprecated_args("--namespace", dest="platform",
release="0.10.0", alternative="--platform")
@cliutils.args("--source", dest="source", type=str, required=False, @cliutils.args("--source", dest="source", type=str, required=False,
help="Path or URL to the repo to clone verifier from.") help="Path or URL to the repo to clone verifier from.")
@cliutils.args("--version", dest="version", type=str, required=False, @cliutils.args("--version", dest="version", type=str, required=False,

View File

@ -1,30 +0,0 @@
# Copyright 2013: Mirantis Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import sys
from rally.cli import cliutils
from rally.cli.commands import db
def main():
categories = {"db": db.DBCommands}
print("`rally-manage db <command>` was deprecated since 0.10.0 version "
"and is going to be removed soon. Please use `rally db <command>`.")
return cliutils.run(sys.argv, categories)
if __name__ == "__main__":
sys.exit(main())

View File

@ -33,7 +33,6 @@ data_files =
[entry_points] [entry_points]
console_scripts = console_scripts =
rally = rally.cli.main:main rally = rally.cli.main:main
rally-manage = rally.cli.manage:main
oslo.config.opts = oslo.config.opts =
rally = rally.common.opts:list_opts rally = rally.common.opts:list_opts
oslo.config.opts.defaults = oslo.config.opts.defaults =

View File

@ -18,10 +18,10 @@ import os
import re import re
import threading import threading
import time import time
import unittest
import jsonschema import jsonschema
import mock import mock
import testtools
from rally import api from rally import api
from tests.functional import utils from tests.functional import utils
@ -30,7 +30,7 @@ from tests.functional import utils
FAKE_TASK_UUID = "87ab639d-4968-4638-b9a1-07774c32484a" FAKE_TASK_UUID = "87ab639d-4968-4638-b9a1-07774c32484a"
class TaskTestCase(unittest.TestCase): class TaskTestCase(testtools.TestCase):
def _get_sample_task_config(self): def _get_sample_task_config(self):
return { return {
@ -156,11 +156,9 @@ class TaskTestCase(unittest.TestCase):
] ]
} }
config = utils.TaskConfig(cfg) config = utils.TaskConfig(cfg)
try: # it should be failed due to Dummy.dummy_exception
# it should be failed due to Dummy.dummy_exception self.assertRaises(utils.RallyCliError,
rally("task start --task %s" % config.filename) rally, "task start --task %s" % config.filename)
except utils.RallyCliError:
pass
output = rally("task detailed --filter-by sla-failures") output = rally("task detailed --filter-by sla-failures")
self.assertIn("Dummy.dummy_exception", output) self.assertIn("Dummy.dummy_exception", output)
self.assertNotIn("Dummy.dummy_random_action", output) self.assertNotIn("Dummy.dummy_random_action", output)
@ -211,10 +209,11 @@ class TaskTestCase(unittest.TestCase):
def test_start_with_empty_config(self): def test_start_with_empty_config(self):
rally = utils.Rally() rally = utils.Rally()
config = utils.TaskConfig(None) config = utils.TaskConfig(None)
with self.assertRaises(utils.RallyCliError) as err: err = self.assertRaises(
rally("task start --task %s" % config.filename) utils.RallyCliError,
rally, "task start --task %s" % config.filename)
self.assertIn("Task config is invalid: `It is empty`", self.assertIn("Task config is invalid: `It is empty`",
err.exception.output) err.output)
def test_results(self): def test_results(self):
rally = utils.Rally() rally = utils.Rally()
@ -265,10 +264,11 @@ class TaskTestCase(unittest.TestCase):
def test_report_with_wrong_task_id(self): def test_report_with_wrong_task_id(self):
rally = utils.Rally() rally = utils.Rally()
self.assertRaises(utils.RallyCliError, e = self.assertRaises(utils.RallyCliError,
rally, "task report --tasks %s" % FAKE_TASK_UUID) rally, "task report --uuid %s" % FAKE_TASK_UUID)
self.assertRaises(utils.RallyCliError, self.assertIn(
rally, "task report --uuid %s" % FAKE_TASK_UUID) "Record for uuid: %s not found in table task" % FAKE_TASK_UUID,
str(e))
def test_sla_check_with_wrong_task_id(self): def test_sla_check_with_wrong_task_id(self):
rally = utils.Rally() rally = utils.Rally()
@ -999,7 +999,7 @@ class TaskTestCase(unittest.TestCase):
result = re.search( result = re.search(
r"(?P<uuid>[0-9a-f\-]{36}): started", output) r"(?P<uuid>[0-9a-f\-]{36}): started", output)
uuid = result.group("uuid") uuid = result.group("uuid")
rally("task use --task %s" % uuid) rally("task use --uuid %s" % uuid)
current_task = utils.get_global("RALLY_TASK", rally.env) current_task = utils.get_global("RALLY_TASK", rally.env)
self.assertEqual(uuid, current_task) self.assertEqual(uuid, current_task)
@ -1050,7 +1050,7 @@ class TaskTestCase(unittest.TestCase):
self.assertTrue(os.path.exists(html_report)) self.assertTrue(os.path.exists(html_report))
class SLATestCase(unittest.TestCase): class SLATestCase(testtools.TestCase):
def _get_sample_task_config(self, max_seconds_per_iteration=4, def _get_sample_task_config(self, max_seconds_per_iteration=4,
failure_rate_max=0): failure_rate_max=0):
@ -1077,9 +1077,10 @@ class SLATestCase(unittest.TestCase):
rally = utils.Rally() rally = utils.Rally()
cfg = self._get_sample_task_config(max_seconds_per_iteration=0.001) cfg = self._get_sample_task_config(max_seconds_per_iteration=0.001)
config = utils.TaskConfig(cfg) config = utils.TaskConfig(cfg)
with self.assertRaises(utils.RallyCliError) as err: err = self.assertRaises(
rally("task start --task %s" % config.filename) utils.RallyCliError,
output = err.exception.output rally, "task start --task %s" % config.filename)
output = err.output
self.assertIn("At least one workload did not pass SLA criteria.", self.assertIn("At least one workload did not pass SLA criteria.",
output) output)
self.assertRaises(utils.RallyCliError, rally, "task sla-check") self.assertRaises(utils.RallyCliError, rally, "task sla-check")
@ -1103,7 +1104,7 @@ class SLATestCase(unittest.TestCase):
self.assertEqual(expected, data) self.assertEqual(expected, data)
class SLAExtraFlagsTestCase(unittest.TestCase): class SLAExtraFlagsTestCase(testtools.TestCase):
def test_abort_on_sla_fail(self): def test_abort_on_sla_fail(self):
rally = utils.Rally() rally = utils.Rally()
@ -1135,13 +1136,9 @@ class SLAExtraFlagsTestCase(unittest.TestCase):
"detail": mock.ANY, "detail": mock.ANY,
"pos": 0, "status": "FAIL"} "pos": 0, "status": "FAIL"}
] ]
try: e = self.assertRaises(utils.RallyCliError,
rally("task sla-check --json", getjson=True) rally, "task sla-check --json", getjson=True)
except utils.RallyCliError as expected_error: self.assertEqual(expected, json.loads(e.output))
self.assertEqual(expected, json.loads(expected_error.output))
else:
self.fail("`rally task sla-check` command should return non-zero "
"exit code")
def _test_broken_context(self, runner): def _test_broken_context(self, runner):
rally = utils.Rally() rally = utils.Rally()
@ -1170,13 +1167,9 @@ class SLAExtraFlagsTestCase(unittest.TestCase):
"detail": mock.ANY, "detail": mock.ANY,
"pos": 0, "status": "FAIL"} "pos": 0, "status": "FAIL"}
] ]
try: e = self.assertRaises(utils.RallyCliError,
rally("task sla-check --json", getjson=True) rally, "task sla-check --json", getjson=True)
except utils.RallyCliError as expected_error: self.assertEqual(expected, json.loads(e.output))
self.assertEqual(expected, json.loads(expected_error.output))
else:
self.fail("`rally task sla-check` command should return non-zero "
"exit code")
def test_broken_context_with_constant_runner(self): def test_broken_context_with_constant_runner(self):
self._test_broken_context({"type": "constant", self._test_broken_context({"type": "constant",
@ -1190,7 +1183,7 @@ class SLAExtraFlagsTestCase(unittest.TestCase):
"timeout": 6}) "timeout": 6})
class SLAPerfDegrTestCase(unittest.TestCase): class SLAPerfDegrTestCase(testtools.TestCase):
def _get_sample_task_config(self, max_degradation=500): def _get_sample_task_config(self, max_degradation=500):
return { return {
@ -1219,9 +1212,10 @@ class SLAPerfDegrTestCase(unittest.TestCase):
rally = utils.Rally() rally = utils.Rally()
cfg = self._get_sample_task_config(max_degradation=1) cfg = self._get_sample_task_config(max_degradation=1)
config = utils.TaskConfig(cfg) config = utils.TaskConfig(cfg)
with self.assertRaises(utils.RallyCliError) as err: err = self.assertRaises(
rally("task start --task %s" % config.filename) utils.RallyCliError,
output = err.exception.output rally, "task start --task %s" % config.filename)
output = err.output
self.assertIn("At least one workload did not pass SLA criteria.", self.assertIn("At least one workload did not pass SLA criteria.",
output) output)
self.assertRaises(utils.RallyCliError, rally, "task sla-check") self.assertRaises(utils.RallyCliError, rally, "task sla-check")
@ -1241,7 +1235,7 @@ class SLAPerfDegrTestCase(unittest.TestCase):
self.assertEqual(expected, data) self.assertEqual(expected, data)
class HookTestCase(unittest.TestCase): class HookTestCase(testtools.TestCase):
def setUp(self): def setUp(self):
super(HookTestCase, self).setUp() super(HookTestCase, self).setUp()

View File

@ -922,6 +922,28 @@ class ValidateArgsTest(test.TestCase):
wrapped = cliutils.alias(cmd_name) wrapped = cliutils.alias(cmd_name)
self.assertEqual(cmd_name, wrapped(alias_fn).alias) self.assertEqual(cmd_name, wrapped(alias_fn).alias)
def test_deprecated_args(self):
def command():
pass
def deprecated_args(func, *args, **kwargs):
cliutils.deprecated_args(*args, **kwargs)(func)
e = self.assertRaises(ValueError, deprecated_args, command,
"--argument-name", type="const")
self.assertIn("'release' is required keyword argument", str(e))
self.assertNotIn("args", command.__dict__)
self.assertNotIn("deprecated_args", command.__dict__)
@cliutils.deprecated_args("--argument-name", type="const", release=777)
def command():
pass
self.assertEqual(1, len(command.__dict__.get("args", [])))
arg_kwargs = command.__dict__["args"][0][1]
self.assertIn("[Deprecated since Rally 777]",
arg_kwargs.get("help", ""))
class CategoryParserTestCase(test.TestCase): class CategoryParserTestCase(test.TestCase):

View File

@ -1,30 +0,0 @@
# Copyright 2013: Mirantis Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import sys
import mock
from rally.cli import manage
from tests.unit import test
class CmdManageTestCase(test.TestCase):
@mock.patch("rally.cli.manage.cliutils")
def test_main(self, mock_cliutils):
manage.main()
categories = {"db": manage.db.DBCommands}
mock_cliutils.run.assert_called_once_with(sys.argv, categories)