[verification] Fix small bugs in verification component
Co-Authored-By: Yaroslav Lobankov <ylobankov@mirantis.com> Change-Id: I654cedd465b4efacb3e28124ec5752a46060cc66
This commit is contained in:
parent
bb336b0a11
commit
01a1b5fc6e
@ -716,7 +716,7 @@ class Stopwatch(object):
|
||||
|
||||
|
||||
def generate_random_path(root_dir=None):
|
||||
"""Generates a vacant name foo file or dir at specified place.
|
||||
"""Generates a vacant name for a file or dir at the specified place.
|
||||
|
||||
:param root_dir: Name of a directory to generate path in. If None (default
|
||||
behaviour), temporary directory (i.e /tmp in linux) will be used.
|
||||
|
@ -18,9 +18,11 @@ import re
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
from rally.common.i18n import _LE
|
||||
from rally.common.io import subunit_v2
|
||||
from rally.common import logging
|
||||
from rally.common import utils as common_utils
|
||||
from rally import exceptions
|
||||
from rally.verification import context
|
||||
from rally.verification import manager
|
||||
from rally.verification import utils
|
||||
@ -97,8 +99,8 @@ class TestrLauncher(manager.VerifierManager):
|
||||
except (subprocess.CalledProcessError, OSError):
|
||||
if os.path.exists(test_repository_dir):
|
||||
shutil.rmtree(test_repository_dir)
|
||||
LOG.error("Failed to initialize a new repository for 'testr'.")
|
||||
raise
|
||||
raise exceptions.RallyException(
|
||||
_LE("Failed to initialize testr."))
|
||||
|
||||
def install(self):
|
||||
super(TestrLauncher, self).install()
|
||||
@ -133,7 +135,7 @@ class TestrLauncher(manager.VerifierManager):
|
||||
def _process_run_args(self, run_args):
|
||||
"""Process run_args before verification execution.
|
||||
|
||||
This method is called by TestrContext before transforming run_args to
|
||||
cli arguments of testr.
|
||||
This method is called by TestrContext before transforming run_args into
|
||||
cli arguments for testr.
|
||||
"""
|
||||
return run_args
|
||||
|
@ -57,6 +57,9 @@ class TempestManager(testr.TestrLauncher):
|
||||
return config.read_configfile(self.configfile)
|
||||
|
||||
def configure(self, extra_options=None):
|
||||
if not os.path.isdir(os.path.dirname(self.configfile)):
|
||||
os.makedirs(os.path.dirname(self.configfile))
|
||||
|
||||
cm = config.TempestConfigfileManager(self.verifier.deployment)
|
||||
raw_configfile = cm.create(self.configfile, extra_options)
|
||||
return raw_configfile
|
||||
@ -68,13 +71,12 @@ class TempestManager(testr.TestrLauncher):
|
||||
with open(self.configfile, "w") as f:
|
||||
f.write(new_content)
|
||||
|
||||
def install_extension(self, source, version=None, extra=None):
|
||||
def install_extension(self, source, version=None, extra_settings=None):
|
||||
"""Install a Tempest plugin."""
|
||||
if extra:
|
||||
if extra_settings:
|
||||
raise NotImplementedError(
|
||||
_LE("'%s' verifiers don't support extra options for "
|
||||
"extension installations.")
|
||||
% self.get_name())
|
||||
_LE("'%s' verifiers don't support extra installation settings "
|
||||
"for extensions.") % self.get_name())
|
||||
version = version or "master"
|
||||
egg = re.sub("\.git$", "", os.path.basename(source.strip("/")))
|
||||
full_source = "git+{0}@{1}#egg={2}".format(source, version, egg)
|
||||
|
@ -44,5 +44,5 @@ class ContextManager(context.ContextManager):
|
||||
VerifierContext.get(name).validate(config, non_hidden=non_hidden)
|
||||
|
||||
def _get_sorted_context_lst(self):
|
||||
return sorted([VerifierContext.get(name)(cfg)
|
||||
for name, cfg in self.context_obj["config"].items()])
|
||||
return sorted([VerifierContext.get(name)(self.context_obj)
|
||||
for name in self.context_obj["config"].keys()])
|
||||
|
@ -49,7 +49,7 @@ def configure(name, namespace="default", default_repo=None,
|
||||
plugin._configure(name, namespace)
|
||||
plugin._meta_set("default_repo", default_repo)
|
||||
plugin._meta_set("default_version", default_version)
|
||||
plugin._meta_set("config", context or {})
|
||||
plugin._meta_set("context", context or {})
|
||||
return plugin
|
||||
|
||||
return decorator
|
||||
@ -126,8 +126,7 @@ class VerifierManager(plugin.Plugin):
|
||||
|
||||
@classmethod
|
||||
def validate(cls, deployment, run_args):
|
||||
ctx_config = cls._meta_get("context")
|
||||
context.ContextManager.validate({"config": ctx_config})
|
||||
context.ContextManager.validate(cls._meta_get("context"))
|
||||
cls.validate_args(run_args)
|
||||
|
||||
def _clone(self):
|
||||
@ -173,7 +172,7 @@ class VerifierManager(plugin.Plugin):
|
||||
LOG.info("Deleting old virtual environment.")
|
||||
shutil.rmtree(self.venv_dir)
|
||||
|
||||
LOG.info("Creating virtual environment.")
|
||||
LOG.info("Creating virtual environment. It may take a few minutes.")
|
||||
|
||||
LOG.debug("Initializing virtual environment in %s directory.",
|
||||
self.venv_dir)
|
||||
|
@ -16,6 +16,7 @@ import subprocess
|
||||
|
||||
import mock
|
||||
|
||||
from rally import exceptions
|
||||
from rally.plugins.common.verification import testr
|
||||
from tests.unit import test
|
||||
|
||||
@ -222,7 +223,7 @@ class TestrLauncherTestCase(test.TestCase):
|
||||
test_repository_dir = os.path.join(launcher.base_dir,
|
||||
".testrepository")
|
||||
|
||||
self.assertRaises(OSError, launcher._init_testr)
|
||||
self.assertRaises(exceptions.RallyException, launcher._init_testr)
|
||||
|
||||
mock_check_output.assert_called_once_with(
|
||||
["testr", "init"], cwd=launcher.repo_dir, env=launcher.environ)
|
||||
|
@ -88,7 +88,8 @@ class TempestManagerTestCase(test.TestCase):
|
||||
system_wide=True))
|
||||
e = self.assertRaises(NotImplementedError, tempest.install_extension,
|
||||
None, None, {"key": "value"})
|
||||
self.assertIn("verifiers don't support extra options", "%s" % e)
|
||||
self.assertIn("verifiers don't support extra installation settings",
|
||||
"%s" % e)
|
||||
|
||||
# case #1 system-wide installation
|
||||
source = "https://github.com/example/example"
|
||||
|
@ -70,7 +70,7 @@ class VerifierManagerTestCase(test.TestCase):
|
||||
mock__meta_get.assert_called_once_with("context")
|
||||
mock_validate_args.assert_called_once_with(args)
|
||||
mock_context_manager_validate.assert_called_once_with(
|
||||
{"config": mock__meta_get.return_value})
|
||||
mock__meta_get.return_value)
|
||||
|
||||
def test__clone(self):
|
||||
verifier = mock.Mock(source=None)
|
||||
|
Loading…
Reference in New Issue
Block a user