Beispiel #1
0
 def run(self, **kwargs):
     """Run testcase."""
     self.start_time = time.time()
     try:
         assert super(RallyBase,
                      self).run(**kwargs) == testcase.TestCase.EX_OK
         environ = dict(os.environ,
                        OS_USERNAME=self.project.user.name,
                        OS_PROJECT_NAME=self.project.project.name,
                        OS_PROJECT_ID=self.project.project.id,
                        OS_PASSWORD=self.project.password)
         try:
             del environ['OS_TENANT_NAME']
             del environ['OS_TENANT_ID']
         except Exception:  # pylint: disable=broad-except
             pass
         conf_utils.create_rally_deployment(environ=environ)
         self.prepare_run()
         self.run_tests()
         self._generate_report()
         res = testcase.TestCase.EX_OK
     except Exception as exc:  # pylint: disable=broad-except
         LOGGER.error('Error with run: %s', exc)
         self.result = 0
         res = testcase.TestCase.EX_RUN_ERROR
     self.stop_time = time.time()
     return res
Beispiel #2
0
 def __init__(self, **kwargs):
     if "case_name" not in kwargs:
         kwargs["case_name"] = 'tempest'
     super(TempestCommon, self).__init__(**kwargs)
     assert self.orig_cloud
     assert self.cloud
     assert self.project
     if self.orig_cloud.get_role("admin"):
         self.role_name = "admin"
     elif self.orig_cloud.get_role("Admin"):
         self.role_name = "Admin"
     else:
         raise Exception("Cannot detect neither admin nor Admin")
     self.orig_cloud.grant_role(self.role_name,
                                user=self.project.user.id,
                                project=self.project.project.id,
                                domain=self.project.domain.id)
     self.orig_cloud.grant_role(self.role_name,
                                user=self.project.user.id,
                                domain=self.project.domain.id)
     environ = dict(os.environ,
                    OS_USERNAME=self.project.user.name,
                    OS_PROJECT_NAME=self.project.project.name,
                    OS_PROJECT_ID=self.project.project.id,
                    OS_PASSWORD=self.project.password)
     try:
         del environ['OS_TENANT_NAME']
         del environ['OS_TENANT_ID']
     except Exception:  # pylint: disable=broad-except
         pass
     self.deployment_id = conf_utils.create_rally_deployment(
         environ=environ)
     if not self.deployment_id:
         raise Exception("Deployment create failed")
     self.verifier_id = conf_utils.create_verifier()
     if not self.verifier_id:
         raise Exception("Verifier create failed")
     self.verifier_repo_dir = conf_utils.get_verifier_repo_dir(
         self.verifier_id)
     self.deployment_dir = conf_utils.get_verifier_deployment_dir(
         self.verifier_id, self.deployment_id)
     self.verification_id = None
     self.res_dir = os.path.join(getattr(config.CONF, 'dir_results'),
                                 self.case_name)
     self.raw_list = os.path.join(self.res_dir, 'test_raw_list.txt')
     self.list = os.path.join(self.res_dir, 'test_list.txt')
     self.conf_file = None
     self.image_alt = None
     self.flavor_alt = None
     self.services = []
     try:
         self.services = kwargs['run']['args']['services']
     except Exception:  # pylint: disable=broad-except
         pass
     self.neutron_extensions = []
     try:
         self.neutron_extensions = kwargs['run']['args'][
             'neutron_extensions']
     except Exception:  # pylint: disable=broad-except
         pass
Beispiel #3
0
    def run(self, **kwargs):
        """Run testcase."""
        self.start_time = time.time()
        try:
            conf_utils.create_rally_deployment()
            self._prepare_env()
            self._run_tests()
            self._generate_report()
            res = testcase.TestCase.EX_OK
        except Exception as exc:   # pylint: disable=broad-except
            LOGGER.error('Error with run: %s', exc)
            res = testcase.TestCase.EX_RUN_ERROR
        finally:
            self._clean_up()

        self.stop_time = time.time()
        return res
Beispiel #4
0
 def run(self, **kwargs):
     """Run testcase."""
     self.start_time = time.time()
     try:
         assert super(RallyBase,
                      self).run(**kwargs) == testcase.TestCase.EX_OK
         conf_utils.create_rally_deployment()
         self._prepare_env()
         self._run_tests()
         self._generate_report()
         res = testcase.TestCase.EX_OK
     except Exception as exc:  # pylint: disable=broad-except
         LOGGER.error('Error with run: %s', exc)
         self.result = 0
         res = testcase.TestCase.EX_RUN_ERROR
     self.stop_time = time.time()
     return res
Beispiel #5
0
    def test_create_rally_deployment(self, mock_exec, mock_exec_raise,
                                     mock_logger_info):

        conf_utils.create_rally_deployment()

        cmd = "rally deployment destroy opnfv-rally"
        error_msg = "Deployment %s does not exist." % \
                    CONST.__getattribute__('rally_deployment_name')
        mock_logger_info.assert_any_call("Creating Rally environment...")
        mock_exec.assert_any_call(cmd, error_msg=error_msg, verbose=False)

        cmd = "rally deployment create --fromenv --name="
        cmd += CONST.__getattribute__('rally_deployment_name')
        error_msg = "Problem while creating Rally deployment"
        mock_exec_raise.assert_any_call(cmd, error_msg=error_msg)

        cmd = "rally deployment check"
        error_msg = ("OpenStack not responding or " "faulty Rally deployment.")
        mock_exec_raise.assert_any_call(cmd, error_msg=error_msg)
Beispiel #6
0
 def test_create_rally_deployment(self, mock_exec, mock_get_id):
     # pylint: disable=unused-argument
     self.assertEqual(conf_utils.create_rally_deployment(), 'foo')
     calls = [
         mock.call(['rally', 'deployment', 'destroy', '--deployment',
                    str(getattr(config.CONF, 'rally_deployment_name'))]),
         mock.call(['rally', 'deployment', 'create', '--fromenv', '--name',
                    str(getattr(config.CONF, 'rally_deployment_name'))],
                   env=None),
         mock.call(['rally', 'deployment', 'check'])]
     mock_exec.assert_has_calls(calls)
Beispiel #7
0
 def test_create_rally_deployment(self, mock_exec):
     self.assertEqual(conf_utils.create_rally_deployment(), None)
     calls = [
         mock.call([
             'rally', 'deployment', 'destroy', '--deployment',
             str(getattr(config.CONF, 'rally_deployment_name'))
         ]),
         mock.call([
             'rally', 'deployment', 'create', '--fromenv', '--name',
             str(getattr(config.CONF, 'rally_deployment_name'))
         ]),
         mock.call(['rally', 'deployment', 'check'])
     ]
     mock_exec.assert_has_calls(calls)