diff options
author | Juha Kosonen <juha.kosonen@nokia.com> | 2018-08-29 13:59:49 +0300 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-08-29 20:13:35 +0200 |
commit | 6f2eba2f3f82f2e145f293f4daf00564d5b312dd (patch) | |
tree | 4229a106eb1c8e9f69d8799d587a9a5283823d51 | |
parent | 53f29de06005a4c70c9a3816cddb98cf87c88757 (diff) |
Create new project/user for tempest tests
JIRA: FUNCTEST-1009
Change-Id: I6b9bca3827ba6cc804c25689a896ca63eec6a78b
Signed-off-by: Juha Kosonen <juha.kosonen@nokia.com>
(cherry picked from commit 9d03fcdd488c385842b43fd914915cbe4ae5390a)
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 3a7c3dad0..56c36a5c7 100644 --- a/functest/opnfv_tests/openstack/tempest/conf_utils.py +++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py @@ -106,19 +106,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(): @@ -142,9 +140,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), @@ -155,12 +150,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 934e6c6ef..9b4a48287 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 1493c2a35..86b0fa7bb 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'), \ |