diff options
author | Juha Kosonen <juha.kosonen@nokia.com> | 2018-08-29 13:59:49 +0300 |
---|---|---|
committer | Juha Kosonen <juha.kosonen@nokia.com> | 2018-08-29 13:59:49 +0300 |
commit | 9d03fcdd488c385842b43fd914915cbe4ae5390a (patch) | |
tree | 351532ffcc95d4fd5d4c063016775ebf6e4fdae7 | |
parent | 04f5136a4f389ff4a2bc5d3cb7ee6b0b51c394f7 (diff) |
Create new project/user for tempest tests
JIRA: FUNCTEST-1009
Change-Id: I6b9bca3827ba6cc804c25689a896ca63eec6a78b
Signed-off-by: Juha Kosonen <juha.kosonen@nokia.com>
4 files changed, 37 insertions, 30 deletions
diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py index bf1a193b6..c428c78ce 100644 --- a/functest/opnfv_tests/openstack/tempest/conf_utils.py +++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py @@ -105,19 +105,17 @@ def get_verifier_id(): """ Returns verifier id for current Tempest """ - create_rally_deployment() - create_verifier() cmd = ("rally verify list-verifiers | awk '/" + getattr(config.CONF, 'tempest_verifier_name') + "/ {print $2}'") proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - deployment_uuid = proc.stdout.readline().rstrip() - if deployment_uuid == "": + verifier_uuid = proc.stdout.readline().rstrip() + if verifier_uuid == "": LOGGER.error("Tempest verifier not found.") raise Exception('Error with command:%s' % cmd) - return deployment_uuid + return verifier_uuid def get_verifier_deployment_id(): @@ -141,9 +139,6 @@ def get_verifier_repo_dir(verifier_id): """ Returns installed verifier repo directory for Tempest """ - if not verifier_id: - verifier_id = get_verifier_id() - return os.path.join(getattr(config.CONF, 'dir_rally_inst'), 'verification', 'verifier-{}'.format(verifier_id), @@ -154,12 +149,6 @@ def get_verifier_deployment_dir(verifier_id, deployment_id): """ Returns Rally deployment directory for current verifier """ - if not verifier_id: - verifier_id = get_verifier_id() - - if not deployment_id: - deployment_id = get_verifier_deployment_id() - return os.path.join(getattr(config.CONF, 'dir_rally_inst'), 'verification', 'verifier-{}'.format(verifier_id), diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py index 542ed9ed0..d38ee1e84 100644 --- a/functest/opnfv_tests/openstack/tempest/tempest.py +++ b/functest/opnfv_tests/openstack/tempest/tempest.py @@ -31,7 +31,7 @@ from functest.utils import env LOGGER = logging.getLogger(__name__) -class TempestCommon(singlevm.VmReady1): +class TempestCommon(singlevm.VmReady2): # pylint: disable=too-many-instance-attributes """TempestCommon testcases implementation class.""" @@ -43,6 +43,27 @@ class TempestCommon(singlevm.VmReady1): 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"): + role_name = "admin" + elif self.orig_cloud.get_role("Admin"): + role_name = "Admin" + else: + raise Exception("Cannot detect neither admin nor Admin") + self.orig_cloud.grant_role( + role_name, user=self.project.user.id, + project=self.project.project.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) + conf_utils.create_rally_deployment(environ=environ) + conf_utils.create_verifier() self.verifier_id = conf_utils.get_verifier_id() self.verifier_repo_dir = conf_utils.get_verifier_repo_dir( self.verifier_id) diff --git a/functest/tests/unit/openstack/tempest/test_conf_utils.py b/functest/tests/unit/openstack/tempest/test_conf_utils.py index 81febd8c0..7d94b88cc 100644 --- a/functest/tests/unit/openstack/tempest/test_conf_utils.py +++ b/functest/tests/unit/openstack/tempest/test_conf_utils.py @@ -106,26 +106,16 @@ class OSTempestConfUtilsTesting(unittest.TestCase): def test_get_verif_repo_dir_default(self): with mock.patch('functest.opnfv_tests.openstack.tempest.' 'conf_utils.os.path.join', - return_value='test_verifier_repo_dir'), \ - mock.patch('functest.opnfv_tests.openstack.tempest.' - 'conf_utils.get_verifier_id') as mock_get_id: + return_value='test_verifier_repo_dir'): self.assertEqual(conf_utils.get_verifier_repo_dir(''), 'test_verifier_repo_dir') - self.assertTrue(mock_get_id.called) def test_get_depl_dir_default(self): with mock.patch('functest.opnfv_tests.openstack.tempest.' 'conf_utils.os.path.join', - return_value='test_verifier_repo_dir'), \ - mock.patch('functest.opnfv_tests.openstack.tempest.' - 'conf_utils.get_verifier_id') as mock_get_vid, \ - mock.patch('functest.opnfv_tests.openstack.tempest.' - 'conf_utils.get_verifier_deployment_id') \ - as mock_get_did: + return_value='test_verifier_repo_dir'): self.assertEqual(conf_utils.get_verifier_deployment_dir('', ''), 'test_verifier_repo_dir') - self.assertTrue(mock_get_vid.called) - self.assertTrue(mock_get_did.called) def _test_missing_param(self, params, image_id, flavor_id, alt=False): with mock.patch('six.moves.configparser.RawConfigParser.' diff --git a/functest/tests/unit/openstack/tempest/test_tempest.py b/functest/tests/unit/openstack/tempest/test_tempest.py index a542bbb25..c87c0b085 100644 --- a/functest/tests/unit/openstack/tempest/test_tempest.py +++ b/functest/tests/unit/openstack/tempest/test_tempest.py @@ -23,9 +23,16 @@ class OSTempestTesting(unittest.TestCase): # pylint: disable=too-many-public-methods def setUp(self): - with mock.patch('functest.opnfv_tests.openstack.tempest.tempest.' - 'conf_utils.get_verifier_id', - return_value='test_deploy_id'), \ + with mock.patch('os_client_config.get_config'), \ + mock.patch('shade.OpenStackCloud'), \ + mock.patch('functest.core.tenantnetwork.NewProject'), \ + mock.patch('functest.opnfv_tests.openstack.tempest.tempest.' + 'conf_utils.create_rally_deployment'), \ + mock.patch('functest.opnfv_tests.openstack.tempest.tempest.' + 'conf_utils.create_verifier'), \ + mock.patch('functest.opnfv_tests.openstack.tempest.tempest.' + 'conf_utils.get_verifier_id', + return_value='test_deploy_id'), \ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.' 'conf_utils.get_verifier_deployment_id', return_value='test_deploy_id'), \ |