Merge "[Verify] Don't install Tempest when rally verify start"

This commit is contained in:
Jenkins 2016-05-03 17:47:58 +00:00 committed by Gerrit Code Review
commit f16350bb4f
5 changed files with 82 additions and 123 deletions

View File

@ -370,6 +370,15 @@ class Task(object):
class Verification(object):
@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 verify(cls, deployment, set_name="", regex=None, tests_file=None,
tempest_config=None, expected_failures=None, system_wide=False,
@ -403,17 +412,7 @@ class Verification(object):
tempest_config=tempest_config,
system_wide=system_wide)
if not verifier.is_installed():
LOG.warning("Installation of Tempest will be deprecated and "
"removed in the future when executing the `rally "
"verify start` command. To install Tempest please "
"start to use the `rally verify install` command "
"before `rally verify start`.")
LOG.info(_("Tempest is not installed "
"for the specified deployment."))
LOG.info(_("Installing Tempest "
"for deployment: %s") % deployment_uuid)
verifier.install()
cls._check_tempest_tree_existence(verifier)
LOG.info("Starting verification of deployment: %s" % deployment_uuid)
verification.set_running()
@ -492,15 +491,6 @@ class Verification(object):
verifier = tempest.Tempest(deployment_uuid)
return verifier.discover_tests(pattern)
@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):

View File

@ -227,13 +227,17 @@ class Tempest(object):
"""
if not self.is_configured() or override:
if not override:
LOG.info(_("Tempest is not configured."))
LOG.info(_("Tempest is not configured "
"for deployment: %s") % self.deployment)
LOG.info(_("Starting: Creating configuration file for Tempest."))
LOG.info(_("Creating Tempest configuration "
"file for deployment: %s") % self.deployment)
config.TempestConfig(self.deployment).generate(self.config_file)
LOG.info(_("Completed: Creating configuration file for Tempest."))
LOG.info(_("Tempest configuration file "
"has been successfully created!"))
else:
LOG.info("Tempest is already configured.")
LOG.info(_("Tempest is already configured "
"for deployment: %s") % self.deployment)
def _initialize_testr(self):
if not os.path.isdir(self.path(".testrepository")):
@ -269,6 +273,10 @@ class Tempest(object):
def install(self):
"""Creates local Tempest repo and virtualenv for deployment."""
if not self.is_installed():
LOG.info(_("Tempest is not installed "
"for deployment: %s") % self.deployment)
LOG.info(_("Installing Tempest "
"for deployment: %s") % self.deployment)
try:
if not os.path.exists(self.path()):
if not self._is_git_repo(self.base_repo):
@ -336,9 +344,14 @@ class Tempest(object):
:param concur: How many processes to use to run Tempest tests.
The default value (0) auto-detects CPU count
"""
if tempest_conf and os.path.isfile(tempest_conf):
if tempest_conf:
self.config_file = tempest_conf
LOG.info(_("Tempest config file: %s") % self.config_file)
if os.path.isfile(self.config_file):
LOG.info(_("Using Tempest config file: %s") % self.config_file)
else:
msg = _("Tempest config file '%s' not found!") % self.config_file
LOG.error(msg)
raise exceptions.NotFoundException(message=msg)
concur_args = "--concurrency %d" % concur
if concur != 1:

View File

@ -49,11 +49,12 @@ class TempestScenarioTestCase(test.TestCase):
"tests": " ".join(tests)
})
@mock.patch("os.path.isfile", return_value=True)
@mock.patch(TS + ".utils.tempfile")
@mock.patch(VERIFIER + ".subprocess")
@mock.patch(TEMPEST_DIR + ".config.TempestResourcesContext")
def test_single_test(self, mock_tempest_resources_context,
mock_subprocess, mock_tempfile):
mock_subprocess, mock_tempfile, mock_isfile):
mock_tempfile.NamedTemporaryFile().name = "/dev/null"
fake_test = "tempest.api.fake.test"
@ -64,11 +65,12 @@ class TempestScenarioTestCase(test.TestCase):
expected_call, cwd=self.verifier.path(),
env=self.verifier.env, shell=True)
@mock.patch("os.path.isfile", return_value=True)
@mock.patch(TS + ".utils.tempfile")
@mock.patch(VERIFIER + ".subprocess")
@mock.patch(TEMPEST_DIR + ".config.TempestResourcesContext")
def test_single_test_negative(self, mock_tempest_resources_context,
mock_subprocess, mock_tempfile):
mock_subprocess, mock_tempfile, mock_isfile):
mock_tempfile.NamedTemporaryFile().name = "/dev/null"
fake_test = "tempest.api.network"
@ -79,11 +81,13 @@ class TempestScenarioTestCase(test.TestCase):
expected_call, cwd=self.verifier.path(),
env=self.verifier.env, shell=True)
@mock.patch("os.path.isfile", return_value=True)
@mock.patch(TS + ".utils.tempfile")
@mock.patch(VERIFIER + ".subprocess")
@mock.patch(TEMPEST_DIR + ".config.TempestResourcesContext")
def test_single_test_without_prefix(self, mock_tempest_resources_context,
mock_subprocess, mock_tempfile):
mock_subprocess, mock_tempfile,
mock_isfile):
mock_tempfile.NamedTemporaryFile().name = "/dev/null"
self.scenario.single_test("network")
@ -93,11 +97,12 @@ class TempestScenarioTestCase(test.TestCase):
expected_call, cwd=self.verifier.path(),
env=self.verifier.env, shell=True)
@mock.patch("os.path.isfile", return_value=True)
@mock.patch(TS + ".utils.tempfile")
@mock.patch(VERIFIER + ".subprocess")
@mock.patch(TEMPEST_DIR + ".config.TempestResourcesContext")
def test_all(self, mock_tempest_resources_context,
mock_subprocess, mock_tempfile):
mock_subprocess, mock_tempfile, mock_isfile):
mock_tempfile.NamedTemporaryFile().name = "/dev/null"
self.scenario.all()
@ -107,11 +112,12 @@ class TempestScenarioTestCase(test.TestCase):
expected_call, cwd=self.verifier.path(),
env=self.verifier.env, shell=True)
@mock.patch("os.path.isfile", return_value=True)
@mock.patch(TS + ".utils.tempfile")
@mock.patch(VERIFIER + ".subprocess")
@mock.patch(TEMPEST_DIR + ".config.TempestResourcesContext")
def test_set_smoke(self, mock_tempest_resources_context,
mock_subprocess, mock_tempfile):
mock_subprocess, mock_tempfile, mock_isfile):
mock_tempfile.NamedTemporaryFile().name = "/dev/null"
self.scenario.set("smoke")
@ -121,11 +127,12 @@ class TempestScenarioTestCase(test.TestCase):
expected_call, cwd=self.verifier.path(),
env=self.verifier.env, shell=True)
@mock.patch("os.path.isfile", return_value=True)
@mock.patch(TS + ".utils.tempfile")
@mock.patch(VERIFIER + ".subprocess")
@mock.patch(TEMPEST_DIR + ".config.TempestResourcesContext")
def test_set_full(self, mock_tempest_resources_context,
mock_subprocess, mock_tempfile):
mock_subprocess, mock_tempfile, mock_isfile):
mock_tempfile.NamedTemporaryFile().name = "/dev/null"
self.scenario.set("full")
@ -135,10 +142,11 @@ class TempestScenarioTestCase(test.TestCase):
expected_call, cwd=self.verifier.path(),
env=self.verifier.env, shell=True)
@mock.patch("os.path.isfile", return_value=True)
@mock.patch(TS + ".utils.tempfile")
@mock.patch(TEMPEST_DIR + ".config.TempestResourcesContext")
def test_set_from_list(self, mock_tempest_resources_context,
mock_tempfile):
mock_tempfile, mock_isfile):
mock_tempfile.NamedTemporaryFile().name = "/dev/null"
fake_scenarios = ["network", "volume", "baremetal",
@ -155,11 +163,12 @@ class TempestScenarioTestCase(test.TestCase):
expected_call, cwd=self.verifier.path(),
env=self.verifier.env, shell=True)
@mock.patch("os.path.isfile", return_value=True)
@mock.patch(TS + ".utils.tempfile")
@mock.patch(VERIFIER + ".subprocess")
@mock.patch(TEMPEST_DIR + ".config.TempestResourcesContext")
def test_set_selective(self, mock_tempest_resources_context,
mock_subprocess, mock_tempfile):
mock_subprocess, mock_tempfile, mock_isfile):
mock_tempfile.NamedTemporaryFile().name = "/dev/null"
self.scenario.set("network")
@ -169,11 +178,12 @@ class TempestScenarioTestCase(test.TestCase):
expected_call, cwd=self.verifier.path(),
env=self.verifier.env, shell=True)
@mock.patch("os.path.isfile", return_value=True)
@mock.patch(TS + ".utils.tempfile")
@mock.patch(VERIFIER + ".subprocess")
@mock.patch(TEMPEST_DIR + ".config.TempestResourcesContext")
def test_list_of_tests(self, mock_tempest_resources_context,
mock_subprocess, mock_tempfile):
mock_subprocess, mock_tempfile, mock_isfile):
mock_tempfile.NamedTemporaryFile().name = "/dev/null"
fake_tests = ["tempest.fake.test1", "tempest.fake.test2"]
@ -184,11 +194,12 @@ class TempestScenarioTestCase(test.TestCase):
expected_call, cwd=self.verifier.path(),
env=self.verifier.env, shell=True)
@mock.patch("os.path.isfile", return_value=True)
@mock.patch(TS + ".utils.tempfile")
@mock.patch(VERIFIER + ".subprocess")
@mock.patch(TEMPEST_DIR + ".config.TempestResourcesContext")
def test_specific_regex(self, mock_tempest_resources_context,
mock_subprocess, mock_tempfile):
mock_subprocess, mock_tempfile, mock_isfile):
mock_tempfile.NamedTemporaryFile().name = "/dev/null"
regex = "tempest.fake.test1"

View File

@ -413,38 +413,18 @@ class VerificationAPITestCase(BaseDeploymentTestCase):
super(VerificationAPITestCase, self).setUp()
self.tempest = mock.Mock()
@mock.patch("os.path.exists", return_value=True)
@mock.patch("rally.common.objects.Deployment.get")
@mock.patch("rally.api.objects.Verification")
@mock.patch("rally.verification.tempest.tempest.Tempest")
def test_verify(self, mock_tempest, mock_verification,
mock_deployment_get):
mock_deployment_get, mock_exists):
mock_deployment_get.return_value = {"uuid": self.deployment_uuid}
mock_tempest.return_value = self.tempest
self.tempest.is_installed.return_value = True
api.Verification.verify(
self.deployment_uuid, set_name="smoke",
regex=None, tests_file=None, tempest_config=None)
self.tempest.is_installed.assert_called_once_with()
self.tempest.verify.assert_called_once_with(
set_name="smoke", regex=None, tests_file=None,
expected_failures=None, concur=0, failing=False)
@mock.patch("rally.api.objects.Deployment.get")
@mock.patch("rally.api.objects.Verification")
@mock.patch("rally.verification.tempest.tempest.Tempest")
def test_verify_tempest_not_installed(self, mock_tempest,
mock_verification,
mock_deployment_get):
mock_deployment_get.return_value = {"uuid": self.deployment_uuid}
mock_tempest.return_value = self.tempest
self.tempest.is_installed.return_value = False
api.Verification.verify(
self.deployment_uuid, set_name="smoke",
regex=None, tests_file=None, tempest_config=None)
self.tempest.is_installed.assert_called_once_with()
self.tempest.install.assert_called_once_with()
self.tempest.verify.assert_called_once_with(
set_name="smoke", regex=None, tests_file=None,
expected_failures=None, concur=0, failing=False)
@ -457,7 +437,6 @@ class VerificationAPITestCase(BaseDeploymentTestCase):
mock_deployment_get, mock_exists):
mock_deployment_get.return_value = {"uuid": self.deployment_uuid}
mock_tempest.return_value = self.tempest
self.tempest.is_installed.return_value = True
tests_file = "/path/to/tests/file"
api.Verification.verify(
self.deployment_uuid, set_name="", regex=None,
@ -467,6 +446,16 @@ class VerificationAPITestCase(BaseDeploymentTestCase):
set_name="", regex=None, tests_file=tests_file,
expected_failures=None, concur=0, failing=False)
@mock.patch("rally.api.objects.Deployment.get")
@mock.patch("rally.api.objects.Verification")
def test_verify_no_tempest_tree_exists(self, mock_verification,
mock_deployment_get):
mock_deployment_get.return_value = {"uuid": self.deployment_uuid}
self.assertRaises(
exceptions.NotFoundException, api.Verification.verify,
self.deployment_uuid, set_name="smoke", regex=None,
tests_file=None, tempest_config=None)
@mock.patch("rally.common.objects.Deployment.get")
@mock.patch("rally.api.objects.Verification")
@mock.patch("rally.verification.tempest.tempest.Tempest")

View File

@ -344,57 +344,24 @@ class TempestVerifyTestCase(BaseTestCase):
"testr_args": testr_args,
"log_file": self.verifier.path("subunit.stream")})
@mock.patch(TEMPEST_PATH + ".tempest.Tempest.parse_results",
return_value=None)
@mock.patch(TEMPEST_PATH + ".tempest.Tempest.env")
@mock.patch(TEMPEST_PATH + ".tempest.subprocess")
@mock.patch(TEMPEST_PATH + ".config.TempestResourcesContext")
@mock.patch(TEMPEST_PATH + ".config.TempestConfig")
@mock.patch(TEMPEST_PATH + ".tempest.Tempest.is_configured",
return_value=False)
def test_verify_not_configured(
self, mock_tempest_is_configured, mock_tempest_config,
mock_tempest_resources_context, mock_subprocess, mock_tempest_env,
mock_tempest_parse_results):
set_name = "compute"
fake_call = self._get_fake_call("tempest.api.%s" % set_name)
self.verifier.verify(set_name, None, None, None, 0, False)
self.assertEqual(2, mock_tempest_is_configured.call_count)
mock_tempest_config.assert_called_once_with(self.verifier.deployment)
mock_tempest_config.return_value.generate.assert_called_once_with(
self.verifier.config_file
)
self.verifier.verification.start_verifying.assert_called_once_with(
set_name)
mock_subprocess.check_call.assert_called_once_with(
fake_call, env=mock_tempest_env, cwd=self.verifier.path(),
shell=True)
mock_tempest_parse_results.assert_called_once_with(None, None)
def test_verify_no_tempest_config_exists(self, mock_tempest_config):
self.assertRaises(exceptions.NotFoundException, self.verifier.verify,
"compute", None, None, None, 0, False)
@mock.patch(TEMPEST_PATH + ".tempest.Tempest.parse_results",
return_value=None)
@mock.patch(TEMPEST_PATH + ".tempest.Tempest.env")
@mock.patch(TEMPEST_PATH + ".tempest.subprocess")
@mock.patch(TEMPEST_PATH + ".config.TempestResourcesContext")
@mock.patch(TEMPEST_PATH + ".config.TempestConfig")
@mock.patch(TEMPEST_PATH + ".tempest.Tempest.is_configured",
return_value=True)
def test_verify_when_tempest_configured(
self, mock_tempest_is_configured, mock_tempest_config,
mock_tempest_resources_context, mock_subprocess, mock_tempest_env,
mock_tempest_parse_results):
@mock.patch("os.path.isfile", return_value=True)
def test_verify_tempest_config_exists(
self, mock_isfile, mock_tempest_resources_context, mock_subprocess,
mock_tempest_env, mock_tempest_parse_results):
set_name = "identity"
fake_call = self._get_fake_call("tempest.api.%s" % set_name)
self.verifier.verify(set_name, None, None, None, 0, False)
mock_tempest_is_configured.assert_called_once_with()
self.assertFalse(mock_tempest_config.called)
self.assertFalse(mock_tempest_config().generate.called)
self.verifier.verification.start_verifying.assert_called_once_with(
set_name)
@ -408,29 +375,22 @@ class TempestVerifyTestCase(BaseTestCase):
@mock.patch(TEMPEST_PATH + ".tempest.Tempest.env")
@mock.patch(TEMPEST_PATH + ".tempest.subprocess")
@mock.patch(TEMPEST_PATH + ".config.TempestResourcesContext")
@mock.patch(TEMPEST_PATH + ".config.TempestConfig")
@mock.patch(TEMPEST_PATH + ".tempest.Tempest.is_configured",
return_value=True)
def test_verify_failed_and_tempest_is_configured(
self, mock_tempest_is_configured, mock_tempest_config,
mock_tempest_resources_context, mock_subprocess, mock_tempest_env,
mock_tempest_parse_results):
@mock.patch("os.path.isfile", return_value=True)
def test_verify_failed_and_tempest_config_exists(
self, mock_isfile, mock_tempest_resources_context, mock_subprocess,
mock_tempest_env, mock_tempest_parse_results):
set_name = "identity"
fake_call = self._get_fake_call("tempest.api.%s" % set_name)
mock_subprocess.side_effect = subprocess.CalledProcessError
self.verifier.verify(set_name, None, None, None, 0, False)
mock_tempest_is_configured.assert_called_once_with()
self.assertFalse(mock_tempest_config.called)
self.assertFalse(mock_tempest_config().generate.called)
self.verifier.verification.start_verifying.assert_called_once_with(
set_name)
mock_subprocess.check_call.assert_called_once_with(
fake_call, env=mock_tempest_env, cwd=self.verifier.path(),
shell=True)
self.assertTrue(mock_tempest_parse_results.called)
mock_tempest_parse_results.assert_called_once_with(None, None)
self.verifier.verification.set_failed.assert_called_once_with()
@mock.patch(TEMPEST_PATH + ".tempest.Tempest.parse_results",
@ -438,10 +398,9 @@ class TempestVerifyTestCase(BaseTestCase):
@mock.patch(TEMPEST_PATH + ".tempest.Tempest.env")
@mock.patch(TEMPEST_PATH + ".tempest.subprocess")
@mock.patch(TEMPEST_PATH + ".config.TempestResourcesContext")
@mock.patch(TEMPEST_PATH + ".tempest.Tempest.is_configured",
return_value=True)
@mock.patch("os.path.isfile", return_value=True)
def test_verify_tests_file_specified(
self, mock_tempest_is_configured, mock_tempest_resources_context,
self, mock_isfile, mock_tempest_resources_context,
mock_subprocess, mock_tempest_env, mock_tempest_parse_results):
tests_file = "/path/to/tests/file"
fake_call = self._get_fake_call("--load-list %s" % tests_file)
@ -459,10 +418,9 @@ class TempestVerifyTestCase(BaseTestCase):
@mock.patch(TEMPEST_PATH + ".tempest.Tempest.env")
@mock.patch(TEMPEST_PATH + ".tempest.subprocess")
@mock.patch(TEMPEST_PATH + ".config.TempestResourcesContext")
@mock.patch(TEMPEST_PATH + ".tempest.Tempest.is_configured",
return_value=True)
@mock.patch("os.path.isfile", return_value=True)
def test_verify_concurrency_equals_to_1(
self, mock_tempest_is_configured, mock_tempest_resources_context,
self, mock_isfile, mock_tempest_resources_context,
mock_subprocess, mock_tempest_env, mock_tempest_parse_results):
set_name = "identity"
fake_call = self._get_fake_call(
@ -482,10 +440,9 @@ class TempestVerifyTestCase(BaseTestCase):
@mock.patch(TEMPEST_PATH + ".tempest.Tempest.env")
@mock.patch(TEMPEST_PATH + ".tempest.subprocess")
@mock.patch(TEMPEST_PATH + ".config.TempestResourcesContext")
@mock.patch(TEMPEST_PATH + ".tempest.Tempest.is_configured",
return_value=True)
@mock.patch("os.path.isfile", return_value=True)
def test_verify_concurrency_doesnt_equal_to_1(
self, mock_tempest_is_configured, mock_tempest_resources_context,
self, mock_isfile, mock_tempest_resources_context,
mock_subprocess, mock_tempest_env, mock_tempest_parse_results):
set_name = "identity"
fake_call = self._get_fake_call("tempest.api.%s" % set_name)
@ -504,9 +461,8 @@ class TempestVerifyTestCase(BaseTestCase):
@mock.patch(TEMPEST_PATH + ".tempest.Tempest.env")
@mock.patch(TEMPEST_PATH + ".tempest.subprocess")
@mock.patch(TEMPEST_PATH + ".config.TempestResourcesContext")
@mock.patch(TEMPEST_PATH + ".tempest.Tempest.is_configured",
return_value=True)
def test_verify_run_failed_tests_(self, mock_tempest_is_configured,
@mock.patch("os.path.isfile", return_value=True)
def test_verify_run_failed_tests_(self, mock_isfile,
mock_tempest_resources_context,
mock_subprocess, mock_tempest_env,
mock_tempest_parse_results):