Merge "Refactor tempest scenarios tests"
diff --git a/requirements.txt b/requirements.txt
index b25b9d3..811580a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,7 +1,7 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
-pbr<2.0,>=1.6
+pbr>=1.6
cliff>=1.14.0 # Apache-2.0
anyjson>=0.3.3
httplib2>=0.7.5
@@ -22,6 +22,6 @@
iso8601>=0.1.9
fixtures>=1.3.1
testscenarios>=0.4
-tempest-lib>=0.6.1
+tempest-lib>=0.8.0
PyYAML>=3.1.0
stevedore>=1.5.0 # Apache-2.0
diff --git a/setup.py b/setup.py
index d8080d0..782bb21 100644
--- a/setup.py
+++ b/setup.py
@@ -25,5 +25,5 @@
pass
setuptools.setup(
- setup_requires=['pbr>=1.3'],
+ setup_requires=['pbr>=1.8'],
pbr=True)
diff --git a/tempest/api/compute/admin/test_live_migration.py b/tempest/api/compute/admin/test_live_migration.py
index 9d49124..34ec78d 100644
--- a/tempest/api/compute/admin/test_live_migration.py
+++ b/tempest/api/compute/admin/test_live_migration.py
@@ -14,6 +14,8 @@
# under the License.
+from collections import namedtuple
+
import testtools
from tempest.api.compute import base
@@ -24,6 +26,9 @@
CONF = config.CONF
+CreatedServer = namedtuple('CreatedServer', 'server_id, volume_backed')
+
+
class LiveBlockMigrationTestJSON(base.BaseV2ComputeAdminTest):
_host_key = 'OS-EXT-SRV-ATTR:host'
@@ -38,7 +43,9 @@
def resource_setup(cls):
super(LiveBlockMigrationTestJSON, cls).resource_setup()
- cls.created_server_ids = []
+ # list of CreatedServer namedtuples
+ # TODO(mriedem): Remove the instance variable and shared server re-use
+ cls.created_servers = []
def _get_compute_hostnames(self):
body = self.admin_hosts_client.list_hosts()['hosts']
@@ -56,7 +63,15 @@
return self._get_server_details(server_id)[self._host_key]
def _migrate_server_to(self, server_id, dest_host):
- bmflm = CONF.compute_feature_enabled.block_migration_for_live_migration
+ # volume backed instances shouldn't be block migrated
+ for id, volume_backed in self.created_servers:
+ if server_id == id:
+ use_block_migration = not volume_backed
+ break
+ else:
+ raise ValueError('Server with id %s not found.' % server_id)
+ bmflm = (CONF.compute_feature_enabled.
+ block_migration_for_live_migration and use_block_migration)
body = self.admin_servers_client.live_migrate_server(
server_id, host=dest_host, block_migration=bmflm,
disk_over_commit=False)
@@ -70,14 +85,18 @@
def _get_server_status(self, server_id):
return self._get_server_details(server_id)['status']
- def _get_an_active_server(self):
- for server_id in self.created_server_ids:
- if 'ACTIVE' == self._get_server_status(server_id):
+ def _get_an_active_server(self, volume_backed=False):
+ for server_id, vol_backed in self.created_servers:
+ if ('ACTIVE' == self._get_server_status(server_id) and
+ volume_backed == vol_backed):
return server_id
else:
- server = self.create_test_server(wait_until="ACTIVE")
+ server = self.create_test_server(wait_until="ACTIVE",
+ volume_backed=volume_backed)
server_id = server['id']
- self.created_server_ids.append(server_id)
+ new_server = CreatedServer(server_id=server_id,
+ volume_backed=volume_backed)
+ self.created_servers.append(new_server)
return server_id
def _volume_clean_up(self, server_id, volume_id):
@@ -87,20 +106,22 @@
self.volumes_client.wait_for_volume_status(volume_id, 'available')
self.volumes_client.delete_volume(volume_id)
- def _test_live_block_migration(self, state='ACTIVE'):
- """Tests live block migration between two hosts.
+ def _test_live_migration(self, state='ACTIVE', volume_backed=False):
+ """Tests live migration between two hosts.
Requires CONF.compute_feature_enabled.live_migration to be True.
:param state: The vm_state the migrated server should be in before and
after the live migration. Supported values are 'ACTIVE'
and 'PAUSED'.
+ :param volume_backed: If the instance is volume backed or not. If
+ volume_backed, *block* migration is not used.
"""
# Live block migrate an instance to another host
if len(self._get_compute_hostnames()) < 2:
raise self.skipTest(
"Less than 2 compute nodes, skipping migration test.")
- server_id = self._get_an_active_server()
+ server_id = self._get_an_active_server(volume_backed=volume_backed)
actual_host = self._get_host_for_server(server_id)
target_host = self._get_host_other_than(actual_host)
@@ -127,7 +148,7 @@
@testtools.skipUnless(CONF.compute_feature_enabled.live_migration,
'Live migration not available')
def test_live_block_migration(self):
- self._test_live_block_migration()
+ self._test_live_migration()
@test.idempotent_id('1e107f21-61b2-4988-8f22-b196e938ab88')
@testtools.skipUnless(CONF.compute_feature_enabled.live_migration,
@@ -139,7 +160,14 @@
'Live migration of paused instances is not '
'available.')
def test_live_block_migration_paused(self):
- self._test_live_block_migration(state='PAUSED')
+ self._test_live_migration(state='PAUSED')
+
+ @test.idempotent_id('5071cf17-3004-4257-ae61-73a84e28badd')
+ @testtools.skipUnless(CONF.compute_feature_enabled.live_migration,
+ 'Live migration not available')
+ @test.services('volume')
+ def test_volume_backed_live_migration(self):
+ self._test_live_migration(volume_backed=True)
@test.idempotent_id('e19c0cc6-6720-4ed8-be83-b6603ed5c812')
@testtools.skipIf(not CONF.compute_feature_enabled.live_migration or not
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 3952439..b0fdbac 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -203,13 +203,17 @@
server_group_id)
@classmethod
- def create_test_server(cls, validatable=False, **kwargs):
+ def create_test_server(cls, validatable=False, volume_backed=False,
+ **kwargs):
"""Wrapper utility that returns a test server.
This wrapper utility calls the common create test server and
returns a test server. The purpose of this wrapper is to minimize
the impact on the code of the tests already using this
function.
+
+ :param validatable: Whether the server will be pingable or sshable.
+ :param volume_backed: Whether the instance is volume backed or not.
"""
tenant_network = cls.get_tenant_network()
body, servers = compute.create_test_server(
@@ -217,6 +221,7 @@
validatable,
validation_resources=cls.validation_resources,
tenant_network=tenant_network,
+ volume_backed=volume_backed,
**kwargs)
cls.servers.extend(servers)
diff --git a/tempest/api/identity/admin/v2/test_endpoints.py b/tempest/api/identity/admin/v2/test_endpoints.py
index 3af2e90..bff4f91 100644
--- a/tempest/api/identity/admin/v2/test_endpoints.py
+++ b/tempest/api/identity/admin/v2/test_endpoints.py
@@ -27,9 +27,8 @@
s_name = data_utils.rand_name('service')
s_type = data_utils.rand_name('type')
s_description = data_utils.rand_name('description')
- cls.service_data =\
- cls.client.create_service(s_name, s_type,
- description=s_description)
+ cls.service_data = cls.client.create_service(
+ s_name, s_type, description=s_description)['OS-KSADM:service']
cls.service_id = cls.service_data['id']
cls.service_ids.append(cls.service_id)
# Create endpoints so as to use for LIST and GET test cases
@@ -41,7 +40,7 @@
region,
publicurl=url,
adminurl=url,
- internalurl=url)
+ internalurl=url)['endpoint']
# list_endpoints() will return 'enabled' field
endpoint['enabled'] = True
cls.setup_endpoints.append(endpoint)
@@ -57,7 +56,7 @@
@test.idempotent_id('11f590eb-59d8-4067-8b2b-980c7f387f51')
def test_list_endpoints(self):
# Get a list of endpoints
- fetched_endpoints = self.client.list_endpoints()
+ fetched_endpoints = self.client.list_endpoints()['endpoints']
# Asserting LIST endpoints
missing_endpoints =\
[e for e in self.setup_endpoints if e not in fetched_endpoints]
@@ -73,18 +72,18 @@
region,
publicurl=url,
adminurl=url,
- internalurl=url)
+ internalurl=url)['endpoint']
# Asserting Create Endpoint response body
self.assertIn('id', endpoint)
self.assertEqual(region, endpoint['region'])
self.assertEqual(url, endpoint['publicurl'])
# Checking if created endpoint is present in the list of endpoints
- fetched_endpoints = self.client.list_endpoints()
+ fetched_endpoints = self.client.list_endpoints()['endpoints']
fetched_endpoints_id = [e['id'] for e in fetched_endpoints]
self.assertIn(endpoint['id'], fetched_endpoints_id)
# Deleting the endpoint created in this method
self.client.delete_endpoint(endpoint['id'])
# Checking whether endpoint is deleted successfully
- fetched_endpoints = self.client.list_endpoints()
+ fetched_endpoints = self.client.list_endpoints()['endpoints']
fetched_endpoints_id = [e['id'] for e in fetched_endpoints]
self.assertNotIn(endpoint['id'], fetched_endpoints_id)
diff --git a/tempest/api/identity/admin/v2/test_roles.py b/tempest/api/identity/admin/v2/test_roles.py
index 0b28a07..78beead 100644
--- a/tempest/api/identity/admin/v2/test_roles.py
+++ b/tempest/api/identity/admin/v2/test_roles.py
@@ -27,7 +27,7 @@
super(RolesTestJSON, cls).resource_setup()
for _ in moves.xrange(5):
role_name = data_utils.rand_name(name='role')
- role = cls.client.create_role(role_name)
+ role = cls.client.create_role(role_name)['role']
cls.data.roles.append(role)
def _get_role_params(self):
@@ -48,7 +48,7 @@
@test.idempotent_id('75d9593f-50b7-4fcf-bd64-e3fb4a278e23')
def test_list_roles(self):
"""Return a list of all roles."""
- body = self.client.list_roles()
+ body = self.client.list_roles()['roles']
found = [role for role in body if role in self.data.roles]
self.assertTrue(any(found))
self.assertEqual(len(found), len(self.data.roles))
@@ -57,16 +57,16 @@
def test_role_create_delete(self):
"""Role should be created, verified, and deleted."""
role_name = data_utils.rand_name(name='role-test')
- body = self.client.create_role(role_name)
+ body = self.client.create_role(role_name)['role']
self.assertEqual(role_name, body['name'])
- body = self.client.list_roles()
+ body = self.client.list_roles()['roles']
found = [role for role in body if role['name'] == role_name]
self.assertTrue(any(found))
body = self.client.delete_role(found[0]['id'])
- body = self.client.list_roles()
+ body = self.client.list_roles()['roles']
found = [role for role in body if role['name'] == role_name]
self.assertFalse(any(found))
@@ -85,7 +85,7 @@
"""Assign a role to a user on a tenant."""
(user, tenant, role) = self._get_role_params()
self.client.assign_user_role(tenant['id'], user['id'], role['id'])
- roles = self.client.list_user_roles(tenant['id'], user['id'])
+ roles = self.client.list_user_roles(tenant['id'], user['id'])['roles']
self.assert_role_in_role_list(role, roles)
@test.idempotent_id('f0b9292c-d3ba-4082-aa6c-440489beef69')
@@ -93,7 +93,8 @@
"""Remove a role assigned to a user on a tenant."""
(user, tenant, role) = self._get_role_params()
user_role = self.client.assign_user_role(tenant['id'],
- user['id'], role['id'])
+ user['id'],
+ role['id'])['role']
self.client.remove_user_role(tenant['id'], user['id'],
user_role['id'])
@@ -102,5 +103,5 @@
"""List roles assigned to a user on tenant."""
(user, tenant, role) = self._get_role_params()
self.client.assign_user_role(tenant['id'], user['id'], role['id'])
- roles = self.client.list_user_roles(tenant['id'], user['id'])
+ roles = self.client.list_user_roles(tenant['id'], user['id'])['roles']
self.assert_role_in_role_list(role, roles)
diff --git a/tempest/api/identity/admin/v2/test_roles_negative.py b/tempest/api/identity/admin/v2/test_roles_negative.py
index b38b7dd..5932aba 100644
--- a/tempest/api/identity/admin/v2/test_roles_negative.py
+++ b/tempest/api/identity/admin/v2/test_roles_negative.py
@@ -78,7 +78,7 @@
def test_role_create_duplicate(self):
# Role names should be unique
role_name = data_utils.rand_name(name='role-dup')
- body = self.client.create_role(role_name)
+ body = self.client.create_role(role_name)['role']
role1_id = body.get('id')
self.addCleanup(self.client.delete_role, role1_id)
self.assertRaises(lib_exc.Conflict, self.client.create_role,
@@ -89,7 +89,7 @@
def test_delete_role_by_unauthorized_user(self):
# Non-administrator user should not be able to delete role
role_name = data_utils.rand_name(name='role')
- body = self.client.create_role(role_name)
+ body = self.client.create_role(role_name)['role']
self.data.roles.append(body)
role_id = body.get('id')
self.assertRaises(lib_exc.Forbidden,
@@ -100,7 +100,7 @@
def test_delete_role_request_without_token(self):
# Request to delete role without a valid token should fail
role_name = data_utils.rand_name(name='role')
- body = self.client.create_role(role_name)
+ body = self.client.create_role(role_name)['role']
self.data.roles.append(body)
role_id = body.get('id')
token = self.client.auth_provider.get_token()
diff --git a/tempest/api/identity/admin/v2/test_services.py b/tempest/api/identity/admin/v2/test_services.py
index ef93981..eebeedb 100644
--- a/tempest/api/identity/admin/v2/test_services.py
+++ b/tempest/api/identity/admin/v2/test_services.py
@@ -38,7 +38,7 @@
type = data_utils.rand_name('type')
description = data_utils.rand_name('description')
service_data = self.client.create_service(
- name, type, description=description)
+ name, type, description=description)['OS-KSADM:service']
self.assertFalse(service_data['id'] is None)
self.addCleanup(self._del_service, service_data['id'])
# Verifying response body of create service
@@ -50,7 +50,8 @@
self.assertIn('description', service_data)
self.assertEqual(description, service_data['description'])
# Get service
- fetched_service = self.client.get_service(service_data['id'])
+ fetched_service = (self.client.get_service(service_data['id'])
+ ['OS-KSADM:service'])
# verifying the existence of service created
self.assertIn('id', fetched_service)
self.assertEqual(fetched_service['id'], service_data['id'])
@@ -67,7 +68,7 @@
# Create a service only with name and type
name = data_utils.rand_name('service')
type = data_utils.rand_name('type')
- service = self.client.create_service(name, type)
+ service = self.client.create_service(name, type)['OS-KSADM:service']
self.assertIn('id', service)
self.addCleanup(self._del_service, service['id'])
self.assertIn('name', service)
@@ -85,7 +86,7 @@
type = data_utils.rand_name('type')
description = data_utils.rand_name('description')
service = self.client.create_service(
- name, type, description=description)
+ name, type, description=description)['OS-KSADM:service']
services.append(service)
service_ids = map(lambda x: x['id'], services)
@@ -95,6 +96,6 @@
self.addCleanup(delete_services)
# List and Verify Services
- body = self.client.list_services()
+ body = self.client.list_services()['OS-KSADM:services']
found = [serv for serv in body if serv['id'] in service_ids]
self.assertEqual(len(found), len(services), 'Services not found')
diff --git a/tempest/api/identity/admin/v2/test_tenant_negative.py b/tempest/api/identity/admin/v2/test_tenant_negative.py
index bccb5ca..74558d1 100644
--- a/tempest/api/identity/admin/v2/test_tenant_negative.py
+++ b/tempest/api/identity/admin/v2/test_tenant_negative.py
@@ -45,7 +45,7 @@
def test_tenant_delete_by_unauthorized_user(self):
# Non-administrator user should not be able to delete a tenant
tenant_name = data_utils.rand_name(name='tenant')
- tenant = self.client.create_tenant(tenant_name)
+ tenant = self.client.create_tenant(tenant_name)['tenant']
self.data.tenants.append(tenant)
self.assertRaises(lib_exc.Forbidden,
self.non_admin_client.delete_tenant, tenant['id'])
@@ -55,7 +55,7 @@
def test_tenant_delete_request_without_token(self):
# Request to delete a tenant without a valid token should fail
tenant_name = data_utils.rand_name(name='tenant')
- tenant = self.client.create_tenant(tenant_name)
+ tenant = self.client.create_tenant(tenant_name)['tenant']
self.data.tenants.append(tenant)
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
@@ -75,7 +75,7 @@
def test_tenant_create_duplicate(self):
# Tenant names should be unique
tenant_name = data_utils.rand_name(name='tenant')
- body = self.client.create_tenant(tenant_name)
+ body = self.client.create_tenant(tenant_name)['tenant']
tenant = body
self.data.tenants.append(tenant)
tenant1_id = body.get('id')
@@ -131,7 +131,7 @@
def test_tenant_update_by_unauthorized_user(self):
# Non-administrator user should not be able to update a tenant
tenant_name = data_utils.rand_name(name='tenant')
- tenant = self.client.create_tenant(tenant_name)
+ tenant = self.client.create_tenant(tenant_name)['tenant']
self.data.tenants.append(tenant)
self.assertRaises(lib_exc.Forbidden,
self.non_admin_client.update_tenant, tenant['id'])
@@ -141,7 +141,7 @@
def test_tenant_update_request_without_token(self):
# Request to update a tenant without a valid token should fail
tenant_name = data_utils.rand_name(name='tenant')
- tenant = self.client.create_tenant(tenant_name)
+ tenant = self.client.create_tenant(tenant_name)['tenant']
self.data.tenants.append(tenant)
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
diff --git a/tempest/api/identity/admin/v2/test_tenants.py b/tempest/api/identity/admin/v2/test_tenants.py
index 9fff5f3..2ec5c4f 100644
--- a/tempest/api/identity/admin/v2/test_tenants.py
+++ b/tempest/api/identity/admin/v2/test_tenants.py
@@ -28,7 +28,7 @@
tenants = []
for _ in moves.xrange(3):
tenant_name = data_utils.rand_name(name='tenant-new')
- tenant = self.client.create_tenant(tenant_name)
+ tenant = self.client.create_tenant(tenant_name)['tenant']
self.data.tenants.append(tenant)
tenants.append(tenant)
tenant_ids = map(lambda x: x['id'], tenants)
@@ -50,14 +50,14 @@
tenant_name = data_utils.rand_name(name='tenant')
tenant_desc = data_utils.rand_name(name='desc')
body = self.client.create_tenant(tenant_name,
- description=tenant_desc)
+ description=tenant_desc)['tenant']
tenant = body
self.data.tenants.append(tenant)
tenant_id = body['id']
desc1 = body['description']
self.assertEqual(desc1, tenant_desc, 'Description should have '
'been sent in response for create')
- body = self.client.get_tenant(tenant_id)
+ body = self.client.get_tenant(tenant_id)['tenant']
desc2 = body['description']
self.assertEqual(desc2, tenant_desc, 'Description does not appear'
'to be set')
@@ -68,13 +68,13 @@
def test_tenant_create_enabled(self):
# Create a tenant that is enabled
tenant_name = data_utils.rand_name(name='tenant')
- body = self.client.create_tenant(tenant_name, enabled=True)
+ body = self.client.create_tenant(tenant_name, enabled=True)['tenant']
tenant = body
self.data.tenants.append(tenant)
tenant_id = body['id']
en1 = body['enabled']
self.assertTrue(en1, 'Enable should be True in response')
- body = self.client.get_tenant(tenant_id)
+ body = self.client.get_tenant(tenant_id)['tenant']
en2 = body['enabled']
self.assertTrue(en2, 'Enable should be True in lookup')
self.client.delete_tenant(tenant_id)
@@ -84,14 +84,14 @@
def test_tenant_create_not_enabled(self):
# Create a tenant that is not enabled
tenant_name = data_utils.rand_name(name='tenant')
- body = self.client.create_tenant(tenant_name, enabled=False)
+ body = self.client.create_tenant(tenant_name, enabled=False)['tenant']
tenant = body
self.data.tenants.append(tenant)
tenant_id = body['id']
en1 = body['enabled']
self.assertEqual('false', str(en1).lower(),
'Enable should be False in response')
- body = self.client.get_tenant(tenant_id)
+ body = self.client.get_tenant(tenant_id)['tenant']
en2 = body['enabled']
self.assertEqual('false', str(en2).lower(),
'Enable should be False in lookup')
@@ -102,7 +102,7 @@
def test_tenant_update_name(self):
# Update name attribute of a tenant
t_name1 = data_utils.rand_name(name='tenant')
- body = self.client.create_tenant(t_name1)
+ body = self.client.create_tenant(t_name1)['tenant']
tenant = body
self.data.tenants.append(tenant)
@@ -110,11 +110,11 @@
resp1_name = body['name']
t_name2 = data_utils.rand_name(name='tenant2')
- body = self.client.update_tenant(t_id, name=t_name2)
+ body = self.client.update_tenant(t_id, name=t_name2)['tenant']
resp2_name = body['name']
self.assertNotEqual(resp1_name, resp2_name)
- body = self.client.get_tenant(t_id)
+ body = self.client.get_tenant(t_id)['tenant']
resp3_name = body['name']
self.assertNotEqual(resp1_name, resp3_name)
@@ -129,7 +129,7 @@
# Update description attribute of a tenant
t_name = data_utils.rand_name(name='tenant')
t_desc = data_utils.rand_name(name='desc')
- body = self.client.create_tenant(t_name, description=t_desc)
+ body = self.client.create_tenant(t_name, description=t_desc)['tenant']
tenant = body
self.data.tenants.append(tenant)
@@ -137,11 +137,11 @@
resp1_desc = body['description']
t_desc2 = data_utils.rand_name(name='desc2')
- body = self.client.update_tenant(t_id, description=t_desc2)
+ body = self.client.update_tenant(t_id, description=t_desc2)['tenant']
resp2_desc = body['description']
self.assertNotEqual(resp1_desc, resp2_desc)
- body = self.client.get_tenant(t_id)
+ body = self.client.get_tenant(t_id)['tenant']
resp3_desc = body['description']
self.assertNotEqual(resp1_desc, resp3_desc)
@@ -156,7 +156,7 @@
# Update the enabled attribute of a tenant
t_name = data_utils.rand_name(name='tenant')
t_en = False
- body = self.client.create_tenant(t_name, enabled=t_en)
+ body = self.client.create_tenant(t_name, enabled=t_en)['tenant']
tenant = body
self.data.tenants.append(tenant)
@@ -164,11 +164,11 @@
resp1_en = body['enabled']
t_en2 = True
- body = self.client.update_tenant(t_id, enabled=t_en2)
+ body = self.client.update_tenant(t_id, enabled=t_en2)['tenant']
resp2_en = body['enabled']
self.assertNotEqual(resp1_en, resp2_en)
- body = self.client.get_tenant(t_id)
+ body = self.client.get_tenant(t_id)['tenant']
resp3_en = body['enabled']
self.assertNotEqual(resp1_en, resp3_en)
diff --git a/tempest/api/identity/admin/v2/test_tokens.py b/tempest/api/identity/admin/v2/test_tokens.py
index 66d00d1..981a9ea 100644
--- a/tempest/api/identity/admin/v2/test_tokens.py
+++ b/tempest/api/identity/admin/v2/test_tokens.py
@@ -27,11 +27,11 @@
user_password = data_utils.rand_name(name='pass')
# first:create a tenant
tenant_name = data_utils.rand_name(name='tenant')
- tenant = self.client.create_tenant(tenant_name)
+ tenant = self.client.create_tenant(tenant_name)['tenant']
self.data.tenants.append(tenant)
# second:create a user
user = self.client.create_user(user_name, user_password,
- tenant['id'], '')
+ tenant['id'], '')['user']
self.data.users.append(user)
# then get a token for the user
body = self.token_client.auth(user_name,
@@ -41,7 +41,7 @@
tenant['name'])
# Perform GET Token
token_id = body['token']['id']
- token_details = self.client.get_token(token_id)
+ token_details = self.client.get_token(token_id)['access']
self.assertEqual(token_id, token_details['token']['id'])
self.assertEqual(user['id'], token_details['user']['id'])
self.assertEqual(user_name, token_details['user']['name'])
@@ -62,21 +62,21 @@
tenant_id = None # No default tenant so will get unscoped token.
email = ''
user = self.client.create_user(user_name, user_password,
- tenant_id, email)
+ tenant_id, email)['user']
self.data.users.append(user)
# Create a couple tenants.
tenant1_name = data_utils.rand_name(name='tenant')
- tenant1 = self.client.create_tenant(tenant1_name)
+ tenant1 = self.client.create_tenant(tenant1_name)['tenant']
self.data.tenants.append(tenant1)
tenant2_name = data_utils.rand_name(name='tenant')
- tenant2 = self.client.create_tenant(tenant2_name)
+ tenant2 = self.client.create_tenant(tenant2_name)['tenant']
self.data.tenants.append(tenant2)
# Create a role
role_name = data_utils.rand_name(name='role')
- role = self.client.create_role(role_name)
+ role = self.client.create_role(role_name)['role']
self.data.roles.append(role)
# Grant the user the role on the tenants.
diff --git a/tempest/api/identity/admin/v2/test_users.py b/tempest/api/identity/admin/v2/test_users.py
index bfbcfe7..6ee5218 100644
--- a/tempest/api/identity/admin/v2/test_users.py
+++ b/tempest/api/identity/admin/v2/test_users.py
@@ -36,7 +36,7 @@
self.data.setup_test_tenant()
user = self.client.create_user(self.alt_user, self.alt_password,
self.data.tenant['id'],
- self.alt_email)
+ self.alt_email)['user']
self.data.users.append(user)
self.assertEqual(self.alt_user, user['name'])
@@ -47,7 +47,7 @@
name = data_utils.rand_name('test_user')
user = self.client.create_user(name, self.alt_password,
self.data.tenant['id'],
- self.alt_email, enabled=False)
+ self.alt_email, enabled=False)['user']
self.data.users.append(user)
self.assertEqual(name, user['name'])
self.assertEqual(False, user['enabled'])
@@ -60,7 +60,7 @@
self.data.setup_test_tenant()
user = self.client.create_user(test_user, self.alt_password,
self.data.tenant['id'],
- self.alt_email)
+ self.alt_email)['user']
# Delete the User at the end of this method
self.addCleanup(self.client.delete_user, user['id'])
# Updating user details with new values
@@ -68,12 +68,12 @@
u_email2 = u_name2 + '@testmail.tm'
update_user = self.client.update_user(user['id'], name=u_name2,
email=u_email2,
- enabled=False)
+ enabled=False)['user']
self.assertEqual(u_name2, update_user['name'])
self.assertEqual(u_email2, update_user['email'])
self.assertEqual(False, update_user['enabled'])
# GET by id after updating
- updated_user = self.client.get_user(user['id'])
+ updated_user = self.client.get_user(user['id'])['user']
# Assert response body of GET after updating
self.assertEqual(u_name2, updated_user['name'])
self.assertEqual(u_email2, updated_user['email'])
@@ -86,7 +86,7 @@
self.data.setup_test_tenant()
user = self.client.create_user(test_user, self.alt_password,
self.data.tenant['id'],
- self.alt_email)
+ self.alt_email)['user']
self.client.delete_user(user['id'])
@test.idempotent_id('aca696c3-d645-4f45-b728-63646045beb1')
@@ -121,7 +121,7 @@
def test_get_users(self):
# Get a list of users and find the test user
self.data.setup_test_user()
- users = self.client.get_users()
+ users = self.client.get_users()['users']
self.assertThat([u['name'] for u in users],
matchers.Contains(self.data.test_user),
"Could not find %s" % self.data.test_user)
@@ -135,18 +135,19 @@
alt_tenant_user1 = data_utils.rand_name('tenant_user1')
user1 = self.client.create_user(alt_tenant_user1, 'password1',
self.data.tenant['id'],
- 'user1@123')
+ 'user1@123')['user']
user_ids.append(user1['id'])
self.data.users.append(user1)
alt_tenant_user2 = data_utils.rand_name('tenant_user2')
user2 = self.client.create_user(alt_tenant_user2, 'password2',
self.data.tenant['id'],
- 'user2@123')
+ 'user2@123')['user']
user_ids.append(user2['id'])
self.data.users.append(user2)
# List of users for the respective tenant ID
- body = self.client.list_users_for_tenant(self.data.tenant['id'])
+ body = (self.client.list_users_for_tenant(self.data.tenant['id'])
+ ['users'])
for i in body:
fetched_user_ids.append(i['id'])
# verifying the user Id in the list
@@ -169,19 +170,20 @@
fetched_user_ids = list()
user_ids.append(user['id'])
role = self.client.assign_user_role(tenant['id'], user['id'],
- role['id'])
+ role['id'])['role']
alt_user2 = data_utils.rand_name('second_user')
second_user = self.client.create_user(alt_user2, 'password1',
self.data.tenant['id'],
- 'user2@123')
+ 'user2@123')['user']
user_ids.append(second_user['id'])
self.data.users.append(second_user)
role = self.client.assign_user_role(tenant['id'],
second_user['id'],
- role['id'])
+ role['id'])['role']
# List of users with roles for the respective tenant ID
- body = self.client.list_users_for_tenant(self.data.tenant['id'])
+ body = (self.client.list_users_for_tenant(self.data.tenant['id'])
+ ['users'])
for i in body:
fetched_user_ids.append(i['id'])
# verifying the user Id in the list
@@ -198,7 +200,7 @@
# Updating the user with new password
new_pass = data_utils.rand_name('pass')
update_user = self.client.update_user_password(
- self.data.user['id'], new_pass)
+ self.data.user['id'], new_pass)['user']
self.assertEqual(update_user['id'], self.data.user['id'])
# Validate the updated password
diff --git a/tempest/api/identity/base.py b/tempest/api/identity/base.py
index ada292f..95826b0 100644
--- a/tempest/api/identity/base.py
+++ b/tempest/api/identity/base.py
@@ -39,7 +39,7 @@
@classmethod
def get_user_by_name(cls, name):
- users = cls.client.get_users()
+ users = cls.client.get_users()['users']
user = [u for u in users if u['name'] == name]
if len(user) > 0:
return user[0]
@@ -47,11 +47,7 @@
@classmethod
def get_tenant_by_name(cls, name):
try:
- tenants = cls.client.list_tenants()
- # TODO(jswarren): always retrieve 'tenants' value
- # once both clients return full response objects
- if 'tenants' in tenants:
- tenants = tenants['tenants']
+ tenants = cls.client.list_tenants()['tenants']
except AttributeError:
tenants = cls.client.list_projects()['projects']
tenant = [t for t in tenants if t['name'] == name]
@@ -60,7 +56,7 @@
@classmethod
def get_role_by_name(cls, name):
- roles = cls.client.list_roles()
+ roles = cls.client.list_roles()['roles']
role = [r for r in roles if r['name'] == name]
if len(role) > 0:
return role[0]
@@ -214,7 +210,7 @@
self.user = self.client.create_user(self.test_user,
self.test_password,
self.tenant['id'],
- self.test_email)
+ self.test_email)['user']
self.users.append(self.user)
def setup_test_tenant(self):
@@ -223,13 +219,13 @@
self.test_description = data_utils.rand_name('desc')
self.tenant = self.client.create_tenant(
name=self.test_tenant,
- description=self.test_description)
+ description=self.test_description)['tenant']
self.tenants.append(self.tenant)
def setup_test_role(self):
"""Set up a test role."""
self.test_role = data_utils.rand_name('role')
- self.role = self.client.create_role(self.test_role)
+ self.role = self.client.create_role(self.test_role)['role']
self.roles.append(self.role)
def setup_test_v3_user(self):
diff --git a/tempest/api/identity/test_extension.py b/tempest/api/identity/test_extension.py
index b1d65b4..01e5661 100644
--- a/tempest/api/identity/test_extension.py
+++ b/tempest/api/identity/test_extension.py
@@ -22,7 +22,7 @@
@test.idempotent_id('85f3f661-f54c-4d48-b563-72ae952b9383')
def test_list_extensions(self):
# List all the extensions
- body = self.non_admin_client.list_extensions()
+ body = self.non_admin_client.list_extensions()['extensions']['values']
self.assertNotEmpty(body)
keys = ['name', 'updated', 'alias', 'links',
'namespace', 'description']
diff --git a/tempest/api/identity/v2/test_api_discovery.py b/tempest/api/identity/v2/test_api_discovery.py
index 8132ee1..57c78ef 100644
--- a/tempest/api/identity/v2/test_api_discovery.py
+++ b/tempest/api/identity/v2/test_api_discovery.py
@@ -23,7 +23,7 @@
@test.attr(type='smoke')
@test.idempotent_id('ea889a68-a15f-4166-bfb1-c12456eae853')
def test_api_version_resources(self):
- descr = self.non_admin_client.get_api_description()
+ descr = self.non_admin_client.get_api_description()['version']
expected_resources = ('id', 'links', 'media-types', 'status',
'updated')
@@ -34,7 +34,7 @@
@test.attr(type='smoke')
@test.idempotent_id('007a0be0-78fe-4fdb-bbee-e9216cc17bb2')
def test_api_media_types(self):
- descr = self.non_admin_client.get_api_description()
+ descr = self.non_admin_client.get_api_description()['version']
# Get MIME type bases and descriptions
media_types = [(media_type['base'], media_type['type']) for
media_type in descr['media-types']]
@@ -49,7 +49,7 @@
@test.attr(type='smoke')
@test.idempotent_id('77fd6be0-8801-48e6-b9bf-38cdd2f253ec')
def test_api_version_statuses(self):
- descr = self.non_admin_client.get_api_description()
+ descr = self.non_admin_client.get_api_description()['version']
status = descr['status'].lower()
supported_statuses = ['current', 'stable', 'experimental',
'supported', 'deprecated']
diff --git a/tempest/api/identity/v2/test_ec2_credentials.py b/tempest/api/identity/v2/test_ec2_credentials.py
index dbb50be..763d8de 100644
--- a/tempest/api/identity/v2/test_ec2_credentials.py
+++ b/tempest/api/identity/v2/test_ec2_credentials.py
@@ -38,7 +38,7 @@
"""Create user ec2 credentials."""
resp = self.non_admin_client.create_user_ec2_credentials(
self.creds.credentials.user_id,
- self.creds.credentials.tenant_id)
+ self.creds.credentials.tenant_id)["credential"]
access = resp['access']
self.addCleanup(
self.non_admin_client.delete_user_ec2_credentials,
@@ -55,11 +55,13 @@
fetched_creds = []
# create first ec2 credentials
creds1 = self.non_admin_client.create_user_ec2_credentials(
- self.creds.credentials.user_id, self.creds.credentials.tenant_id)
+ self.creds.credentials.user_id,
+ self.creds.credentials.tenant_id)["credential"]
created_creds.append(creds1['access'])
# create second ec2 credentials
creds2 = self.non_admin_client.create_user_ec2_credentials(
- self.creds.credentials.user_id, self.creds.credentials.tenant_id)
+ self.creds.credentials.user_id,
+ self.creds.credentials.tenant_id)["credential"]
created_creds.append(creds2['access'])
# add credentials to be cleaned up
self.addCleanup(
@@ -70,7 +72,7 @@
self.creds.credentials.user_id, creds2['access'])
# get the list of user ec2 credentials
resp = self.non_admin_client.list_user_ec2_credentials(
- self.creds.credentials.user_id)
+ self.creds.credentials.user_id)["credentials"]
fetched_creds = [cred['access'] for cred in resp]
# created credentials should be in a fetched list
missing = [cred for cred in created_creds
@@ -84,14 +86,14 @@
"""Get the definite user ec2 credentials."""
resp = self.non_admin_client.create_user_ec2_credentials(
self.creds.credentials.user_id,
- self.creds.credentials.tenant_id)
+ self.creds.credentials.tenant_id)["credential"]
self.addCleanup(
self.non_admin_client.delete_user_ec2_credentials,
self.creds.credentials.user_id, resp['access'])
ec2_creds = self.non_admin_client.show_user_ec2_credentials(
self.creds.credentials.user_id, resp['access']
- )
+ )["credential"]
for key in ['access', 'secret', 'user_id', 'tenant_id']:
self.assertEqual(ec2_creds[key], resp[key])
@@ -100,7 +102,7 @@
"""Delete user ec2 credentials."""
resp = self.non_admin_client.create_user_ec2_credentials(
self.creds.credentials.user_id,
- self.creds.credentials.tenant_id)
+ self.creds.credentials.tenant_id)["credential"]
access = resp['access']
self.non_admin_client.delete_user_ec2_credentials(
self.creds.credentials.user_id, access)
diff --git a/tempest/api/identity/v2/test_users.py b/tempest/api/identity/v2/test_users.py
index 4e5b41d..3b89b66 100644
--- a/tempest/api/identity/v2/test_users.py
+++ b/tempest/api/identity/v2/test_users.py
@@ -56,7 +56,7 @@
# user updates own password
resp = self.non_admin_client.update_user_own_password(
- user_id=user_id, new_pass=new_pass, old_pass=old_pass)
+ user_id=user_id, new_pass=new_pass, old_pass=old_pass)['access']
# check authorization with new token
self.non_admin_token_client.auth_token(resp['token']['id'])
diff --git a/tempest/api/object_storage/test_container_quotas.py b/tempest/api/object_storage/test_container_quotas.py
index c78b4c3..896352b 100644
--- a/tempest/api/object_storage/test_container_quotas.py
+++ b/tempest/api/object_storage/test_container_quotas.py
@@ -26,7 +26,7 @@
class ContainerQuotasTest(base.BaseObjectTest):
- """Attemps to test the perfect behavior of quotas in a container."""
+ """Attempts to test the perfect behavior of quotas in a container."""
def setUp(self):
"""Creates and sets a container with quotas.
diff --git a/tempest/api/orchestration/base.py b/tempest/api/orchestration/base.py
index 5b6b0fa..f450b0c 100644
--- a/tempest/api/orchestration/base.py
+++ b/tempest/api/orchestration/base.py
@@ -50,9 +50,13 @@
cls.servers_client = cls.os.servers_client
cls.keypairs_client = cls.os.keypairs_client
cls.network_client = cls.os.network_client
- cls.volumes_client = cls.os.volumes_client
cls.images_v2_client = cls.os.image_client_v2
+ if CONF.volume_feature_enabled.api_v2:
+ cls.volumes_client = cls.os.volumes_v2_client
+ else:
+ cls.volumes_client = cls.os.volumes_client
+
@classmethod
def resource_setup(cls):
super(BaseOrchestrationTest, cls).resource_setup()
diff --git a/tempest/api/orchestration/stacks/test_volumes.py b/tempest/api/orchestration/stacks/test_volumes.py
index 4ba38ad..ae9a411 100644
--- a/tempest/api/orchestration/stacks/test_volumes.py
+++ b/tempest/api/orchestration/stacks/test_volumes.py
@@ -38,10 +38,19 @@
self.assertEqual('available', volume.get('status'))
self.assertEqual(template['resources']['volume']['properties'][
'size'], volume.get('size'))
+
+ # Some volume properties have been renamed with Cinder v2
+ if CONF.volume_feature_enabled.api_v2:
+ description_field = 'description'
+ name_field = 'name'
+ else:
+ description_field = 'display_description'
+ name_field = 'display_name'
+
self.assertEqual(template['resources']['volume']['properties'][
- 'description'], volume.get('display_description'))
+ 'description'], volume.get(description_field))
self.assertEqual(template['resources']['volume']['properties'][
- 'name'], volume.get('display_name'))
+ 'name'], volume.get(name_field))
def _outputs_verify(self, stack_identifier, template):
self.assertEqual('available',
diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py
index 5566f63..2dbcd98 100755
--- a/tempest/cmd/javelin.py
+++ b/tempest/cmd/javelin.py
@@ -278,7 +278,7 @@
existing = [x['name'] for x in body]
for tenant in tenants:
if tenant not in existing:
- admin.identity.create_tenant(tenant)
+ admin.identity.create_tenant(tenant)['tenant']
else:
LOG.warn("Tenant '%s' already exists in this environment" % tenant)
@@ -423,7 +423,7 @@
LOG.info("checking users")
for name, user in six.iteritems(self.users):
client = keystone_admin()
- found = client.identity.get_user(user['id'])
+ found = client.identity.get_user(user['id'])['user']
self.assertEqual(found['name'], user['name'])
self.assertEqual(found['tenantId'], user['tenant_id'])
diff --git a/tempest/cmd/verify_tempest_config.py b/tempest/cmd/verify_tempest_config.py
index 6d53b59..4fcdf8b 100755
--- a/tempest/cmd/verify_tempest_config.py
+++ b/tempest/cmd/verify_tempest_config.py
@@ -65,10 +65,10 @@
# Check glance api versions
_, versions = os.image_client.get_versions()
if CONF.image_feature_enabled.api_v1 != contains_version('v1.', versions):
- print_and_or_update('api_v1', 'image_feature_enabled',
+ print_and_or_update('api_v1', 'image-feature-enabled',
not CONF.image_feature_enabled.api_v1, update)
if CONF.image_feature_enabled.api_v2 != contains_version('v2.', versions):
- print_and_or_update('api_v2', 'image_feature_enabled',
+ print_and_or_update('api_v2', 'image-feature-enabled',
not CONF.image_feature_enabled.api_v2, update)
@@ -105,11 +105,11 @@
versions = _get_api_versions(os, 'keystone')
if (CONF.identity_feature_enabled.api_v2 !=
contains_version('v2.', versions)):
- print_and_or_update('api_v2', 'identity_feature_enabled',
+ print_and_or_update('api_v2', 'identity-feature-enabled',
not CONF.identity_feature_enabled.api_v2, update)
if (CONF.identity_feature_enabled.api_v3 !=
contains_version('v3.', versions)):
- print_and_or_update('api_v3', 'identity_feature_enabled',
+ print_and_or_update('api_v3', 'identity-feature-enabled',
not CONF.identity_feature_enabled.api_v3, update)
@@ -118,11 +118,11 @@
versions = _get_api_versions(os, 'cinder')
if (CONF.volume_feature_enabled.api_v1 !=
contains_version('v1.', versions)):
- print_and_or_update('api_v1', 'volume_feature_enabled',
+ print_and_or_update('api_v1', 'volume-feature-enabled',
not CONF.volume_feature_enabled.api_v1, update)
if (CONF.volume_feature_enabled.api_v2 !=
contains_version('v2.', versions)):
- print_and_or_update('api_v2', 'volume_feature_enabled',
+ print_and_or_update('api_v2', 'volume-feature-enabled',
not CONF.volume_feature_enabled.api_v2, update)
diff --git a/tempest/common/accounts.py b/tempest/common/accounts.py
index 9e6bee3..5fab85b 100644
--- a/tempest/common/accounts.py
+++ b/tempest/common/accounts.py
@@ -102,7 +102,7 @@
if resource == 'network':
hash_dict['networks'][temp_hash_key] = resources[resource]
else:
- LOG.warning('Unkown resource type %s, ignoring this field'
+ LOG.warning('Unknown resource type %s, ignoring this field'
% resource)
return hash_dict
diff --git a/tempest/common/compute.py b/tempest/common/compute.py
index 176be51..41b0529 100644
--- a/tempest/common/compute.py
+++ b/tempest/common/compute.py
@@ -28,7 +28,8 @@
def create_test_server(clients, validatable=False, validation_resources=None,
- tenant_network=None, wait_until=None, **kwargs):
+ tenant_network=None, wait_until=None,
+ volume_backed=False, **kwargs):
"""Common wrapper utility returning a test server.
This method is a common wrapper returning a test server that can be
@@ -41,6 +42,7 @@
:param tenant_network: Tenant network to be used for creating a server.
:param wait_until: Server status to wait for the server to reach after
its creation.
+ :param volume_backed: Whether the instance is volume backed or not.
:returns a tuple
"""
@@ -85,6 +87,29 @@
if wait_until is None:
wait_until = 'ACTIVE'
+ if volume_backed:
+ volume_name = data_utils.rand_name('volume')
+ volumes_client = clients.volumes_v2_client
+ if CONF.volume_feature_enabled.api_v1:
+ volumes_client = clients.volumes_client
+ volume = volumes_client.create_volume(
+ display_name=volume_name,
+ imageRef=image_id)
+ volumes_client.wait_for_volume_status(volume['volume']['id'],
+ 'available')
+
+ bd_map_v2 = [{
+ 'uuid': volume['volume']['id'],
+ 'source_type': 'volume',
+ 'destination_type': 'volume',
+ 'boot_index': 0,
+ 'delete_on_termination': True}]
+ kwargs['block_device_mapping_v2'] = bd_map_v2
+
+ # Since this is boot from volume an image does not need
+ # to be specified.
+ image_id = ''
+
body = clients.servers_client.create_server(name=name, imageRef=image_id,
flavorRef=flavor,
**kwargs)
diff --git a/tempest/common/cred_client.py b/tempest/common/cred_client.py
index 7c3a77f..4d391d0 100644
--- a/tempest/common/cred_client.py
+++ b/tempest/common/cred_client.py
@@ -81,7 +81,7 @@
self.identity_client.delete_user(user_id)
def _list_roles(self):
- roles = self.identity_client.list_roles()
+ roles = self.identity_client.list_roles()['roles']
return roles
@@ -89,7 +89,7 @@
def create_project(self, name, description):
tenant = self.identity_client.create_tenant(
- name=name, description=description)
+ name=name, description=description)['tenant']
return tenant
def get_credentials(self, user, project, password):
diff --git a/tempest/services/botoclients.py b/tempest/services/botoclients.py
index ede464f..bedb9ec 100644
--- a/tempest/services/botoclients.py
+++ b/tempest/services/botoclients.py
@@ -94,14 +94,15 @@
:return: EC2 credentials
"""
ec2_cred_list = identity_client.list_user_ec2_credentials(
- identity_client.user_id)
+ identity_client.user_id)['credentials']
for cred in ec2_cred_list:
if cred['tenant_id'] == identity_client.tenant_id:
ec2_cred = cred
break
else:
- ec2_cred = identity_client.create_user_ec2_credentials(
+ ec2_cred = (identity_client.create_user_ec2_credentials(
identity_client.user_id, identity_client.tenant_id)
+ ['credential'])
if not all((ec2_cred, ec2_cred['access'], ec2_cred['secret'])):
raise lib_exc.NotFound("Unable to get access and secret keys")
else:
diff --git a/tempest/services/identity/v2/json/identity_client.py b/tempest/services/identity/v2/json/identity_client.py
index 81e967d..f37bc08 100644
--- a/tempest/services/identity/v2/json/identity_client.py
+++ b/tempest/services/identity/v2/json/identity_client.py
@@ -24,7 +24,8 @@
url = ''
resp, body = self.get(url)
self.expected_success([200, 203], resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def has_admin_extensions(self):
"""
@@ -49,7 +50,8 @@
post_body = json.dumps({'role': post_body})
resp, body = self.post('OS-KSADM/roles', post_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def get_role(self, role_id):
"""Get a role by its id."""
@@ -73,7 +75,8 @@
post_body = json.dumps({'tenant': post_body})
resp, body = self.post('tenants', post_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def delete_role(self, role_id):
"""Delete a role."""
@@ -86,14 +89,16 @@
url = '/tenants/%s/users/%s/roles' % (tenant_id, user_id)
resp, body = self.get(url)
self.expected_success(200, resp.status)
- return service_client.ResponseBodyList(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def assign_user_role(self, tenant_id, user_id, role_id):
"""Add roles to a user on a tenant."""
resp, body = self.put('/tenants/%s/users/%s/roles/OS-KSADM/%s' %
(tenant_id, user_id, role_id), "")
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def remove_user_role(self, tenant_id, user_id, role_id):
"""Removes a role assignment for a user on a tenant."""
@@ -112,13 +117,15 @@
"""Get tenant details."""
resp, body = self.get('tenants/%s' % str(tenant_id))
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def list_roles(self):
"""Returns roles."""
resp, body = self.get('OS-KSADM/roles')
self.expected_success(200, resp.status)
- return service_client.ResponseBodyList(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def list_tenants(self):
"""Returns tenants."""
@@ -136,7 +143,7 @@
def update_tenant(self, tenant_id, **kwargs):
"""Updates a tenant."""
- body = self.get_tenant(tenant_id)
+ body = self.get_tenant(tenant_id)['tenant']
name = kwargs.get('name', body['name'])
desc = kwargs.get('description', body['description'])
en = kwargs.get('enabled', body['enabled'])
@@ -149,7 +156,8 @@
post_body = json.dumps({'tenant': post_body})
resp, body = self.post('tenants/%s' % tenant_id, post_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def create_user(self, name, password, tenant_id, email, **kwargs):
"""Create a user."""
@@ -165,20 +173,23 @@
post_body = json.dumps({'user': post_body})
resp, body = self.post('users', post_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def update_user(self, user_id, **kwargs):
"""Updates a user."""
put_body = json.dumps({'user': kwargs})
resp, body = self.put('users/%s' % user_id, put_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def get_user(self, user_id):
"""GET a user."""
resp, body = self.get("users/%s" % user_id)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def delete_user(self, user_id):
"""Delete a user."""
@@ -190,7 +201,8 @@
"""Get the list of users."""
resp, body = self.get("users")
self.expected_success(200, resp.status)
- return service_client.ResponseBodyList(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def enable_disable_user(self, user_id, enabled):
"""Enables or disables a user."""
@@ -200,13 +212,15 @@
put_body = json.dumps({'user': put_body})
resp, body = self.put('users/%s/enabled' % user_id, put_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def get_token(self, token_id):
"""Get token details."""
resp, body = self.get("tokens/%s" % token_id)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def delete_token(self, token_id):
"""Delete a token."""
@@ -218,10 +232,11 @@
"""List users for a Tenant."""
resp, body = self.get('/tenants/%s/users' % tenant_id)
self.expected_success(200, resp.status)
- return service_client.ResponseBodyList(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def get_user_by_username(self, tenant_id, username):
- users = self.list_users_for_tenant(tenant_id)
+ users = self.list_users_for_tenant(tenant_id)['users']
for user in users:
if user['name'] == username:
return user
@@ -237,20 +252,23 @@
post_body = json.dumps({'OS-KSADM:service': post_body})
resp, body = self.post('/OS-KSADM/services', post_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def get_service(self, service_id):
"""Get Service."""
url = '/OS-KSADM/services/%s' % service_id
resp, body = self.get(url)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def list_services(self):
"""List Service - Returns Services."""
resp, body = self.get('/OS-KSADM/services')
self.expected_success(200, resp.status)
- return service_client.ResponseBodyList(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def delete_service(self, service_id):
"""Delete Service."""
@@ -271,13 +289,15 @@
post_body = json.dumps({'endpoint': post_body})
resp, body = self.post('/endpoints', post_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def list_endpoints(self):
"""List Endpoints - Returns Endpoints."""
resp, body = self.get('/endpoints')
self.expected_success(200, resp.status)
- return service_client.ResponseBodyList(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def delete_endpoint(self, endpoint_id):
"""Delete an endpoint."""
@@ -295,7 +315,8 @@
put_body = json.dumps({'user': put_body})
resp, body = self.put('users/%s/OS-KSADM/password' % user_id, put_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def update_user_own_password(self, user_id, new_pass, old_pass):
"""User updates own password"""
@@ -306,22 +327,23 @@
patch_body = json.dumps({'user': patch_body})
resp, body = self.patch('OS-KSCRUD/users/%s' % user_id, patch_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def list_extensions(self):
"""List all the extensions."""
resp, body = self.get('/extensions')
self.expected_success(200, resp.status)
body = json.loads(body)
- return service_client.ResponseBodyList(resp,
- body['extensions']['values'])
+ return service_client.ResponseBody(resp, body)
def create_user_ec2_credentials(self, user_id, tenant_id):
post_body = json.dumps({'tenant_id': tenant_id})
resp, body = self.post('/users/%s/credentials/OS-EC2' % user_id,
post_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def delete_user_ec2_credentials(self, user_id, access):
resp, body = self.delete('/users/%s/credentials/OS-EC2/%s' %
@@ -332,10 +354,12 @@
def list_user_ec2_credentials(self, user_id):
resp, body = self.get('/users/%s/credentials/OS-EC2' % user_id)
self.expected_success(200, resp.status)
- return service_client.ResponseBodyList(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def show_user_ec2_credentials(self, user_id, access):
resp, body = self.get('/users/%s/credentials/OS-EC2/%s' %
(user_id, access))
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
diff --git a/tempest/stress/cleanup.py b/tempest/stress/cleanup.py
index 9456590..1350d95 100644
--- a/tempest/stress/cleanup.py
+++ b/tempest/stress/cleanup.py
@@ -68,7 +68,7 @@
except Exception:
pass
- users = admin_manager.identity_client.get_users()
+ users = admin_manager.identity_client.get_users()['users']
LOG.info("Cleanup::remove %s users" % len(users))
for user in users:
if user['name'].startswith("stress_user"):
diff --git a/tempest/tests/cmd/test_verify_tempest_config.py b/tempest/tests/cmd/test_verify_tempest_config.py
index 2de5802..a5dea54 100644
--- a/tempest/tests/cmd/test_verify_tempest_config.py
+++ b/tempest/tests/cmd/test_verify_tempest_config.py
@@ -113,7 +113,7 @@
'print_and_or_update') as print_mock:
verify_tempest_config.verify_keystone_api_versions(fake_os, True)
print_mock.assert_called_once_with('api_v3',
- 'identity_feature_enabled',
+ 'identity-feature-enabled',
False, True)
def test_verify_keystone_api_versions_no_v2(self):
@@ -129,7 +129,7 @@
'print_and_or_update') as print_mock:
verify_tempest_config.verify_keystone_api_versions(fake_os, True)
print_mock.assert_called_once_with('api_v2',
- 'identity_feature_enabled',
+ 'identity-feature-enabled',
False, True)
def test_verify_cinder_api_versions_no_v2(self):
@@ -144,7 +144,7 @@
with mock.patch.object(verify_tempest_config,
'print_and_or_update') as print_mock:
verify_tempest_config.verify_cinder_api_versions(fake_os, True)
- print_mock.assert_called_once_with('api_v2', 'volume_feature_enabled',
+ print_mock.assert_called_once_with('api_v2', 'volume-feature-enabled',
False, True)
def test_verify_cinder_api_versions_no_v1(self):
@@ -159,7 +159,7 @@
with mock.patch.object(verify_tempest_config,
'print_and_or_update') as print_mock:
verify_tempest_config.verify_cinder_api_versions(fake_os, True)
- print_mock.assert_called_once_with('api_v1', 'volume_feature_enabled',
+ print_mock.assert_called_once_with('api_v1', 'volume-feature-enabled',
False, True)
def test_verify_glance_version_no_v2_with_v1_1(self):
@@ -170,7 +170,7 @@
with mock.patch.object(verify_tempest_config,
'print_and_or_update') as print_mock:
verify_tempest_config.verify_glance_api_versions(fake_os, True)
- print_mock.assert_called_once_with('api_v2', 'image_feature_enabled',
+ print_mock.assert_called_once_with('api_v2', 'image-feature-enabled',
False, True)
def test_verify_glance_version_no_v2_with_v1_0(self):
@@ -181,7 +181,7 @@
with mock.patch.object(verify_tempest_config,
'print_and_or_update') as print_mock:
verify_tempest_config.verify_glance_api_versions(fake_os, True)
- print_mock.assert_called_once_with('api_v2', 'image_feature_enabled',
+ print_mock.assert_called_once_with('api_v2', 'image-feature-enabled',
False, True)
def test_verify_glance_version_no_v1(self):
@@ -192,7 +192,7 @@
with mock.patch.object(verify_tempest_config,
'print_and_or_update') as print_mock:
verify_tempest_config.verify_glance_api_versions(fake_os, True)
- print_mock.assert_called_once_with('api_v1', 'image_feature_enabled',
+ print_mock.assert_called_once_with('api_v1', 'image-feature-enabled',
False, True)
def test_verify_extensions_neutron(self):
diff --git a/tempest/tests/services/compute/test_flavors_client.py b/tempest/tests/services/compute/test_flavors_client.py
new file mode 100644
index 0000000..6c0edb8
--- /dev/null
+++ b/tempest/tests/services/compute/test_flavors_client.py
@@ -0,0 +1,255 @@
+# Copyright 2015 IBM Corp.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import copy
+import httplib2
+
+from oslo_serialization import jsonutils as json
+from oslotest import mockpatch
+
+from tempest.services.compute.json import flavors_client
+from tempest.tests import fake_auth_provider
+from tempest.tests.services.compute import base
+
+
+class TestFlavorsClient(base.BaseComputeServiceTest):
+
+ FAKE_FLAVOR = {
+ "disk": 1,
+ "id": "1",
+ "links": [{
+ "href": "http://openstack.example.com/v2/openstack/flavors/1",
+ "rel": "self"}, {
+ "href": "http://openstack.example.com/openstack/flavors/1",
+ "rel": "bookmark"}],
+ "name": "m1.tiny",
+ "ram": 512,
+ "swap": 1,
+ "vcpus": 1
+ }
+
+ EXTRA_SPECS = {"extra_specs": {
+ "key1": "value1",
+ "key2": "value2"}
+ }
+
+ FAKE_FLAVOR_ACCESS = {
+ "flavor_id": "10",
+ "tenant_id": "1a951d988e264818afe520e78697dcbf"
+ }
+
+ def setUp(self):
+ super(TestFlavorsClient, self).setUp()
+ fake_auth = fake_auth_provider.FakeAuthProvider()
+ self.client = flavors_client.FlavorsClient(fake_auth,
+ 'compute', 'regionOne')
+
+ def _test_list_flavors(self, bytes_body=False):
+ flavor = copy.deepcopy(TestFlavorsClient.FAKE_FLAVOR)
+ # Remove extra attributes
+ for attribute in ('disk', 'vcpus', 'ram', 'swap'):
+ del flavor[attribute]
+ expected = {'flavors': [flavor]}
+ self.check_service_client_function(
+ self.client.list_flavors,
+ 'tempest.common.service_client.ServiceClient.get',
+ expected,
+ bytes_body)
+
+ def test_list_flavors_str_body(self):
+ self._test_list_flavors(bytes_body=False)
+
+ def test_list_flavors_byte_body(self):
+ self._test_list_flavors(bytes_body=True)
+
+ def _test_show_flavor(self, bytes_body=False):
+ expected = {"flavor": TestFlavorsClient.FAKE_FLAVOR}
+ self.check_service_client_function(
+ self.client.show_flavor,
+ 'tempest.common.service_client.ServiceClient.get',
+ expected,
+ bytes_body,
+ flavor_id='fake-id')
+
+ def test_show_flavor_str_body(self):
+ self._test_show_flavor(bytes_body=False)
+
+ def test_show_flavor_byte_body(self):
+ self._test_show_flavor(bytes_body=True)
+
+ def _test_create_flavor(self, bytes_body=False):
+ expected = {"flavor": TestFlavorsClient.FAKE_FLAVOR}
+ request = copy.deepcopy(TestFlavorsClient.FAKE_FLAVOR)
+ # The 'links' parameter should not be passed in
+ del request['links']
+ self.check_service_client_function(
+ self.client.create_flavor,
+ 'tempest.common.service_client.ServiceClient.post',
+ expected,
+ bytes_body,
+ **request)
+
+ def test_create_flavor_str_body(self):
+ self._test_create_flavor(bytes_body=False)
+
+ def test_create_flavor__byte_body(self):
+ self._test_create_flavor(bytes_body=True)
+
+ def test_delete_flavor(self):
+ self.check_service_client_function(
+ self.client.delete_flavor,
+ 'tempest.common.service_client.ServiceClient.delete',
+ {}, status=202, flavor_id='c782b7a9-33cd-45f0-b795-7f87f456408b')
+
+ def _test_is_resource_deleted(self, flavor_id, is_deleted=True,
+ bytes_body=False):
+ body = json.dumps({'flavors': [TestFlavorsClient.FAKE_FLAVOR]})
+ if bytes_body:
+ body = body.encode('utf-8')
+ response = (httplib2.Response({'status': 200}), body)
+ self.useFixture(mockpatch.Patch(
+ 'tempest.common.service_client.ServiceClient.get',
+ return_value=response))
+ self.assertEqual(is_deleted,
+ self.client.is_resource_deleted(flavor_id))
+
+ def test_is_resource_deleted_true_str_body(self):
+ self._test_is_resource_deleted('2', bytes_body=False)
+
+ def test_is_resource_deleted_true_byte_body(self):
+ self._test_is_resource_deleted('2', bytes_body=True)
+
+ def test_is_resource_deleted_false_str_body(self):
+ self._test_is_resource_deleted('1', is_deleted=False, bytes_body=False)
+
+ def test_is_resource_deleted_false_byte_body(self):
+ self._test_is_resource_deleted('1', is_deleted=False, bytes_body=True)
+
+ def _test_set_flavor_extra_spec(self, bytes_body=False):
+ self.check_service_client_function(
+ self.client.set_flavor_extra_spec,
+ 'tempest.common.service_client.ServiceClient.post',
+ TestFlavorsClient.EXTRA_SPECS,
+ bytes_body,
+ flavor_id='8c7aae5a-d315-4216-875b-ed9b6a5bcfc6',
+ **TestFlavorsClient.EXTRA_SPECS)
+
+ def test_set_flavor_extra_spec_str_body(self):
+ self._test_set_flavor_extra_spec(bytes_body=False)
+
+ def test_set_flavor_extra_spec_byte_body(self):
+ self._test_set_flavor_extra_spec(bytes_body=True)
+
+ def _test_list_flavor_extra_specs(self, bytes_body=False):
+ self.check_service_client_function(
+ self.client.list_flavor_extra_specs,
+ 'tempest.common.service_client.ServiceClient.get',
+ TestFlavorsClient.EXTRA_SPECS,
+ bytes_body,
+ flavor_id='8c7aae5a-d315-4216-875b-ed9b6a5bcfc6')
+
+ def test_list_flavor_extra_specs_str_body(self):
+ self._test_list_flavor_extra_specs(bytes_body=False)
+
+ def test_list_flavor_extra_specs__byte_body(self):
+ self._test_list_flavor_extra_specs(bytes_body=True)
+
+ def _test_show_flavor_extra_spec(self, bytes_body=False):
+ expected = {"key": "value"}
+ self.check_service_client_function(
+ self.client.show_flavor_extra_spec,
+ 'tempest.common.service_client.ServiceClient.get',
+ expected,
+ bytes_body,
+ flavor_id='8c7aae5a-d315-4216-875b-ed9b6a5bcfc6',
+ key='key')
+
+ def test_show_flavor_extra_spec_str_body(self):
+ self._test_show_flavor_extra_spec(bytes_body=False)
+
+ def test_show_flavor_extra_spec__byte_body(self):
+ self._test_show_flavor_extra_spec(bytes_body=True)
+
+ def _test_update_flavor_extra_spec(self, bytes_body=False):
+ expected = {"key1": "value"}
+ self.check_service_client_function(
+ self.client.update_flavor_extra_spec,
+ 'tempest.common.service_client.ServiceClient.put',
+ expected,
+ bytes_body,
+ flavor_id='8c7aae5a-d315-4216-875b-ed9b6a5bcfc6',
+ key='key1', **expected)
+
+ def test_update_flavor_extra_spec_str_body(self):
+ self._test_update_flavor_extra_spec(bytes_body=False)
+
+ def test_update_flavor_extra_spec_byte_body(self):
+ self._test_update_flavor_extra_spec(bytes_body=True)
+
+ def test_unset_flavor_extra_spec(self):
+ self.check_service_client_function(
+ self.client.unset_flavor_extra_spec,
+ 'tempest.common.service_client.ServiceClient.delete', {},
+ flavor_id='c782b7a9-33cd-45f0-b795-7f87f456408b', key='key')
+
+ def _test_list_flavor_access(self, bytes_body=False):
+ expected = {'flavor_access': [TestFlavorsClient.FAKE_FLAVOR_ACCESS]}
+ self.check_service_client_function(
+ self.client.list_flavor_access,
+ 'tempest.common.service_client.ServiceClient.get',
+ expected,
+ bytes_body,
+ flavor_id='8c7aae5a-d315-4216-875b-ed9b6a5bcfc6')
+
+ def test_list_flavor_access_str_body(self):
+ self._test_list_flavor_access(bytes_body=False)
+
+ def test_list_flavor_access_byte_body(self):
+ self._test_list_flavor_access(bytes_body=True)
+
+ def _test_add_flavor_access(self, bytes_body=False):
+ expected = {
+ "flavor_access": [TestFlavorsClient.FAKE_FLAVOR_ACCESS]
+ }
+ self.check_service_client_function(
+ self.client.add_flavor_access,
+ 'tempest.common.service_client.ServiceClient.post',
+ expected,
+ bytes_body,
+ flavor_id='8c7aae5a-d315-4216-875b-ed9b6a5bcfc6',
+ tenant_id='1a951d988e264818afe520e78697dcbf')
+
+ def test_add_flavor_access_str_body(self):
+ self._test_add_flavor_access(bytes_body=False)
+
+ def test_add_flavor_access_byte_body(self):
+ self._test_add_flavor_access(bytes_body=True)
+
+ def _test_remove_flavor_access(self, bytes_body=False):
+ expected = {
+ "flavor_access": [TestFlavorsClient.FAKE_FLAVOR_ACCESS]
+ }
+ self.check_service_client_function(
+ self.client.remove_flavor_access,
+ 'tempest.common.service_client.ServiceClient.post',
+ expected,
+ bytes_body,
+ flavor_id='10',
+ tenant_id='a6edd4d66ad04245b5d2d8716ecc91e3')
+
+ def test_remove_flavor_access_str_body(self):
+ self._test_remove_flavor_access(bytes_body=False)
+
+ def test_remove_flavor_access_byte_body(self):
+ self._test_remove_flavor_access(bytes_body=True)
diff --git a/tempest/tests/test_tenant_isolation.py b/tempest/tests/test_tenant_isolation.py
index 7bdc1d7..cc4de2d 100644
--- a/tempest/tests/test_tenant_isolation.py
+++ b/tempest/tests/test_tenant_isolation.py
@@ -55,7 +55,7 @@
json_iden_client.IdentityClient,
'create_user',
return_value=(service_client.ResponseBody
- (200, {'id': id, 'name': name}))))
+ (200, {'user': {'id': id, 'name': name}}))))
return user_fix
def _mock_tenant_create(self, id, name):
@@ -63,28 +63,29 @@
json_iden_client.IdentityClient,
'create_tenant',
return_value=(service_client.ResponseBody
- (200, {'id': id, 'name': name}))))
+ (200, {'tenant': {'id': id, 'name': name}}))))
return tenant_fix
def _mock_list_roles(self, id, name):
roles_fix = self.useFixture(mockpatch.PatchObject(
json_iden_client.IdentityClient,
'list_roles',
- return_value=(service_client.ResponseBodyList
+ return_value=(service_client.ResponseBody
(200,
- [{'id': id, 'name': name},
- {'id': '1', 'name': 'FakeRole'}]))))
+ {'roles': [{'id': id, 'name': name},
+ {'id': '1', 'name': 'FakeRole'},
+ {'id': '2', 'name': 'Member'}]}))))
return roles_fix
def _mock_list_2_roles(self):
roles_fix = self.useFixture(mockpatch.PatchObject(
json_iden_client.IdentityClient,
'list_roles',
- return_value=(service_client.ResponseBodyList
+ return_value=(service_client.ResponseBody
(200,
- [{'id': '1234', 'name': 'role1'},
+ {'roles': [{'id': '1234', 'name': 'role1'},
{'id': '1', 'name': 'FakeRole'},
- {'id': '12345', 'name': 'role2'}]))))
+ {'id': '12345', 'name': 'role2'}]}))))
return roles_fix
def _mock_assign_user_role(self):
@@ -99,20 +100,22 @@
roles_fix = self.useFixture(mockpatch.PatchObject(
json_iden_client.IdentityClient,
'list_roles',
- return_value=(service_client.ResponseBodyList
- (200, [{'id': '1', 'name': 'FakeRole'}]))))
+ return_value=(service_client.ResponseBody
+ (200, {'roles': [{'id': '1',
+ 'name': 'FakeRole'}]}))))
return roles_fix
def _mock_list_ec2_credentials(self, user_id, tenant_id):
ec2_creds_fix = self.useFixture(mockpatch.PatchObject(
json_iden_client.IdentityClient,
'list_user_ec2_credentials',
- return_value=(service_client.ResponseBodyList
- (200, [{'access': 'fake_access',
- 'secret': 'fake_secret',
- 'tenant_id': tenant_id,
- 'user_id': user_id,
- 'trust_id': None}]))))
+ return_value=(service_client.ResponseBody
+ (200, {'credentials': [{
+ 'access': 'fake_access',
+ 'secret': 'fake_secret',
+ 'tenant_id': tenant_id,
+ 'user_id': user_id,
+ 'trust_id': None}]}))))
return ec2_creds_fix
def _mock_network_create(self, iso_creds, id, name):