Merge "[Verify] Improvements in rally verify installplugin cmd"

This commit is contained in:
Jenkins 2016-07-21 10:00:36 +00:00 committed by Gerrit Code Review
commit 41b26f4ab5
4 changed files with 19 additions and 12 deletions

View File

@ -495,8 +495,8 @@ class Verification(object):
:param source: Path/URL to repo to clone Tempest plugin from
:param version: Branch, commit ID or tag to checkout before Tempest
plugin installation
:param system_wide: Whether or not to install plugin in Tempest
virtual env
:param system_wide: Install plugin in Tempest virtual env or
in the local env
"""
deployment_uuid = objects.Deployment.get(deployment)["uuid"]
verifier = tempest.Tempest(deployment_uuid,

View File

@ -471,14 +471,14 @@ class VerifyCommands(object):
required=False, help="UUID or name of a deployment")
@cliutils.args("--source", type=str, dest="source", required=True,
help="Path/URL to repo to clone Tempest plugin from")
@envutils.with_default_deployment(cli_arg_name="deployment")
@cliutils.args("--version", type=str, dest="version", required=False,
help="Branch, commit ID or tag to checkout before Tempest "
"plugin installation")
@cliutils.args("--system-wide", dest="system_wide",
help="Don't install plugin in Tempest virtual env. "
"Note that all Tempest plugin requirements have "
"to be already installed in the local env!",
help="Install plugin in the local env, "
"not in Tempest virtual env. Note that all Tempest "
"plugin requirements have to be already installed in "
"the local env!",
required=False, action="store_true")
@envutils.with_default_deployment(cli_arg_name="deployment")
def installplugin(self, deployment=None, source=None, version=None,
@ -489,8 +489,8 @@ class VerifyCommands(object):
:param source: Path/URL to repo to clone Tempest plugin from
:param version: Branch, commit ID or tag to checkout before Tempest
plugin installation
:param system_wide: Whether or not to install plugin in Tempest
virtual env
:param system_wide: Install plugin in Tempest virtual env or
in the local env
"""
api.Verification.install_tempest_plugin(deployment, source,
version, system_wide)

View File

@ -15,6 +15,7 @@
import os
import re
import shutil
import subprocess
import sys
@ -298,10 +299,15 @@ class Tempest(object):
"""Install Tempest plugin for local Tempest repo."""
LOG.info(_("Installing Tempest plugin from %s for "
"deployment: %s") % (self.plugin_source, self.deployment))
egg = os.path.basename(self.plugin_source.strip("/"))
egg = re.sub("\.git$", "",
os.path.basename(self.plugin_source.strip("/")))
version = self.plugin_version or "master"
cmd = [self.venv_wrapper, "pip", "install", "-e",
cmd = ["pip", "install", "--no-deps",
"--src", self.path("plugins"), "-e",
"git+{0}@{1}#egg={2}".format(self.plugin_source, version, egg)]
if not self._system_wide:
cmd.insert(0, self.path("tools/with_venv.sh"))
cmd.remove("--no-deps")
check_output(cmd, cwd=self.path())
LOG.info(_("Tempest plugin has been successfully installed!"))

View File

@ -331,12 +331,13 @@ class TempestInstallAndUninstallTestCase(BaseTestCase):
class TempestInstallPluginsTestCase(BaseTestCase):
@mock.patch(TEMPEST_PATH + ".tempest.check_output")
@ddt.data("https://github.com/fake-plugin", "/tmp/fake-plugin")
@ddt.data("https://github.com/fake-plugin.git", "/tmp/fake-plugin")
def test_install_plugin(self, plugin_source, mock_tempest_check_output):
self.verifier.plugin_source = plugin_source
self.verifier.install_plugin()
cmd = [self.verifier.venv_wrapper, "pip", "install", "-e",
cmd = [self.verifier.venv_wrapper, "pip", "install",
"--src", self.verifier.path("plugins"), "-e",
"git+{0}@master#egg={1}".format(plugin_source, "fake-plugin")]
mock_tempest_check_output.assert_called_with(cmd,
cwd=self.verifier.path())