Exemplo n.º 1
0
    def list_tempest_plugins(cls, deployment, system_wide=False):
        """List all installed Tempest plugins.

        :param deployment: UUID or name of a deployment
        :param system_wide: List all plugins installed in the local env or
                            in Tempest virtual env
        """
        deployment_uuid = objects.Deployment.get(deployment)["uuid"]
        verifier = tempest.Tempest(deployment_uuid, system_wide=system_wide)

        cls._check_tempest_tree_existence(verifier)

        return verifier.list_plugins()
Exemplo n.º 2
0
    def setUp(self):
        super(BaseTestCase, self).setUp()
        self.base_repo_patcher = mock.patch.object(tempest.Tempest,
                                                   "base_repo", "foo-baserepo")
        self.base_repo_dir_patcher = mock.patch.object(tempest.Tempest,
                                                       "base_repo_dir",
                                                       "foo-baserepodir")
        self.verifier = tempest.Tempest("fake_deployment_id",
                                        verification=mock.MagicMock())

        self.verifier._path = "/tmp"
        self.verifier.config_file = "/tmp/tempest.conf"
        self.verifier.log_file_raw = "/tmp/subunit.stream"
Exemplo n.º 3
0
 def setUp(self):
     super(TempestScenarioTestCase, self).setUp()
     self.verifier = verifier.Tempest("fake_uuid")
     self.verifier.log_file_raw = "/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()
Exemplo n.º 4
0
    def verify(cls,
               deployment,
               set_name="",
               regex=None,
               tests_file=None,
               tempest_config=None,
               expected_failures=None,
               system_wide=False,
               concur=0,
               failing=False):
        """Start verification.

        :param deployment: UUID or name of a deployment
        :param deployment: UUID or name of a deployment
        :param set_name: Name of a Tempest test set
        :param regex: Regular expression of test
        :param tests_file: Path to a file with a list of Tempest tests
        :param tempest_config: User specified Tempest config file location
        :param expected_failures: Dictionary with Tempest tests that are
                                  expected to fail. Keys are test names;
                                  values are reasons of test failures
        :param system_wide: 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
        :param concur: How many processes to use to run Tempest tests.
                       The default value (0) auto-detects CPU count
        :param failing: Re-run tests that failed during the last
                        execution
        :returns: Verification object
        """

        deployment_uuid = objects.Deployment.get(deployment)["uuid"]
        verification = objects.Verification(deployment_uuid=deployment_uuid)
        verifier = tempest.Tempest(deployment_uuid,
                                   verification=verification,
                                   tempest_config=tempest_config,
                                   system_wide=system_wide)

        cls._check_tempest_tree_existence(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,
                        expected_failures=expected_failures,
                        concur=concur,
                        failing=failing)

        return verification
Exemplo n.º 5
0
 def setUp(self):
     super(TempestScenarioTestCase, self).setUp()
     self.verifier = verifier.Tempest("fake_uuid")
     self.verifier.log_file_raw = "/dev/null"
     self.verifier.parse_results = mock.MagicMock()
     self.verifier.parse_results.return_value = mock.MagicMock(
         tests={}, total={"time": 0})
     self.context = test.get_test_context()
     self.context.update({
         "verifier": self.verifier,
         "tmp_results_dir": "/dev"
     })
     self.scenario = tempest.TempestScenario(self.context)
     self.scenario._add_atomic_actions = mock.MagicMock()
Exemplo n.º 6
0
    def uninstall_tempest_plugin(cls,
                                 deployment,
                                 repo_name,
                                 system_wide=False):
        """Uninstall Tempest plugin.

        :param deployment: UUID or name of a deployment
        :param repo_name: Plugin repo name
        :param system_wide: Uninstall plugin from Tempest virtual env or
                            from the local env
        """
        deployment_uuid = objects.Deployment.get(deployment)["uuid"]
        verifier = tempest.Tempest(deployment_uuid, system_wide=system_wide)
        verifier.uninstall_plugin(repo_name)
Exemplo n.º 7
0
    def discover_tests(cls, deployment, pattern="", system_wide=False):
        """Get a list of discovered tests.

        :param deployment: UUID or name of a deployment
        :param pattern: Test name pattern which can be used to match
        :param system_wide: Discover tests for system-wide or venv
                            Tempest installation
        """
        deployment_uuid = objects.Deployment.get(deployment)["uuid"]
        verifier = tempest.Tempest(deployment_uuid, system_wide=system_wide)

        cls._check_tempest_tree_existence(verifier)

        return verifier.discover_tests(pattern)
Exemplo n.º 8
0
    def install_tempest(cls, deployment, source=None, version=None,
                        system_wide=False):
        """Install Tempest.

        :param deployment: UUID or name of a deployment
        :param source: Path/URL to repo to clone Tempest from
        :param version: Commit ID or tag to checkout before Tempest
                        installation
        :param system_wide: Whether or not to install Tempest package and
                            create a Tempest virtual env
        """
        deployment_uuid = objects.Deployment.get(deployment)["uuid"]
        verifier = tempest.Tempest(deployment_uuid, source=source,
                                   version=version, system_wide=system_wide)
        verifier.install()
Exemplo n.º 9
0
    def reinstall_tempest(cls, deployment, tempest_config=None, source=None):
        """Uninstall Tempest and then reinstall from new source.

        :param deployment: UUID or name of the deployment
        :param tempest_config: Tempest config file. Use previous file as
        default
        :param source: Source to fetch Tempest from. Use old source as default
        """
        deployment_uuid = objects.Deployment.get(deployment)["uuid"]
        verifier = tempest.Tempest(deployment_uuid)
        if not tempest_config:
            config_path = verifier.config_file
            filename = os.path.basename(config_path)
            temp_location = tempfile.gettempdir()
            tmp_conf_path = os.path.join(temp_location, filename)
            shutil.copy2(config_path, tmp_conf_path)
        source = source or verifier.tempest_source
        verifier.uninstall()
        verifier = tempest.Tempest(deployment_uuid,
                                   source=source,
                                   tempest_config=tempest_config)
        verifier.install()
        if not tempest_config:
            shutil.move(tmp_conf_path, verifier.config_file)
Exemplo n.º 10
0
    def show_config_info(cls, deployment):
        """Get information about Tempest configuration file.

        :param deployment: UUID or name of a deployment
        """
        deployment_uuid = objects.Deployment.get(deployment)["uuid"]
        verifier = tempest.Tempest(deployment_uuid)

        cls._check_tempest_tree_existence(verifier)

        if not verifier.is_configured():
            verifier.generate_config_file()

        with open(verifier.config_file, "rb") as conf:
            return {"conf_data": conf.read(),
                    "conf_path": verifier.config_file}
Exemplo n.º 11
0
    def destroy(cls, deployment):
        """Destroy the deployment.

        :param deployment: UUID or name 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(deployment)
        deployer = deploy_engine.Engine.get_engine(
            deployment["config"]["type"], deployment)

        tempest.Tempest(deployment["uuid"]).uninstall()
        with deployer:
            deployer.make_cleanup()
            deployment.delete()
Exemplo n.º 12
0
    def configure_tempest(cls,
                          deployment,
                          tempest_config=None,
                          override=False):
        """Generate configuration file of Tempest.

        :param deployment: UUID or name of a deployment
        :param tempest_config: User specified Tempest config file location
        :param override: Whether or not to override existing Tempest
                         config file
        """
        deployment_uuid = objects.Deployment.get(deployment)["uuid"]
        verifier = tempest.Tempest(deployment_uuid,
                                   tempest_config=tempest_config)

        cls._check_tempest_tree_existence(verifier)

        verifier.generate_config_file(override)
Exemplo n.º 13
0
    def configure_tempest(cls, deployment, tempest_config=None,
                          extra_conf=None, override=False):
        """Generate Tempest configuration file.

        :param deployment: UUID or name of a deployment
        :param tempest_config: User specified Tempest config file location
        :param extra_conf: A ConfigParser() object with options to
                           extend/update Tempest config file
        :param override: Whether or not to override existing Tempest
                         config file
        """
        deployment_uuid = objects.Deployment.get(deployment)["uuid"]
        verifier = tempest.Tempest(deployment_uuid,
                                   tempest_config=tempest_config)

        cls._check_tempest_tree_existence(verifier)

        verifier.generate_config_file(extra_conf, override)
Exemplo n.º 14
0
    def import_results(cls, deployment, set_name="", log_file=None):
        """Import Tempest tests results into the Rally database.

        :param deployment: UUID or name of a deployment
        :param log_file: User specified Tempest log file in subunit format
        :returns: Deployment and verification objects
        """
        # TODO(aplanas): Create an external deployment if this is
        # missing, as required in the blueprint [1].
        # [1] https://blueprints.launchpad.net/rally/+spec/verification-import
        deployment_uuid = objects.Deployment.get(deployment)["uuid"]
        verification = objects.Verification(deployment_uuid=deployment_uuid)
        verifier = tempest.Tempest(deployment_uuid, verification=verification)

        LOG.info("Importing verification of deployment: %s" % deployment_uuid)
        verification.set_running()
        verifier.import_results(set_name=set_name, log_file=log_file)

        return deployment, verification
Exemplo n.º 15
0
    def install_tempest_plugin(cls, deployment, source=None, version=None,
                               system_wide=False):
        """Install Tempest plugin.

        :param deployment: UUID or name of a deployment
        :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: Install plugin in Tempest virtual env or
                            in the local env
        """
        deployment_uuid = objects.Deployment.get(deployment)["uuid"]
        verifier = tempest.Tempest(deployment_uuid,
                                   plugin_source=source,
                                   plugin_version=version,
                                   system_wide=system_wide)

        cls._check_tempest_tree_existence(verifier)

        verifier.install_plugin()
Exemplo n.º 16
0
def tempest_tests_exists(config, clients, deployment):
    """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(deployment["uuid"],
                               source=config.get("context",
                                                 {}).get("tempest",
                                                         {}).get("source"))
    if not verifier.is_installed():
        try:
            verifier.install()
        except tempest.TempestSetupFailure as e:
            return ValidationResult(False, e)
    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 wrong_tests:
        message = (_("One or more tests not found: '%s'") %
                   "', '".join(sorted(wrong_tests)))
        return ValidationResult(False, message)
Exemplo n.º 17
0
    def verify(cls,
               deployment,
               set_name="",
               regex=None,
               tests_file=None,
               tempest_config=None,
               expected_failures=None,
               system_wide=False,
               concur=0,
               failing=False):
        """Start verification.

        :param deployment: UUID or name of a deployment
        :param deployment: UUID or name of a deployment
        :param set_name: Name of a Tempest test set
        :param regex: Regular expression of test
        :param tests_file: Path to a file with a list of Tempest tests
        :param tempest_config: User specified Tempest config file location
        :param expected_failures: Dictionary with Tempest tests that are
                                  expected to fail. Keys are test names;
                                  values are reasons of test failures
        :param system_wide: 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
        :param concur: How many processes to use to run Tempest tests.
                       The default value (0) auto-detects CPU count
        :param failing: Re-run tests that failed during the last
                        execution
        :returns: Verification object
        """

        deployment_uuid = objects.Deployment.get(deployment)["uuid"]
        verification = objects.Verification(deployment_uuid=deployment_uuid)
        verifier = tempest.Tempest(deployment_uuid,
                                   verification=verification,
                                   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()

        LOG.info("Starting verification of deployment: %s" % deployment_uuid)
        verification.set_running()
        verifier.verify(set_name=set_name,
                        regex=regex,
                        tests_file=tests_file,
                        expected_failures=expected_failures,
                        concur=concur,
                        failing=failing)

        return verification