Esempio n. 1
0
    def run(self, testr_args="", log_file=None, tempest_conf=None):
        """Run Tempest.

        :param testr_args: Arguments which will be passed to testr
        :param log_file: Path to a file for raw subunit stream logs.
                         If not specified, the value from "self.log_file_raw"
                         will be used as the path to the file
        :param tempest_conf: User specified Tempest config file location
        """
        if tempest_conf and os.path.isfile(tempest_conf):
            self.config_file = tempest_conf
        LOG.info(_("Tempest config file: %s") % self.config_file)

        test_cmd = ("%(venv)s testr run --subunit --parallel %(testr_args)s "
                    "| tee %(log_file)s "
                    "| %(venv)s subunit-trace -f -n" % {
                        "venv": self.venv_wrapper,
                        "testr_args": testr_args,
                        "log_file": log_file or self.log_file_raw
                    })
        # Create all resources needed for Tempest before running tests.
        # Once tests finish, all created resources will be deleted.
        with config.TempestResourcesContext(self.deployment, self.verification,
                                            self.config_file):
            # Run tests
            LOG.debug("Test(s) started by the command: %s" % test_cmd)
            subprocess.check_call(test_cmd,
                                  cwd=self.path(),
                                  env=self.env,
                                  shell=True)
    def setUp(self, mock_isfile, mock_clients_verified_keystone,
              mock_clients_services, mock_deployment_get):
        super(ConfigTestCase, self).setUp()

        self.endpoint = {
            "username": "******",
            "tenant_name": "test",
            "password": "******",
            "auth_url": "http://test/v2.0/",
            "permission": "admin",
            "admin_domain_name": "Default"
        }
        mock_deployment_get.return_value = {"admin": self.endpoint}

        self.deployment = "fake_deployment"
        self.conf_generator = config.TempestConfig(self.deployment)
        self.conf_generator.clients.services = mock_clients_services
        self.context = config.TempestResourcesContext(self.deployment,
                                                      "/path/to/fake/conf")
        self.context.conf.add_section("compute")

        keystone_patcher = mock.patch(
            "rally.osclients.Keystone._create_keystone_client")
        keystone_patcher.start()
        self.addCleanup(keystone_patcher.stop)
Esempio n. 3
0
    def setUp(self):
        super(TempestResourcesContextTestCase, self).setUp()

        mock.patch("rally.common.objects.deploy.db.deployment_get",
                   return_value=CREDS).start()
        mock.patch("rally.osclients.Clients").start()

        self.context = config.TempestResourcesContext("fake_deployment",
                                                      "/fake/path/to/config")
        self.context.conf.add_section("compute")
Esempio n. 4
0
    def setUp(self):
        super(TempestResourcesContextTestCase, self).setUp()

        mock.patch("rally.common.objects.deploy.db.deployment_get",
                   return_value=CREDS).start()
        mock.patch("rally.osclients.Clients").start()
        self.mock_isfile = mock.patch("os.path.isfile",
                                      return_value=True).start()

        fake_verification = {"uuid": "uuid"}
        self.context = config.TempestResourcesContext("fake_deployment",
                                                      fake_verification,
                                                      "/fake/path/to/config")
        self.context.conf.add_section("compute")
        self.context.conf.add_section("orchestration")
        self.context.conf.add_section("scenario")
Esempio n. 5
0
    def run(self, testr_args="", log_file=None, tempest_conf=None, concur=0):
        """Run Tempest.

        :param testr_args: Arguments which will be passed to testr
        :param log_file: Path to a file for raw subunit stream logs.
                         If not specified, the value from "self.log_file_raw"
                         will be used as the path to the file
        :param tempest_conf: User specified Tempest config file location
        :param concur: How many processes to use to run Tempest tests.
                       The default value (0) auto-detects CPU count
        """
        if tempest_conf:
            self.config_file = tempest_conf
        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:
            concur_args = "--parallel %s" % concur_args

        test_cmd = (
            "%(venv)s testr run --subunit %(concur_args)s %(testr_args)s "
            "| tee %(log_file)s "
            "| %(venv)s subunit-trace -f -n" % {
                "venv": self.venv_wrapper,
                "concur_args": concur_args,
                "testr_args": testr_args,
                "log_file": log_file or self.log_file_raw
            })
        # Discover or create all resources needed for Tempest before running
        # tests. Once tests finish, all created resources will be deleted.
        with config.TempestResourcesContext(self.deployment, self.verification,
                                            self.config_file):
            # Run tests
            LOG.debug("Test(s) started by the command: %s" % test_cmd)
            subprocess.check_call(test_cmd,
                                  cwd=self.path(),
                                  env=self.env,
                                  shell=True)
Esempio n. 6
0
    def run(self, testr_arg=None, log_file=None, tempest_conf=None):
        """Launch tempest with given arguments

        :param testr_arg: argument which will be transmitted into testr
        :type testr_arg: str
        :param log_file: file name for raw subunit results of tests. If not
                         specified, value from "self.log_file_raw"
                         will be chosen.
        :type log_file: str
        :param tempest_conf: User specified tempest.conf location
        :type tempest_conf: str

        :raises subprocess.CalledProcessError: if tests has been finished
                                               with error.
        """

        if tempest_conf and os.path.isfile(tempest_conf):
            self.config_file = tempest_conf
        LOG.info(_("Tempest config file: %s") % self.config_file)

        test_cmd = ("%(venv)s testr run --parallel --subunit %(arg)s "
                    "| tee %(log_file)s "
                    "| %(venv)s subunit-2to1 "
                    "| %(venv)s %(tempest_path)s/tools/colorizer.py" % {
                        "venv": self.venv_wrapper,
                        "arg": testr_arg,
                        "tempest_path": self.path(),
                        "log_file": log_file or self.log_file_raw
                    })
        LOG.debug("Test(s) started by the command: %s" % test_cmd)
        # Create all resources needed for Tempest before running tests.
        # Once tests finish, all created resources will be deleted.
        with config.TempestResourcesContext(self.deployment, self.config_file):
            # Run tests
            subprocess.check_call(test_cmd,
                                  cwd=self.path(),
                                  env=self.env,
                                  shell=True)