[Verify] Don't install Tempest when rally verify [gen/show]config

We shouldn't install Tempest when we execute `rally verify [gen/show]config`
because user should explicitly install Tempest by one of two ways:

    1. install Tempest using URL to a git repo;
    2. Install Tempest from a local git repo.

The _create_verifier method was removed.

Change-Id: If29d0ecd5d7906e80f5480128e35eec8f546520e
This commit is contained in:
Yaroslav Lobankov 2015-12-03 01:01:57 +03:00
parent 8e374ae1c1
commit 180b57acc3
2 changed files with 58 additions and 35 deletions

View File

@ -374,35 +374,11 @@ class Verification(object):
"""
deployment_uuid = objects.Deployment.get(deployment)["uuid"]
verification = objects.Verification(deployment_uuid=deployment_uuid)
verifier = cls._create_verifier(deployment_uuid, verification,
tempest_config, system_wide_install)
LOG.info("Starting verification of deployment: %s" % deployment_uuid)
verification.set_running()
verifier.verify(set_name=set_name, regex=regex,
tests_file=tests_file)
return verification
@staticmethod
def _create_verifier(deployment_uuid, verification=None,
tempest_config=None, system_wide_install=False):
"""Create a Tempest object.
:param deployment_uuid: UUID or name of a deployment
:param verification: Verification object
:param tempest_config: User specified Tempest config file location
:param system_wide_install: Whether or not to create a virtual env
when installing Tempest; whether or not to
use the local env instead of the Tempest
virtual env when running the tests
:returns: Tempest object
"""
verifier = tempest.Tempest(deployment_uuid, verification=verification,
tempest_config=tempest_config,
system_wide_install=system_wide_install)
if not verifier.is_installed():
LOG.info(_("Tempest is not installed "
"for the specified deployment."))
@ -410,7 +386,12 @@ class Verification(object):
"for deployment: %s") % deployment_uuid)
verifier.install()
return verifier
LOG.info("Starting verification of deployment: %s" % deployment_uuid)
verification.set_running()
verifier.verify(set_name=set_name, regex=regex,
tests_file=tests_file)
return verification
@classmethod
def import_results(cls, deployment, set_name="", log_file=None):
@ -485,6 +466,15 @@ class Verification(object):
if not tempest_config:
shutil.move(tmp_conf_path, verifier.config_file)
@staticmethod
def _check_tempest_tree_existence(verifier):
if not os.path.exists(verifier.path()):
msg = _("Tempest tree for "
"deployment '%s' not found! ") % verifier.deployment
LOG.error(
msg + _("Use `rally verify install` for Tempest installation"))
raise exceptions.NotFoundException(message=msg)
@classmethod
def configure_tempest(cls, deployment, tempest_config=None,
override=False):
@ -496,8 +486,11 @@ class Verification(object):
config file
"""
deployment_uuid = objects.Deployment.get(deployment)["uuid"]
verifier = cls._create_verifier(deployment_uuid,
tempest_config=tempest_config)
verifier = tempest.Tempest(deployment_uuid,
tempest_config=tempest_config)
cls._check_tempest_tree_existence(verifier)
verifier.generate_config_file(override)
@classmethod
@ -507,7 +500,10 @@ class Verification(object):
:param deployment: UUID or name of a deployment
"""
deployment_uuid = objects.Deployment.get(deployment)["uuid"]
verifier = cls._create_verifier(deployment_uuid)
verifier = tempest.Tempest(deployment_uuid)
cls._check_tempest_tree_existence(verifier)
if not verifier.is_configured():
verifier.generate_config_file()

View File

@ -494,18 +494,32 @@ class VerificationAPITestCase(BaseDeploymentTestCase):
self.tempest.install.assert_called_once_with()
mock_move.assert_called_once_with(tmp_file, fake_conf)
@mock.patch("os.path.exists", return_value=True)
@mock.patch("rally.common.objects.Deployment.get")
@mock.patch("rally.verification.tempest.tempest.Tempest")
def test_configure_tempest(self, mock_tempest, mock_deployment_get):
def test_configure_tempest_when_tempest_tree_exists(
self, mock_tempest, mock_deployment_get, mock_exists):
mock_tempest.return_value = self.tempest
api.Verification.configure_tempest(self.deployment_uuid)
self.tempest.generate_config_file.assert_called_once_with(False)
@mock.patch("six.moves.builtins.open", side_effect=mock.mock_open())
@mock.patch("os.path.exists", return_value=False)
@mock.patch("rally.common.objects.Deployment.get")
@mock.patch("rally.verification.tempest.tempest.Tempest")
def test_show_config_info_when_tempest_configured(
self, mock_tempest, mock_deployment_get, mock_open):
def test_configure_tempest_when_no_tempest_tree_exists(
self, mock_tempest, mock_deployment_get, mock_exists):
mock_tempest.return_value = self.tempest
self.assertRaises(exceptions.NotFoundException,
api.Verification.configure_tempest,
self.deployment_uuid)
self.assertEqual(0, self.tempest.generate_config_file.call_count)
@mock.patch("six.moves.builtins.open", side_effect=mock.mock_open())
@mock.patch("os.path.exists", return_value=True)
@mock.patch("rally.common.objects.Deployment.get")
@mock.patch("rally.verification.tempest.tempest.Tempest")
def test_show_config_info_when_tempest_tree_and_config_exist(
self, mock_tempest, mock_deployment_get, mock_exists, mock_open):
self.tempest.is_configured.return_value = True
self.tempest.config_file = "/path/to/fake/conf"
mock_tempest.return_value = self.tempest
@ -513,10 +527,11 @@ class VerificationAPITestCase(BaseDeploymentTestCase):
mock_open.assert_called_once_with("/path/to/fake/conf", "rb")
@mock.patch("six.moves.builtins.open", side_effect=mock.mock_open())
@mock.patch("os.path.exists", return_value=True)
@mock.patch("rally.common.objects.Deployment.get")
@mock.patch("rally.verification.tempest.tempest.Tempest")
def test_show_config_info_when_tempest_not_configured(
self, mock_tempest, mock_deployment_get, mock_open):
def test_show_config_info_when_tempest_tree_exists_and_config_doesnt(
self, mock_tempest, mock_deployment_get, mock_exists, mock_open):
self.tempest.is_configured.return_value = False
self.tempest.config_file = "/path/to/fake/conf"
mock_tempest.return_value = self.tempest
@ -524,6 +539,18 @@ class VerificationAPITestCase(BaseDeploymentTestCase):
self.tempest.generate_config_file.assert_called_once_with()
mock_open.assert_called_once_with("/path/to/fake/conf", "rb")
@mock.patch("six.moves.builtins.open", side_effect=mock.mock_open())
@mock.patch("os.path.exists", return_value=False)
@mock.patch("rally.common.objects.Deployment.get")
@mock.patch("rally.verification.tempest.tempest.Tempest")
def test_show_config_info_when_no_tempest_tree_exists(
self, mock_tempest, mock_deployment_get, mock_exists, mock_open):
mock_tempest.return_value = self.tempest
self.assertRaises(exceptions.NotFoundException,
api.Verification.show_config_info,
self.deployment_uuid)
self.assertEqual(0, mock_open.call_count)
@mock.patch("rally.common.objects.Verification.list")
def test_delete(self, mock_verification_list):
retval = api.Verification.list()