diff --git a/etc/rally.bash_completion b/etc/rally.bash_completion index f55fb71c4e..5e035db01a 100644 --- a/etc/rally.bash_completion +++ b/etc/rally.bash_completion @@ -48,7 +48,7 @@ _rally() 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_detailed"]="--uuid --sort-by" - OPTS["verify_discover"]="--deployment --pattern" + OPTS["verify_discover"]="--deployment --pattern --system-wide" OPTS["verify_genconfig"]="--deployment --tempest-config --override" OPTS["verify_import"]="--deployment --set --file --no-use" OPTS["verify_install"]="--deployment --source --version --system-wide" diff --git a/rally/api.py b/rally/api.py index b8fd5f3020..e79dc84ab7 100644 --- a/rally/api.py +++ b/rally/api.py @@ -541,14 +541,16 @@ class Verification(object): verifier.uninstall_plugin(repo_name) @classmethod - def discover_tests(cls, deployment, pattern=""): + def discover_tests(cls, deployment, pattern="", system_wide=False): """Get a list of discovered tests. :param deployment: UUID or name of a deployment :param pattern: Test name pattern which can be used to match + :param system_wide: Discover tests for system-wide or venv + Tempest installation """ deployment_uuid = objects.Deployment.get(deployment)["uuid"] - verifier = tempest.Tempest(deployment_uuid) + verifier = tempest.Tempest(deployment_uuid, system_wide=system_wide) cls._check_tempest_tree_existence(verifier) diff --git a/rally/cli/commands/verify.py b/rally/cli/commands/verify.py index e1b6f379ae..e3c1d70da2 100644 --- a/rally/cli/commands/verify.py +++ b/rally/cli/commands/verify.py @@ -546,14 +546,20 @@ class VerifyCommands(object): @cliutils.args("--pattern", dest="pattern", type=str, required=False, metavar="", help="Test name pattern which can be used to match") + @cliutils.args("--system-wide", dest="system_wide", + help="Discover tests for system-wide Tempest installation", + required=False, action="store_true") @envutils.with_default_deployment(cli_arg_name="deployment") - def discover(self, deployment=None, pattern=""): + def discover(self, deployment=None, pattern="", system_wide=False): """Show a list of discovered tests. :param deployment: UUID or name of a deployment :param pattern: Test name pattern which can be used to match + :param system_wide: Discover tests for system-wide or venv + Tempest installation """ - discovered_tests = api.Verification.discover_tests(deployment, pattern) + discovered_tests = api.Verification.discover_tests(deployment, pattern, + system_wide) p_str = (_(" matching pattern '%s'") % pattern) if pattern else "" if discovered_tests: print(_("Discovered tests%s:\n") % p_str) @@ -567,7 +573,7 @@ class VerifyCommands(object): help="UUID or name of a deployment.") @envutils.with_default_deployment(cli_arg_name="deployment") def showconfig(self, deployment=None): - """Show configuration file of Tempest. + """Show Tempest configuration file. :param deployment: UUID or name of a deployment """ diff --git a/rally/verification/tempest/tempest.py b/rally/verification/tempest/tempest.py index a5d4066572..4d2774d9e0 100644 --- a/rally/verification/tempest/tempest.py +++ b/rally/verification/tempest/tempest.py @@ -416,7 +416,9 @@ class Tempest(object): :param pattern: Test name pattern which can be used to match """ - cmd = [self.venv_wrapper, "testr", "list-tests", pattern] + cmd = ["testr", "list-tests", pattern] + if not self._system_wide: + cmd.insert(0, self.path("tools/with_venv.sh")) raw_results = subprocess.Popen( cmd, cwd=self.path(), env=self.env, stdout=subprocess.PIPE).communicate()[0] diff --git a/tests/unit/cli/commands/test_verify.py b/tests/unit/cli/commands/test_verify.py index 421bbe083e..32e8eb4c15 100644 --- a/tests/unit/cli/commands/test_verify.py +++ b/tests/unit/cli/commands/test_verify.py @@ -567,7 +567,7 @@ class VerifyCommandsTestCase(test.TestCase): deployment_uuid = "97725f22-1cd2-46a5-8c62-3cdc36ed6d2a" self.verify.discover(deployment_uuid, "some_pattern") mock_verification_discover_tests.assert_called_once_with( - deployment_uuid, "some_pattern") + deployment_uuid, "some_pattern", False) @mock.patch("rally.api.Verification.show_config_info") def test_showconfig(self, mock_verification_show_config_info):