Browse Source

Merge "Remove a bunch of deprecated stuff from CLI"

tags/2.0.0
Zuul 1 month ago
parent
commit
9b792b8282

+ 25
- 1
CHANGELOG.rst View File

@@ -17,11 +17,35 @@ Changelog
17 17
 .. Release notes for existing releases are MUTABLE! If there is something that
18 18
    was missed or can be improved, feel free to change it!
19 19
 
20
+[unreleased]
21
+------------
22
+
23
+Removed
24
+~~~~~~~
25
+
26
+* *rally task sla_check* command was deprecated in Rally 0.8.0 in favor of
27
+  *rally task sla-check*.
28
+
29
+* *rally-manage db* command (and the whole *rally-manage* entry-point) was
30
+  deprecated in Rally 0.10.0 in favor of *rally db* command.
31
+
32
+* *--namespace* argument was deprecated in Rally 0.10.0 in favor of
33
+  *--platform* which has better meaning.
34
+  Affected commands: *rally plugin show*, *rally plugin list*,
35
+  *rally verify list-plugins*, *rally verify create-verifier*.
36
+
37
+* *--tasks* argument of *rally task report* command and *--task* argument of
38
+  *rally task use* command were deprecated in Rally 0.10.0 in favor of
39
+  unified *--uuid* argument.
40
+
41
+* *--junit* argument of *rally task report* command is deprecated in
42
+  Rally 0.10.0 in favor of *rally task export --type junit-xml*
43
+
20 44
 [1.6.0] - 2019-06-19
21 45
 --------------------
22 46
 
23 47
 Added
24
-~~~~~~~
48
+~~~~~
25 49
 
26 50
 A list of tests to skip while running verification now supports regular
27 51
 expressions.

+ 1
- 2
etc/rally.bash_completion View File

@@ -52,7 +52,6 @@ _rally()
52 52
     OPTS["task_report"]="--out --open --html --html-static --json --uuid --deployment"
53 53
     OPTS["task_results"]="--uuid"
54 54
     OPTS["task_sla-check"]="--uuid --json"
55
-    OPTS["task_sla_check"]="--uuid --json"
56 55
     OPTS["task_start"]="--deployment --task --task-args --task-args-file --tag --no-use --abort-on-sla-failure"
57 56
     OPTS["task_status"]="--uuid"
58 57
     OPTS["task_trends"]="--out --open --tasks --html-static"
@@ -106,4 +105,4 @@ _rally()
106 105
     return 0
107 106
 }
108 107
 
109
-complete -o filenames -F _rally rally
108
+complete -o filenames -F _rally rally

+ 0
- 4
rally/cli/commands/plugin.py View File

@@ -42,8 +42,6 @@ class PluginCommands(object):
42 42
                    help="Plugin name.")
43 43
     @cliutils.args("--platform", dest="platform", type=str,
44 44
                    help="Plugin platform.")
45
-    @cliutils.deprecated_args("--namespace", dest="platform",
46
-                              release="0.10.0", alternative="--platform")
47 45
     @plugins.ensure_plugins_are_loaded
48 46
     def show(self, api, name, platform=None):
49 47
         """Show detailed information about a Rally plugin."""
@@ -88,8 +86,6 @@ class PluginCommands(object):
88 86
     @cliutils.args(
89 87
         "--platform", dest="platform", type=str,
90 88
         help="List only plugins that are in the specified platform.")
91
-    @cliutils.deprecated_args("--namespace", dest="platform",
92
-                              release="0.10.0", alternative="--platform")
93 89
     @cliutils.args(
94 90
         "--plugin-base", dest="base_cls", type=str,
95 91
         help="Plugin base class.")

+ 0
- 20
rally/cli/commands/task.py View File

@@ -836,8 +836,6 @@ class TaskCommands(object):
836 836
                     output_dest=kwargs.get("out"),
837 837
                     open_it=kwargs.get("open_it", False))
838 838
 
839
-    @cliutils.deprecated_args("--tasks", dest="tasks", nargs="+",
840
-                              release="0.10.0", alternative="--uuid")
841 839
     @cliutils.args("--out", metavar="<path>",
842 840
                    type=str, dest="out", required=False,
843 841
                    help="Report destination. Can be a path to a file (in case"
@@ -851,11 +849,6 @@ class TaskCommands(object):
851 849
                    action="store_const", const="html-static")
852 850
     @cliutils.args("--json", dest="out_format",
853 851
                    action="store_const", const="json")
854
-    @cliutils.deprecated_args("--junit", dest="out_format",
855
-                              action="store_const", const="junit-xml",
856
-                              release="0.10.0",
857
-                              alternative=("rally task export "
858
-                                           "--type junit-xml"))
859 852
     @cliutils.args("--uuid", dest="tasks", nargs="+", type=str,
860 853
                    help="UUIDs of tasks or json reports of tasks")
861 854
     @cliutils.args("--deployment", dest="deployment", type=str,
@@ -895,17 +888,6 @@ class TaskCommands(object):
895 888
         else:
896 889
             _delete_single_task(task_id, force)
897 890
 
898
-    @cliutils.args("--uuid", type=str, dest="task_id", help="UUID of task.")
899
-    @cliutils.args("--json", dest="tojson",
900
-                   action="store_true",
901
-                   help="Output in JSON format.")
902
-    @envutils.with_default_task_id
903
-    @cliutils.alias("sla_check")
904
-    def sla_check_deprecated(self, api, task_id=None, tojson=False):
905
-        """DEPRECATED since Rally 0.8.0, use `rally task sla-check` instead."""
906
-
907
-        return self.sla_check(api, task_id=task_id, tojson=tojson)
908
-
909 891
     @cliutils.args("--uuid", type=str, dest="task_id", help="UUID of task.")
910 892
     @cliutils.args("--json", dest="tojson",
911 893
                    action="store_true",
@@ -938,8 +920,6 @@ class TaskCommands(object):
938 920
 
939 921
     @cliutils.args("--uuid", type=str, dest="task_id",
940 922
                    help="UUID of the task")
941
-    @cliutils.deprecated_args("--task", dest="task_id", type=str,
942
-                              release="0.2.0", alternative="--uuid")
943 923
     def use(self, api, task_id):
944 924
         """Set active task."""
945 925
 

+ 0
- 4
rally/cli/commands/verify.py View File

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

+ 0
- 30
rally/cli/manage.py View File

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

+ 0
- 1
setup.cfg View File

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

+ 33
- 39
tests/functional/test_cli_task.py View File

@@ -18,10 +18,10 @@ import os
18 18
 import re
19 19
 import threading
20 20
 import time
21
-import unittest
22 21
 
23 22
 import jsonschema
24 23
 import mock
24
+import testtools
25 25
 
26 26
 from rally import api
27 27
 from tests.functional import utils
@@ -30,7 +30,7 @@ from tests.functional import utils
30 30
 FAKE_TASK_UUID = "87ab639d-4968-4638-b9a1-07774c32484a"
31 31
 
32 32
 
33
-class TaskTestCase(unittest.TestCase):
33
+class TaskTestCase(testtools.TestCase):
34 34
 
35 35
     def _get_sample_task_config(self):
36 36
         return {
@@ -156,11 +156,9 @@ class TaskTestCase(unittest.TestCase):
156 156
             ]
157 157
         }
158 158
         config = utils.TaskConfig(cfg)
159
-        try:
160
-            # it should be failed due to Dummy.dummy_exception
161
-            rally("task start --task %s" % config.filename)
162
-        except utils.RallyCliError:
163
-            pass
159
+        # it should be failed due to Dummy.dummy_exception
160
+        self.assertRaises(utils.RallyCliError,
161
+                          rally, "task start --task %s" % config.filename)
164 162
         output = rally("task detailed --filter-by sla-failures")
165 163
         self.assertIn("Dummy.dummy_exception", output)
166 164
         self.assertNotIn("Dummy.dummy_random_action", output)
@@ -211,10 +209,11 @@ class TaskTestCase(unittest.TestCase):
211 209
     def test_start_with_empty_config(self):
212 210
         rally = utils.Rally()
213 211
         config = utils.TaskConfig(None)
214
-        with self.assertRaises(utils.RallyCliError) as err:
215
-            rally("task start --task %s" % config.filename)
212
+        err = self.assertRaises(
213
+            utils.RallyCliError,
214
+            rally, "task start --task %s" % config.filename)
216 215
         self.assertIn("Task config is invalid: `It is empty`",
217
-                      err.exception.output)
216
+                      err.output)
218 217
 
219 218
     def test_results(self):
220 219
         rally = utils.Rally()
@@ -265,10 +264,11 @@ class TaskTestCase(unittest.TestCase):
265 264
 
266 265
     def test_report_with_wrong_task_id(self):
267 266
         rally = utils.Rally()
268
-        self.assertRaises(utils.RallyCliError,
269
-                          rally, "task report --tasks %s" % FAKE_TASK_UUID)
270
-        self.assertRaises(utils.RallyCliError,
271
-                          rally, "task report --uuid %s" % FAKE_TASK_UUID)
267
+        e = self.assertRaises(utils.RallyCliError,
268
+                              rally, "task report --uuid %s" % FAKE_TASK_UUID)
269
+        self.assertIn(
270
+            "Record for uuid: %s not found in table task" % FAKE_TASK_UUID,
271
+            str(e))
272 272
 
273 273
     def test_sla_check_with_wrong_task_id(self):
274 274
         rally = utils.Rally()
@@ -999,7 +999,7 @@ class TaskTestCase(unittest.TestCase):
999 999
         result = re.search(
1000 1000
             r"(?P<uuid>[0-9a-f\-]{36}): started", output)
1001 1001
         uuid = result.group("uuid")
1002
-        rally("task use --task %s" % uuid)
1002
+        rally("task use --uuid %s" % uuid)
1003 1003
         current_task = utils.get_global("RALLY_TASK", rally.env)
1004 1004
         self.assertEqual(uuid, current_task)
1005 1005
 
@@ -1050,7 +1050,7 @@ class TaskTestCase(unittest.TestCase):
1050 1050
         self.assertTrue(os.path.exists(html_report))
1051 1051
 
1052 1052
 
1053
-class SLATestCase(unittest.TestCase):
1053
+class SLATestCase(testtools.TestCase):
1054 1054
 
1055 1055
     def _get_sample_task_config(self, max_seconds_per_iteration=4,
1056 1056
                                 failure_rate_max=0):
@@ -1077,9 +1077,10 @@ class SLATestCase(unittest.TestCase):
1077 1077
         rally = utils.Rally()
1078 1078
         cfg = self._get_sample_task_config(max_seconds_per_iteration=0.001)
1079 1079
         config = utils.TaskConfig(cfg)
1080
-        with self.assertRaises(utils.RallyCliError) as err:
1081
-            rally("task start --task %s" % config.filename)
1082
-        output = err.exception.output
1080
+        err = self.assertRaises(
1081
+            utils.RallyCliError,
1082
+            rally, "task start --task %s" % config.filename)
1083
+        output = err.output
1083 1084
         self.assertIn("At least one workload did not pass SLA criteria.",
1084 1085
                       output)
1085 1086
         self.assertRaises(utils.RallyCliError, rally, "task sla-check")
@@ -1103,7 +1104,7 @@ class SLATestCase(unittest.TestCase):
1103 1104
         self.assertEqual(expected, data)
1104 1105
 
1105 1106
 
1106
-class SLAExtraFlagsTestCase(unittest.TestCase):
1107
+class SLAExtraFlagsTestCase(testtools.TestCase):
1107 1108
 
1108 1109
     def test_abort_on_sla_fail(self):
1109 1110
         rally = utils.Rally()
@@ -1135,13 +1136,9 @@ class SLAExtraFlagsTestCase(unittest.TestCase):
1135 1136
              "detail": mock.ANY,
1136 1137
              "pos": 0, "status": "FAIL"}
1137 1138
         ]
1138
-        try:
1139
-            rally("task sla-check --json", getjson=True)
1140
-        except utils.RallyCliError as expected_error:
1141
-            self.assertEqual(expected, json.loads(expected_error.output))
1142
-        else:
1143
-            self.fail("`rally task sla-check` command should return non-zero "
1144
-                      "exit code")
1139
+        e = self.assertRaises(utils.RallyCliError,
1140
+                              rally, "task sla-check --json", getjson=True)
1141
+        self.assertEqual(expected, json.loads(e.output))
1145 1142
 
1146 1143
     def _test_broken_context(self, runner):
1147 1144
         rally = utils.Rally()
@@ -1170,13 +1167,9 @@ class SLAExtraFlagsTestCase(unittest.TestCase):
1170 1167
              "detail": mock.ANY,
1171 1168
              "pos": 0, "status": "FAIL"}
1172 1169
         ]
1173
-        try:
1174
-            rally("task sla-check --json", getjson=True)
1175
-        except utils.RallyCliError as expected_error:
1176
-            self.assertEqual(expected, json.loads(expected_error.output))
1177
-        else:
1178
-            self.fail("`rally task sla-check` command should return non-zero "
1179
-                      "exit code")
1170
+        e = self.assertRaises(utils.RallyCliError,
1171
+                              rally, "task sla-check --json", getjson=True)
1172
+        self.assertEqual(expected, json.loads(e.output))
1180 1173
 
1181 1174
     def test_broken_context_with_constant_runner(self):
1182 1175
         self._test_broken_context({"type": "constant",
@@ -1190,7 +1183,7 @@ class SLAExtraFlagsTestCase(unittest.TestCase):
1190 1183
                                    "timeout": 6})
1191 1184
 
1192 1185
 
1193
-class SLAPerfDegrTestCase(unittest.TestCase):
1186
+class SLAPerfDegrTestCase(testtools.TestCase):
1194 1187
 
1195 1188
     def _get_sample_task_config(self, max_degradation=500):
1196 1189
         return {
@@ -1219,9 +1212,10 @@ class SLAPerfDegrTestCase(unittest.TestCase):
1219 1212
         rally = utils.Rally()
1220 1213
         cfg = self._get_sample_task_config(max_degradation=1)
1221 1214
         config = utils.TaskConfig(cfg)
1222
-        with self.assertRaises(utils.RallyCliError) as err:
1223
-            rally("task start --task %s" % config.filename)
1224
-        output = err.exception.output
1215
+        err = self.assertRaises(
1216
+            utils.RallyCliError,
1217
+            rally, "task start --task %s" % config.filename)
1218
+        output = err.output
1225 1219
         self.assertIn("At least one workload did not pass SLA criteria.",
1226 1220
                       output)
1227 1221
         self.assertRaises(utils.RallyCliError, rally, "task sla-check")
@@ -1241,7 +1235,7 @@ class SLAPerfDegrTestCase(unittest.TestCase):
1241 1235
         self.assertEqual(expected, data)
1242 1236
 
1243 1237
 
1244
-class HookTestCase(unittest.TestCase):
1238
+class HookTestCase(testtools.TestCase):
1245 1239
 
1246 1240
     def setUp(self):
1247 1241
         super(HookTestCase, self).setUp()

+ 22
- 0
tests/unit/cli/test_cliutils.py View File

@@ -922,6 +922,28 @@ class ValidateArgsTest(test.TestCase):
922 922
         wrapped = cliutils.alias(cmd_name)
923 923
         self.assertEqual(cmd_name, wrapped(alias_fn).alias)
924 924
 
925
+    def test_deprecated_args(self):
926
+        def command():
927
+            pass
928
+
929
+        def deprecated_args(func, *args, **kwargs):
930
+            cliutils.deprecated_args(*args, **kwargs)(func)
931
+
932
+        e = self.assertRaises(ValueError, deprecated_args, command,
933
+                              "--argument-name", type="const")
934
+        self.assertIn("'release' is required keyword argument", str(e))
935
+        self.assertNotIn("args", command.__dict__)
936
+        self.assertNotIn("deprecated_args", command.__dict__)
937
+
938
+        @cliutils.deprecated_args("--argument-name", type="const", release=777)
939
+        def command():
940
+            pass
941
+
942
+        self.assertEqual(1, len(command.__dict__.get("args", [])))
943
+        arg_kwargs = command.__dict__["args"][0][1]
944
+        self.assertIn("[Deprecated since Rally 777]",
945
+                      arg_kwargs.get("help", ""))
946
+
925 947
 
926 948
 class CategoryParserTestCase(test.TestCase):
927 949
 

+ 0
- 30
tests/unit/cli/test_manage.py View File

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

Loading…
Cancel
Save