def tempest_tests_exists(config, clients, task): """Validator checks that specified test exists.""" args = config.get("args", {}) if "test_name" in args: tests = [args["test_name"]] else: tests = args.get("test_names", []) if not tests: return ValidationResult( False, "Parameter 'test_name' or 'test_names' should " "be specified.") verifier = tempest.Tempest(task["deployment_uuid"]) if not verifier.is_installed(): verifier.install() if not verifier.is_configured(): verifier.generate_config_file() allowed_tests = verifier.discover_tests() for i, test in enumerate(tests): if not test.startswith("tempest.api."): tests[i] = "tempest.api." + test wrong_tests = set(tests) - allowed_tests if not wrong_tests: return ValidationResult() else: message = (_("One or more tests not found: '%s'") % "', '".join(sorted(wrong_tests))) return ValidationResult(False, message)
def setup(self): self.verifier = tempest.Tempest(self.task.task.deployment_uuid) self.verifier.log_file = "/dev/null" try: if not self.verifier.is_installed(): self.verifier.install() if not self.verifier.is_configured(): self.verifier.generate_config_file() except exceptions.TempestSetupFailure: msg = _("Failing to install tempest.") LOG.error(msg) raise exceptions.BenchmarkSetupFailure(msg) except exceptions.TempestConfigCreationFailure: msg = _("Failing to configure tempest.") LOG.error(msg) raise exceptions.BenchmarkSetupFailure(msg) self.context["verifier"] = self.verifier # Create temporary directory for xml-results. self.results_dir = os.path.join(tempfile.gettempdir(), "%s-results" % self.task.task.uuid) os.mkdir(self.results_dir) self.context["tmp_results_dir"] = self.results_dir
def tempest_test_exists_validator(**kwargs): verifier = tempest.Tempest(kwargs["task"].task.deployment_uuid) if not verifier.is_installed(): verifier.install() if not verifier.is_configured(): verifier.generate_config_file() allowed_tests = verifier.discover_tests() if "test_name" in kwargs: tests = [kwargs["test_name"]] else: tests = kwargs["test_names"] for test in tests: if (not test.startswith("tempest.api.") and test.split(".")[0] in consts.TEMPEST_TEST_SETS): tests[tests.index(test)] = "tempest.api." + test wrong_tests = set(tests) - allowed_tests if not wrong_tests: return ValidationResult() else: message = (_("One or more tests not found: '%s'") % "', '".join(sorted(wrong_tests))) return ValidationResult(False, message)
def tempest_test_exists_validator(**kwargs): verifier = tempest.Tempest(kwargs['task'].task.deployment_uuid) if not verifier.is_installed(): verifier.install() if not verifier.is_configured(): verifier.generate_config_file() allowed_tests = verifier.discover_tests() if 'test_name' in kwargs: tests = [kwargs['test_name']] else: tests = kwargs['test_names'] for test in tests: if not test.startswith('tempest.api.'): tests[tests.index(test)] = 'tempest.api.' + test wrong_tests = set(tests) - set(allowed_tests) if not wrong_tests: return ValidationResult() else: message = (_("One or more tests not found: '%s'") % "', '".join(wrong_tests)) return ValidationResult(False, message)
def setUp(self): super(BaseTestCase, self).setUp() self.verifier = tempest.Tempest('fake_deploy_id', verification=mock.MagicMock()) self.verifier._path = "/tmp" self.verifier.config_file = "/tmp/tempest.conf" self.verifier.log_file_raw = "/tmp/subunit.stream"
def setUp(self): super(TempestTestCase, self).setUp() self.verifier = tempest.Tempest('fake_deploy_id', verification=mock.MagicMock()) self.verifier.tempest_path = '/tmp' self.verifier.config_file = '/tmp/tempest.conf' self.verifier.log_file_raw = '/tmp/subunit.stream' self.regex = None
def setUp(self): super(TempestScenarioTestCase, self).setUp() self.verifier = verifier.Tempest("fake_uuid") self.verifier.log_file = "/dev/null" self.verifier.parse_results = mock.MagicMock() self.verifier.parse_results.return_value = ({"fake": True}, {"have_results": True}) self.context = {"verifier": self.verifier, "tmp_results_dir": "/dev"} self.scenario = tempest.TempestScenario(self.context) self.scenario._add_atomic_actions = mock.MagicMock()
def destroy_deploy(deploy_uuid): """Destroy the deployment. :param deploy_uuid: UUID of the deployment """ # TODO(akscram): We have to be sure that there are no running # tasks for this deployment. # TODO(akscram): Check that the deployment have got a status that # is equal to "*->finished" or "deploy->inconsistent". deployment = objects.Deployment.get(deploy_uuid) deployer = deploy.EngineFactory.get_engine(deployment['config']['type'], deployment) with deployer: deployer.make_cleanup() deployment.delete() tempest.Tempest(deploy_uuid).uninstall()
def verify(deploy_id, set_name, regex): """Start verifying. :param deploy_id: a UUID of a deployment. :param set_name: Valid name of tempest test set. :param regex: Regular expression of test """ verification = objects.Verification(deployment_uuid=deploy_id) verifier = tempest.Tempest(deploy_id, verification=verification) if not verifier.is_installed(): print("Tempest is not installed for specified deployment.") print("Installing Tempest for deployment %s" % deploy_id) verifier.install() LOG.info("Starting verification of deployment: %s" % deploy_id) verification.set_running() verifier.verify(set_name=set_name, regex=regex)
def setup(self): self.verifier = tempest.Tempest(self.task.task.deployment_uuid) self.verifier.log_file = "/dev/null" try: if not self.verifier.is_installed(): self.verifier.install() if not self.verifier.is_configured(): self.verifier.generate_config_file() except exceptions.TempestSetupFailure: msg = _("Failing to install tempest.") LOG.error(msg) raise exceptions.BenchmarkSetupFailure(msg) except exceptions.TempestConfigCreationFailure: msg = _("Failing to configure tempest.") LOG.error(msg) raise exceptions.BenchmarkSetupFailure(msg) self.context["verifier"] = self.verifier
def install(self, deploy_id=None): """Install tempest.""" verifier = tempest.Tempest(deploy_id) verifier.install()
def setUp(self): super(TempestScenarioTestCase, self).setUp() self.verifier = verifier.Tempest("fake_uuid") self.verifier.log_file = "/dev/null" self.context = {"verifier": self.verifier} self.scenario = tempest.TempestScenario(self.context)