Merge "Improve unit tests for subunit_describe_calls"
diff --git a/doc/source/conf.py b/doc/source/conf.py
index ded713d..2a3edf4 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -204,6 +204,3 @@
('index', 'doc-tempest.tex', u'Tempest Testing Project',
u'OpenStack Foundation', 'manual'),
]
-
-# Disable usage of xindy https://bugzilla.redhat.com/show_bug.cgi?id=1643664
-latex_use_xindy = False
diff --git a/tempest/api/compute/admin/test_floating_ips_bulk.py b/tempest/api/compute/admin/test_floating_ips_bulk.py
index 2d7e1a7..786c7f0 100644
--- a/tempest/api/compute/admin/test_floating_ips_bulk.py
+++ b/tempest/api/compute/admin/test_floating_ips_bulk.py
@@ -63,7 +63,7 @@
@decorators.idempotent_id('2c8f145f-8012-4cb8-ac7e-95a587f0e4ab')
@utils.services('network')
def test_create_list_delete_floating_ips_bulk(self):
- # Create, List and delete the Floating IPs Bulk
+ """Creating, listing and deleting the Floating IPs Bulk"""
pool = 'test_pool'
# NOTE(GMann): Reserving the IP range but those are not attached
# anywhere. Using the below mentioned interface which is not ever
diff --git a/tempest/api/compute/admin/test_hosts.py b/tempest/api/compute/admin/test_hosts.py
index 31fe2b5..30f3388 100644
--- a/tempest/api/compute/admin/test_hosts.py
+++ b/tempest/api/compute/admin/test_hosts.py
@@ -18,7 +18,7 @@
class HostsAdminTestJSON(base.BaseV2ComputeAdminTest):
- """Tests hosts API using admin privileges."""
+ """Tests nova hosts API using admin privileges."""
max_microversion = '2.42'
@@ -29,13 +29,13 @@
@decorators.idempotent_id('9bfaf98d-e2cb-44b0-a07e-2558b2821e4f')
def test_list_hosts(self):
- # Listing hosts.
+ """Listing nova hosts"""
hosts = self.client.list_hosts()['hosts']
self.assertGreaterEqual(len(hosts), 2, str(hosts))
@decorators.idempotent_id('5dc06f5b-d887-47a2-bb2a-67762ef3c6de')
def test_list_hosts_with_zone(self):
- # Listing hosts with specified availability zone
+ """Listing nova hosts with specified availability zone"""
self.useFixture(fixtures.LockFixture('availability_zone'))
hosts = self.client.list_hosts()['hosts']
host = hosts[0]
@@ -45,23 +45,27 @@
@decorators.idempotent_id('9af3c171-fbf4-4150-a624-22109733c2a6')
def test_list_hosts_with_a_blank_zone(self):
- # Listing hosts with blank availability zone.
- # If send the request with a blank zone, the request will be successful
- # and it will return all the hosts list
+ """Listing nova hosts with blank availability zone
+
+ If send the request with a blank zone, the request will be successful
+ and it will return all the hosts list
+ """
hosts = self.client.list_hosts(zone='')['hosts']
self.assertNotEmpty(hosts)
@decorators.idempotent_id('c6ddbadb-c94e-4500-b12f-8ffc43843ff8')
def test_list_hosts_with_nonexistent_zone(self):
- # Listing hosts with not existing availability zone.
- # If send the request with a nonexistent zone, the request will be
- # successful and no hosts will be returned
+ """Listing nova hosts with not existing availability zone.
+
+ If send the request with a nonexistent zone, the request will be
+ successful and no hosts will be returned
+ """
hosts = self.client.list_hosts(zone='xxx')['hosts']
self.assertEmpty(hosts)
@decorators.idempotent_id('38adbb12-aee2-4498-8aec-329c72423aa4')
def test_show_host_detail(self):
- # Showing host details.
+ """Showing nova host details"""
hosts = self.client.list_hosts()['hosts']
hosts = [host for host in hosts if host['service'] == 'compute']
diff --git a/tempest/api/compute/admin/test_hosts_negative.py b/tempest/api/compute/admin/test_hosts_negative.py
index e8733c8..e9436bc 100644
--- a/tempest/api/compute/admin/test_hosts_negative.py
+++ b/tempest/api/compute/admin/test_hosts_negative.py
@@ -39,21 +39,21 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('dd032027-0210-4d9c-860e-69b1b8deed5f')
def test_list_hosts_with_non_admin_user(self):
- # Non admin user is not allowed to list hosts.
+ """Non admin user is not allowed to list hosts"""
self.assertRaises(lib_exc.Forbidden,
self.non_admin_client.list_hosts)
@decorators.attr(type=['negative'])
@decorators.idempotent_id('e75b0a1a-041f-47a1-8b4a-b72a6ff36d3f')
def test_show_host_detail_with_nonexistent_hostname(self):
- # Showing host detail with not existing hostname should fail.
+ """Showing host detail with not existing hostname should fail"""
self.assertRaises(lib_exc.NotFound,
self.client.show_host, 'nonexistent_hostname')
@decorators.attr(type=['negative'])
@decorators.idempotent_id('19ebe09c-bfd4-4b7c-81a2-e2e0710f59cc')
def test_show_host_detail_with_non_admin_user(self):
- # Non admin user is not allowed to show host details.
+ """Non admin user is not allowed to show host details"""
self.assertRaises(lib_exc.Forbidden,
self.non_admin_client.show_host,
self.hostname)
@@ -61,7 +61,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('e40c72b1-0239-4ed6-ba21-81a184df1f7c')
def test_update_host_with_non_admin_user(self):
- # Non admin user is not allowed to update host.
+ """Non admin user is not allowed to update host"""
self.assertRaises(lib_exc.Forbidden,
self.non_admin_client.update_host,
self.hostname,
@@ -71,8 +71,10 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('fbe2bf3e-3246-4a95-a59f-94e4e298ec77')
def test_update_host_with_invalid_status(self):
- # Updating host to invalid status should fail,
- # 'status' can only be 'enable' or 'disable'.
+ """Updating host to invalid status should fail
+
+ 'status' can only be 'enable' or 'disable'.
+ """
self.assertRaises(lib_exc.BadRequest,
self.client.update_host,
self.hostname,
@@ -82,8 +84,10 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('ab1e230e-5e22-41a9-8699-82b9947915d4')
def test_update_host_with_invalid_maintenance_mode(self):
- # Updating host to invalid maintenance mode should fail,
- # 'maintenance_mode' can only be 'enable' or 'disable'.
+ """Updating host to invalid maintenance mode should fail
+
+ 'maintenance_mode' can only be 'enable' or 'disable'.
+ """
self.assertRaises(lib_exc.BadRequest,
self.client.update_host,
self.hostname,
@@ -93,8 +97,10 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('0cd85f75-6992-4a4a-b1bd-d11e37fd0eee')
def test_update_host_without_param(self):
- # Updating host without param should fail,
- # 'status' or 'maintenance_mode' is needed for host update.
+ """Updating host without param should fail
+
+ 'status' or 'maintenance_mode' is needed for host update
+ """
self.assertRaises(lib_exc.BadRequest,
self.client.update_host,
self.hostname)
@@ -102,7 +108,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('23c92146-2100-4d68-b2d6-c7ade970c9c1')
def test_update_nonexistent_host(self):
- # Updating not existing host should fail.
+ """Updating not existing host should fail"""
self.assertRaises(lib_exc.NotFound,
self.client.update_host,
'nonexistent_hostname',
@@ -112,7 +118,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('0d981ac3-4320-4898-b674-82b61fbb60e4')
def test_startup_nonexistent_host(self):
- # Starting up not existing host should fail.
+ """Starting up not existing host should fail"""
self.assertRaises(lib_exc.NotFound,
self.client.startup_host,
'nonexistent_hostname')
@@ -120,7 +126,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('9f4ebb7e-b2ae-4e5b-a38f-0fd1bb0ddfca')
def test_startup_host_with_non_admin_user(self):
- # Non admin user is not allowed to startup host.
+ """Non admin user is not allowed to startup host"""
self.assertRaises(lib_exc.Forbidden,
self.non_admin_client.startup_host,
self.hostname)
@@ -128,7 +134,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('9e637444-29cf-4244-88c8-831ae82c31b6')
def test_shutdown_nonexistent_host(self):
- # Shutting down not existing host should fail.
+ """Shutting down not existing host should fail"""
self.assertRaises(lib_exc.NotFound,
self.client.shutdown_host,
'nonexistent_hostname')
@@ -136,7 +142,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('a803529c-7e3f-4d3c-a7d6-8e1c203d27f6')
def test_shutdown_host_with_non_admin_user(self):
- # Non admin user is not allowed to shutdown host.
+ """Non admin user is not allowed to shutdown host"""
self.assertRaises(lib_exc.Forbidden,
self.non_admin_client.shutdown_host,
self.hostname)
@@ -144,7 +150,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('f86bfd7b-0b13-4849-ae29-0322e83ee58b')
def test_reboot_nonexistent_host(self):
- # Rebooting not existing host should fail.
+ """Rebooting not existing host should fail"""
self.assertRaises(lib_exc.NotFound,
self.client.reboot_host,
'nonexistent_hostname')
@@ -152,7 +158,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('02d79bb9-eb57-4612-abf6-2cb38897d2f8')
def test_reboot_host_with_non_admin_user(self):
- # Non admin user is not allowed to reboot host.
+ """Non admin user is not allowed to reboot host"""
self.assertRaises(lib_exc.Forbidden,
self.non_admin_client.reboot_host,
self.hostname)
diff --git a/tempest/api/compute/admin/test_hypervisor.py b/tempest/api/compute/admin/test_hypervisor.py
index e45aac5..347193d 100644
--- a/tempest/api/compute/admin/test_hypervisor.py
+++ b/tempest/api/compute/admin/test_hypervisor.py
@@ -36,19 +36,19 @@
@decorators.idempotent_id('7f0ceacd-c64d-4e96-b8ee-d02943142cc5')
def test_get_hypervisor_list(self):
- # List of hypervisor and available hypervisors hostname
+ """List of hypervisor and available hypervisors hostname"""
hypers = self._list_hypervisors()
self.assertNotEmpty(hypers, "No hypervisors found.")
@decorators.idempotent_id('1e7fdac2-b672-4ad1-97a4-bad0e3030118')
def test_get_hypervisor_list_details(self):
- # Display the details of the all hypervisor
+ """Display the details of the all hypervisor"""
hypers = self.client.list_hypervisors(detail=True)['hypervisors']
self.assertNotEmpty(hypers, "No hypervisors found.")
@decorators.idempotent_id('94ff9eae-a183-428e-9cdb-79fde71211cc')
def test_get_hypervisor_show_details(self):
- # Display the details of the specified hypervisor
+ """Display the details of the specified hypervisor"""
hypers = self._list_hypervisors()
self.assertNotEmpty(hypers, "No hypervisors found.")
@@ -59,14 +59,14 @@
@decorators.idempotent_id('797e4f28-b6e0-454d-a548-80cc77c00816')
def test_get_hypervisor_stats(self):
- # Verify the stats of the all hypervisor
+ """Verify the stats of the all hypervisor"""
stats = (self.client.show_hypervisor_statistics()
['hypervisor_statistics'])
self.assertNotEmpty(stats)
@decorators.idempotent_id('91a50d7d-1c2b-4f24-b55a-a1fe20efca70')
def test_get_hypervisor_uptime(self):
- # Verify that GET shows the specified hypervisor uptime
+ """Verify that GET shows the specified hypervisor uptime"""
hypers = self._list_hypervisors()
# Ironic will register each baremetal node as a 'hypervisor',
@@ -106,10 +106,13 @@
class HypervisorAdminV228Test(HypervisorAdminTestBase):
+ """Tests Hypervisors API higher than 2.27 that require admin privileges"""
+
min_microversion = '2.28'
@decorators.idempotent_id('d46bab64-0fbe-4eb8-9133-e6ee56188cc5')
def test_get_list_hypervisor_details(self):
+ """Test listing and showing hypervisor details"""
# NOTE(zhufl): This test tests the hypervisor APIs response schema
# for 2.28 microversion. No specific assert or behaviour verification
# is needed.
@@ -119,11 +122,13 @@
class HypervisorAdminUnderV252Test(HypervisorAdminTestBase):
+ """Tests Hypervisors API below 2.53 that require admin privileges"""
+
max_microversion = '2.52'
@decorators.idempotent_id('e81bba3f-6215-4e39-a286-d52d2f906862')
def test_get_hypervisor_show_servers(self):
- # Show instances about the specific hypervisors
+ """Test showing instances about the specific hypervisors"""
hypers = self._list_hypervisors()
self.assertNotEmpty(hypers, "No hypervisors found.")
@@ -134,7 +139,7 @@
@decorators.idempotent_id('d7e1805b-3b14-4a3b-b6fd-50ec6d9f361f')
def test_search_hypervisor(self):
- # Searching for hypervisors by its name.
+ """Test searching for hypervisors by its name"""
hypers = self._list_hypervisors()
self.assertNotEmpty(hypers, "No hypervisors found.")
hypers = self.client.search_hypervisor(
diff --git a/tempest/api/compute/admin/test_hypervisor_negative.py b/tempest/api/compute/admin/test_hypervisor_negative.py
index 723b93c..9aaffd9 100644
--- a/tempest/api/compute/admin/test_hypervisor_negative.py
+++ b/tempest/api/compute/admin/test_hypervisor_negative.py
@@ -40,8 +40,9 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('c136086a-0f67-4b2b-bc61-8482bd68989f')
def test_show_nonexistent_hypervisor(self):
- # Showing not existing hypervisor should fail.
+ """Test showing non existent hypervisor should fail"""
nonexistent_hypervisor_id = data_utils.rand_uuid()
+
self.assertRaises(
lib_exc.NotFound,
self.client.show_hypervisor,
@@ -50,7 +51,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('51e663d0-6b89-4817-a465-20aca0667d03')
def test_show_hypervisor_with_non_admin_user(self):
- # Non admin user is not allowed to show hypervisor.
+ """Test showing hypervisor by non admin user should fail"""
hypers = self._list_hypervisors()
self.assertNotEmpty(hypers)
@@ -62,7 +63,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('e2b061bb-13f9-40d8-9d6e-d5bf17595849')
def test_get_hypervisor_stats_with_non_admin_user(self):
- # Non admin user is not allowed to get hypervisor stats.
+ """Test getting hypervisor stats by non admin user should fail"""
self.assertRaises(
lib_exc.Forbidden,
self.non_adm_client.show_hypervisor_statistics)
@@ -70,7 +71,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('f60aa680-9a3a-4c7d-90e1-fae3a4891303')
def test_get_nonexistent_hypervisor_uptime(self):
- # Getting uptime of not existing hypervisor should fail.
+ """Test showing uptime of non existent hypervisor should fail"""
nonexistent_hypervisor_id = data_utils.rand_uuid()
self.assertRaises(
@@ -81,7 +82,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('6c3461f9-c04c-4e2a-bebb-71dc9cb47df2')
def test_get_hypervisor_uptime_with_non_admin_user(self):
- # Non admin user is not allowed to get hypervisor uptime.
+ """Test showing uptime of hypervisor by non admin user should fail"""
hypers = self._list_hypervisors()
self.assertNotEmpty(hypers)
@@ -93,7 +94,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('51b3d536-9b14-409c-9bce-c6f7c794994e')
def test_get_hypervisor_list_with_non_admin_user(self):
- # List of hypervisor and available services with non admin user
+ """Test listing hypervisors by non admin user should fail"""
self.assertRaises(
lib_exc.Forbidden,
self.non_adm_client.list_hypervisors)
@@ -101,19 +102,21 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('dc02db05-e801-4c5f-bc8e-d915290ab345')
def test_get_hypervisor_list_details_with_non_admin_user(self):
- # Non admin user is not allowed to list hypervisor details.
+ """Test listing hypervisor details by non admin user should fail"""
self.assertRaises(
lib_exc.Forbidden,
self.non_adm_client.list_hypervisors, detail=True)
class HypervisorAdminNegativeUnderV252Test(HypervisorAdminNegativeTestBase):
+ """Tests Hypervisors API below ver 2.53 that require admin privileges"""
+
max_microversion = '2.52'
@decorators.attr(type=['negative'])
@decorators.idempotent_id('2a0a3938-832e-4859-95bf-1c57c236b924')
def test_show_servers_with_non_admin_user(self):
- # Non admin user is not allowed to show servers on hypervisor.
+ """Test showing hypervisor servers by non admin user should fail"""
hypers = self._list_hypervisors()
self.assertNotEmpty(hypers)
@@ -125,7 +128,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('02463d69-0ace-4d33-a4a8-93d7883a2bba')
def test_show_servers_with_nonexistent_hypervisor(self):
- # Showing servers on not existing hypervisor should fail.
+ """Test showing servers on non existent hypervisor should fail"""
nonexistent_hypervisor_id = data_utils.rand_uuid()
self.assertRaises(
@@ -136,7 +139,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('5b6a6c79-5dc1-4fa5-9c58-9c8085948e74')
def test_search_hypervisor_with_non_admin_user(self):
- # Non admin user is not allowed to search hypervisor.
+ """Test searching hypervisor by non admin user should fail"""
hypers = self._list_hypervisors()
self.assertNotEmpty(hypers)
@@ -148,7 +151,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('19a45cc1-1000-4055-b6d2-28e8b2ec4faa')
def test_search_nonexistent_hypervisor(self):
- # Searching not existing hypervisor should fail.
+ """Test searching non existent hypervisor should fail"""
self.assertRaises(
lib_exc.NotFound,
self.client.search_hypervisor,
diff --git a/tempest/api/compute/admin/test_keypairs_v210.py b/tempest/api/compute/admin/test_keypairs_v210.py
index 40ed532..3068127 100644
--- a/tempest/api/compute/admin/test_keypairs_v210.py
+++ b/tempest/api/compute/admin/test_keypairs_v210.py
@@ -19,6 +19,8 @@
class KeyPairsV210TestJSON(base.BaseKeypairTest):
+ """Tests KeyPairs API with microversion higher than 2.9"""
+
credentials = ['primary', 'admin']
min_microversion = '2.10'
@@ -48,6 +50,13 @@
@decorators.idempotent_id('3c8484af-cfb3-48f6-b8ba-d5d58bbf3eac')
def test_admin_manage_keypairs_for_other_users(self):
+ """Test admin managing keypairs for other users
+
+ First admin creates a keypair for an other user, then admin lists
+ keypairs filtered by that user, and keypairs created for that user
+ should appear in the result and keypairs not created for that user
+ should not appear in the result.
+ """
user_id = self.non_admin_client.user_id
key_list = self._create_and_check_keypairs(user_id)
first_keyname = key_list[0]['name']
diff --git a/tempest/api/compute/admin/test_live_migration.py b/tempest/api/compute/admin/test_live_migration.py
index a845c72..064949f 100644
--- a/tempest/api/compute/admin/test_live_migration.py
+++ b/tempest/api/compute/admin/test_live_migration.py
@@ -123,11 +123,17 @@
self._live_migrate(server_id, source_host, state, volume_backed)
@decorators.idempotent_id('1dce86b8-eb04-4c03-a9d8-9c1dc3ee0c7b')
+ @testtools.skipUnless(CONF.compute_feature_enabled.
+ block_migration_for_live_migration,
+ 'Block Live migration not available')
def test_live_block_migration(self):
"""Test live migrating an active server"""
self._test_live_migration()
@decorators.idempotent_id('1e107f21-61b2-4988-8f22-b196e938ab88')
+ @testtools.skipUnless(CONF.compute_feature_enabled.
+ block_migration_for_live_migration,
+ 'Block Live migration not available')
@testtools.skipUnless(CONF.compute_feature_enabled.pause,
'Pause is not available.')
def test_live_block_migration_paused(self):
diff --git a/tempest/api/compute/admin/test_quotas_negative.py b/tempest/api/compute/admin/test_quotas_negative.py
index f90ff92..04dbc2d 100644
--- a/tempest/api/compute/admin/test_quotas_negative.py
+++ b/tempest/api/compute/admin/test_quotas_negative.py
@@ -53,10 +53,12 @@
class QuotasAdminNegativeTest(QuotasAdminNegativeTestBase):
+ """Negative tests of nova quotas"""
@decorators.attr(type=['negative'])
@decorators.idempotent_id('733abfe8-166e-47bb-8363-23dbd7ff3476')
def test_update_quota_normal_user(self):
+ """Test updating nova quota by normal user should fail"""
self.assertRaises(lib_exc.Forbidden,
self.client.update_quota_set,
self.demo_tenant_id,
@@ -67,7 +69,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('91058876-9947-4807-9f22-f6eb17140d9b')
def test_create_server_when_cpu_quota_is_full(self):
- # Disallow server creation when tenant's vcpu quota is full
+ """Disallow server creation when tenant's vcpu quota is full"""
self._update_quota('cores', 0)
self.assertRaises((lib_exc.Forbidden, lib_exc.OverLimit),
self.create_test_server)
@@ -75,7 +77,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('6fdd7012-584d-4327-a61c-49122e0d5864')
def test_create_server_when_memory_quota_is_full(self):
- # Disallow server creation when tenant's memory quota is full
+ """Disallow server creation when tenant's memory quota is full"""
self._update_quota('ram', 0)
self.assertRaises((lib_exc.Forbidden, lib_exc.OverLimit),
self.create_test_server)
@@ -83,13 +85,15 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('7c6be468-0274-449a-81c3-ac1c32ee0161')
def test_create_server_when_instances_quota_is_full(self):
- # Once instances quota limit is reached, disallow server creation
+ """Once instances quota limit is reached, disallow server creation"""
self._update_quota('instances', 0)
self.assertRaises((lib_exc.Forbidden, lib_exc.OverLimit),
self.create_test_server)
class QuotasSecurityGroupAdminNegativeTest(QuotasAdminNegativeTestBase):
+ """Negative tests of nova security group quota"""
+
max_microversion = '2.35'
@decorators.skip_because(bug="1186354",
@@ -98,7 +102,7 @@
@decorators.idempotent_id('7c6c8f3b-2bf6-4918-b240-57b136a66aa0')
@utils.services('network')
def test_security_groups_exceed_limit(self):
- # Negative test: Creation Security Groups over limit should FAIL
+ """Negative test: Creation Security Groups over limit should FAIL"""
# Set the quota to number of used security groups
sg_quota = self.limits_client.show_limits()['limits']['absolute'][
'totalSecurityGroupsUsed']
@@ -117,7 +121,7 @@
@decorators.idempotent_id('6e9f436d-f1ed-4f8e-a493-7275dfaa4b4d')
@utils.services('network')
def test_security_groups_rules_exceed_limit(self):
- # Negative test: Creation of Security Group Rules should FAIL
+ """Negative test: Creation of Security Group Rules should FAIL"""
# when we reach limit maxSecurityGroupRules
self._update_quota('security_group_rules', 0)
diff --git a/tempest/api/compute/admin/test_services.py b/tempest/api/compute/admin/test_services.py
index bf846e5..24518a8 100644
--- a/tempest/api/compute/admin/test_services.py
+++ b/tempest/api/compute/admin/test_services.py
@@ -19,7 +19,10 @@
class ServicesAdminTestJSON(base.BaseV2ComputeAdminTest):
- """Tests Services API. List and Enable/Disable require admin privileges."""
+ """Tests Nova Services API.
+
+ List and Enable/Disable require admin privileges.
+ """
@classmethod
def setup_clients(cls):
@@ -28,13 +31,13 @@
@decorators.idempotent_id('5be41ef4-53d1-41cc-8839-5c2a48a1b283')
def test_list_services(self):
- # Listing nova services
+ """Listing nova services"""
services = self.client.list_services()['services']
self.assertNotEmpty(services)
@decorators.idempotent_id('f345b1ec-bc6e-4c38-a527-3ca2bc00bef5')
def test_get_service_by_service_binary_name(self):
- # Listing nova services by binary name.
+ """Listing nova services by binary name"""
binary_name = 'nova-compute'
services = self.client.list_services(binary=binary_name)['services']
self.assertNotEmpty(services)
@@ -43,7 +46,7 @@
@decorators.idempotent_id('affb42d5-5b4b-43c8-8b0b-6dca054abcca')
def test_get_service_by_host_name(self):
- # Listing nova services by host name.
+ """Listing nova services by host name"""
services = self.client.list_services()['services']
host_name = services[0]['host']
services_on_host = [service for service in services if
diff --git a/tempest/api/compute/flavors/test_flavors.py b/tempest/api/compute/flavors/test_flavors.py
index 20294e9..58861a1 100644
--- a/tempest/api/compute/flavors/test_flavors.py
+++ b/tempest/api/compute/flavors/test_flavors.py
@@ -18,11 +18,12 @@
class FlavorsV2TestJSON(base.BaseV2ComputeTest):
+ """Tests Flavors"""
@decorators.attr(type='smoke')
@decorators.idempotent_id('e36c0eaa-dff5-4082-ad1f-3f9a80aa3f59')
def test_list_flavors(self):
- # List of all flavors should contain the expected flavor
+ """List of all flavors should contain the expected flavor"""
flavors = self.flavors_client.list_flavors()['flavors']
flavor = self.flavors_client.show_flavor(self.flavor_ref)['flavor']
flavor_min_detail = {'id': flavor['id'], 'links': flavor['links'],
@@ -31,7 +32,7 @@
@decorators.idempotent_id('6e85fde4-b3cd-4137-ab72-ed5f418e8c24')
def test_list_flavors_with_detail(self):
- # Detailed list of all flavors should contain the expected flavor
+ """Detailed list of all flavors should contain the expected flavor"""
flavors = self.flavors_client.list_flavors(detail=True)['flavors']
flavor = self.flavors_client.show_flavor(self.flavor_ref)['flavor']
self.assertIn(flavor, flavors)
@@ -39,20 +40,20 @@
@decorators.attr(type='smoke')
@decorators.idempotent_id('1f12046b-753d-40d2-abb6-d8eb8b30cb2f')
def test_get_flavor(self):
- # The expected flavor details should be returned
+ """The expected flavor details should be returned"""
flavor = self.flavors_client.show_flavor(self.flavor_ref)['flavor']
self.assertEqual(self.flavor_ref, flavor['id'])
@decorators.idempotent_id('8d7691b3-6ed4-411a-abc9-2839a765adab')
def test_list_flavors_limit_results(self):
- # Only the expected number of flavors should be returned
+ """Only the expected number of flavors should be returned"""
params = {'limit': 1}
flavors = self.flavors_client.list_flavors(**params)['flavors']
self.assertEqual(1, len(flavors))
@decorators.idempotent_id('b26f6327-2886-467a-82be-cef7a27709cb')
def test_list_flavors_detailed_limit_results(self):
- # Only the expected number of flavors (detailed) should be returned
+ """Only the expected number of flavors(detailed) should be returned"""
params = {'limit': 1}
flavors = self.flavors_client.list_flavors(detail=True,
**params)['flavors']
@@ -60,7 +61,7 @@
@decorators.idempotent_id('e800f879-9828-4bd0-8eae-4f17189951fb')
def test_list_flavors_using_marker(self):
- # The list of flavors should start from the provided marker
+ """The list of flavors should start from the provided marker"""
flavor = self.flavors_client.show_flavor(self.flavor_ref)['flavor']
flavor_id = flavor['id']
@@ -71,7 +72,7 @@
@decorators.idempotent_id('6db2f0c0-ddee-4162-9c84-0703d3dd1107')
def test_list_flavors_detailed_using_marker(self):
- # The list of flavors should start from the provided marker
+ """The list of flavors should start from the provided marker"""
flavor = self.flavors_client.show_flavor(self.flavor_ref)['flavor']
flavor_id = flavor['id']
@@ -83,7 +84,7 @@
@decorators.idempotent_id('3df2743e-3034-4e57-a4cb-b6527f6eac79')
def test_list_flavors_detailed_filter_by_min_disk(self):
- # The detailed list of flavors should be filtered by disk space
+ """The detailed list of flavors should be filtered by disk space"""
flavor = self.flavors_client.show_flavor(self.flavor_ref)['flavor']
flavor_id = flavor['id']
@@ -94,7 +95,7 @@
@decorators.idempotent_id('09fe7509-b4ee-4b34-bf8b-39532dc47292')
def test_list_flavors_detailed_filter_by_min_ram(self):
- # The detailed list of flavors should be filtered by RAM
+ """The detailed list of flavors should be filtered by RAM"""
flavor = self.flavors_client.show_flavor(self.flavor_ref)['flavor']
flavor_id = flavor['id']
@@ -105,7 +106,7 @@
@decorators.idempotent_id('10645a4d-96f5-443f-831b-730711e11dd4')
def test_list_flavors_filter_by_min_disk(self):
- # The list of flavors should be filtered by disk space
+ """The list of flavors should be filtered by disk space"""
flavor = self.flavors_client.show_flavor(self.flavor_ref)['flavor']
flavor_id = flavor['id']
@@ -115,7 +116,7 @@
@decorators.idempotent_id('935cf550-e7c8-4da6-8002-00f92d5edfaa')
def test_list_flavors_filter_by_min_ram(self):
- # The list of flavors should be filtered by RAM
+ """The list of flavors should be filtered by RAM"""
flavor = self.flavors_client.show_flavor(self.flavor_ref)['flavor']
flavor_id = flavor['id']
diff --git a/tempest/api/identity/v2/test_api_discovery.py b/tempest/api/identity/v2/test_api_discovery.py
index 5b9d38c..afda104 100644
--- a/tempest/api/identity/v2/test_api_discovery.py
+++ b/tempest/api/identity/v2/test_api_discovery.py
@@ -18,11 +18,12 @@
class TestApiDiscovery(base.BaseIdentityV2Test):
- """Tests for API discovery features."""
+ """Tests for identity v2 API discovery features."""
@decorators.attr(type='smoke')
@decorators.idempotent_id('ea889a68-a15f-4166-bfb1-c12456eae853')
def test_api_version_resources(self):
+ """Test showing identity v2 api version resources"""
descr = self.non_admin_client.show_api_description()['version']
expected_resources = ('id', 'links', 'media-types', 'status',
'updated')
@@ -34,6 +35,7 @@
@decorators.attr(type='smoke')
@decorators.idempotent_id('007a0be0-78fe-4fdb-bbee-e9216cc17bb2')
def test_api_media_types(self):
+ """Test showing identity v2 api version media type"""
descr = self.non_admin_client.show_api_description()['version']
# Get MIME type bases and descriptions
media_types = [(media_type['base'], media_type['type']) for
@@ -49,6 +51,7 @@
@decorators.attr(type='smoke')
@decorators.idempotent_id('77fd6be0-8801-48e6-b9bf-38cdd2f253ec')
def test_api_version_statuses(self):
+ """Test showing identity v2 api version status"""
descr = self.non_admin_client.show_api_description()['version']
status = descr['status'].lower()
supported_statuses = ['current', 'stable', 'experimental',
diff --git a/tempest/api/identity/v2/test_extension.py b/tempest/api/identity/v2/test_extension.py
index c538c14..13555bd 100644
--- a/tempest/api/identity/v2/test_extension.py
+++ b/tempest/api/identity/v2/test_extension.py
@@ -18,10 +18,11 @@
class ExtensionTestJSON(base.BaseIdentityV2Test):
+ """Test extensions in identity v2 API"""
@decorators.idempotent_id('85f3f661-f54c-4d48-b563-72ae952b9383')
def test_list_extensions(self):
- # List all the extensions
+ """List all the identity extensions via v2 API"""
body = self.non_admin_client.list_extensions()['extensions']['values']
self.assertNotEmpty(body)
keys = ['name', 'updated', 'alias', 'links',
diff --git a/tempest/api/identity/v2/test_tenants.py b/tempest/api/identity/v2/test_tenants.py
index b2a6d13..1752b65 100644
--- a/tempest/api/identity/v2/test_tenants.py
+++ b/tempest/api/identity/v2/test_tenants.py
@@ -19,11 +19,13 @@
class IdentityTenantsTest(base.BaseIdentityV2Test):
+ """Test listing tenants in identity v2 API"""
credentials = ['primary', 'alt']
@decorators.idempotent_id('ecae2459-243d-4ba1-ad02-65f15dc82b78')
def test_list_tenants_returns_only_authorized_tenants(self):
+ """Test listing tenants only returns authorized tenants via v2 API"""
alt_tenant_name = self.os_alt.credentials.tenant_name
resp = self.non_admin_tenants_client.list_tenants()
diff --git a/tempest/api/identity/v2/test_tokens.py b/tempest/api/identity/v2/test_tokens.py
index 64b81c2..a928ad9 100644
--- a/tempest/api/identity/v2/test_tokens.py
+++ b/tempest/api/identity/v2/test_tokens.py
@@ -20,10 +20,11 @@
class TokensTest(base.BaseIdentityV2Test):
+ """Test tokens in identity v2 API"""
@decorators.idempotent_id('65ae3b78-91ff-467b-a705-f6678863b8ec')
def test_create_token(self):
-
+ """Test creating token for user via v2 API"""
token_client = self.non_admin_token_client
# get a token for the user
diff --git a/tempest/api/identity/v2/test_users.py b/tempest/api/identity/v2/test_users.py
index 2eea860..a63b45c 100644
--- a/tempest/api/identity/v2/test_users.py
+++ b/tempest/api/identity/v2/test_users.py
@@ -28,6 +28,7 @@
class IdentityUsersTest(base.BaseIdentityV2Test):
+ """Test user password in identity v2 API"""
@classmethod
def resource_setup(cls):
@@ -85,6 +86,7 @@
'immutable user source and solely '
'provides read-only access to users.')
def test_user_update_own_password(self):
+ """test updating user's own password via v2 API"""
old_pass = self.creds.password
old_token = self.non_admin_users_client.token
new_pass = data_utils.rand_password()
diff --git a/tempest/api/identity/v3/test_api_discovery.py b/tempest/api/identity/v3/test_api_discovery.py
index e87d1cd..ebb96fd 100644
--- a/tempest/api/identity/v3/test_api_discovery.py
+++ b/tempest/api/identity/v3/test_api_discovery.py
@@ -22,10 +22,11 @@
class TestApiDiscovery(base.BaseIdentityV3Test):
- """Tests for API discovery features."""
+ """Tests for identity API discovery features."""
@decorators.idempotent_id('79aec9ae-710f-4c54-a4fc-3aa25b4feac3')
def test_identity_v3_existence(self):
+ """Test that identity v3 version should exist"""
versions = self.non_admin_versions_client.list_versions()
found = any(
"v3" in version.get('id')
@@ -35,9 +36,12 @@
@decorators.idempotent_id('721f480f-35b6-46c7-846e-047e6acea0dc')
@decorators.attr(type='smoke')
def test_list_api_versions(self):
- # NOTE: Actually this API doesn't depend on v3 API at all, because
- # the API operation is "GET /" without v3's endpoint. The reason of
- # this test path is just v3 API is CURRENT on Keystone side.
+ """Test listing identity api versions
+
+ NOTE: Actually this API doesn't depend on v3 API at all, because
+ the API operation is "GET /" without v3's endpoint. The reason of
+ this test path is just v3 API is CURRENT on Keystone side.
+ """
versions = self.non_admin_versions_client.list_versions()
expected_resources = ('id', 'links', 'media-types', 'status',
'updated')
@@ -49,6 +53,7 @@
@decorators.attr(type='smoke')
@decorators.idempotent_id('b9232f5e-d9e5-4d97-b96c-28d3db4de1bd')
def test_api_version_resources(self):
+ """Test showing identity v3 api version resources"""
descr = self.non_admin_client.show_api_description()['version']
expected_resources = ('id', 'links', 'media-types', 'status',
'updated')
@@ -60,6 +65,7 @@
@decorators.attr(type='smoke')
@decorators.idempotent_id('657c1970-4722-4189-8831-7325f3bc4265')
def test_api_media_types(self):
+ """Test showing identity v3 api version media type"""
descr = self.non_admin_client.show_api_description()['version']
# Get MIME type bases and descriptions
media_types = [(media_type['base'], media_type['type']) for
@@ -75,6 +81,7 @@
@decorators.attr(type='smoke')
@decorators.idempotent_id('8879a470-abfb-47bb-bb8d-5a7fd279ad1e')
def test_api_version_statuses(self):
+ """Test showing identity v3 api version status"""
descr = self.non_admin_client.show_api_description()['version']
status = descr['status'].lower()
supported_statuses = ['current', 'stable', 'experimental',
diff --git a/tempest/api/identity/v3/test_domains.py b/tempest/api/identity/v3/test_domains.py
index 9f132dd..bb62ea6 100644
--- a/tempest/api/identity/v3/test_domains.py
+++ b/tempest/api/identity/v3/test_domains.py
@@ -21,6 +21,7 @@
class DefaultDomainTestJSON(base.BaseIdentityV3Test):
+ """Test identity default domains"""
@classmethod
def setup_clients(cls):
@@ -35,5 +36,6 @@
@decorators.attr(type='smoke')
@decorators.idempotent_id('17a5de24-e6a0-4e4a-a9ee-d85b6e5612b5')
def test_default_domain_exists(self):
+ """Test showing default domain"""
domain = self.domains_client.show_domain(self.domain_id)['domain']
self.assertTrue(domain['enabled'])
diff --git a/tempest/api/identity/v3/test_projects.py b/tempest/api/identity/v3/test_projects.py
index bbb4013..338b57b 100644
--- a/tempest/api/identity/v3/test_projects.py
+++ b/tempest/api/identity/v3/test_projects.py
@@ -19,11 +19,13 @@
class IdentityV3ProjectsTest(base.BaseIdentityV3Test):
+ """Test identity projects"""
credentials = ['primary', 'alt']
@decorators.idempotent_id('86128d46-e170-4644-866a-cc487f699e1d')
def test_list_projects_returns_only_authorized_projects(self):
+ """Test listing projects only returns authorized projects"""
alt_project_name = self.os_alt.credentials.project_name
resp = self.non_admin_users_client.list_user_projects(
self.os_primary.credentials.user_id)
diff --git a/tempest/api/identity/v3/test_tokens.py b/tempest/api/identity/v3/test_tokens.py
index cb05f39..b201285 100644
--- a/tempest/api/identity/v3/test_tokens.py
+++ b/tempest/api/identity/v3/test_tokens.py
@@ -24,9 +24,11 @@
class TokensV3Test(base.BaseIdentityV3Test):
+ """Test identity tokens"""
@decorators.idempotent_id('a9512ac3-3909-48a4-b395-11f438e16260')
def test_validate_token(self):
+ """Test validating token for user"""
creds = self.os_primary.credentials
user_id = creds.user_id
username = creds.username
@@ -69,7 +71,7 @@
@decorators.idempotent_id('6f8e4436-fc96-4282-8122-e41df57197a9')
def test_create_token(self):
-
+ """Test creating token for user"""
creds = self.os_primary.credentials
user_id = creds.user_id
username = creds.username
@@ -120,9 +122,12 @@
@decorators.idempotent_id('0f9f5a5f-d5cd-4a86-8a5b-c5ded151f212')
def test_token_auth_creation_existence_deletion(self):
- # Tests basic token auth functionality in a way that is compatible with
- # pre-provisioned credentials. The default user is used for token
- # authentication.
+ """Test auth/check existence/delete token for user
+
+ Tests basic token auth functionality in a way that is compatible with
+ pre-provisioned credentials. The default user is used for token
+ authentication.
+ """
# Valid user's token is authenticated
user = self.os_primary.credentials
diff --git a/tempest/api/identity/v3/test_users.py b/tempest/api/identity/v3/test_users.py
index d4e7612..6425ea9 100644
--- a/tempest/api/identity/v3/test_users.py
+++ b/tempest/api/identity/v3/test_users.py
@@ -28,6 +28,7 @@
class IdentityV3UsersTest(base.BaseIdentityV3Test):
+ """Test identity user password"""
@classmethod
def resource_setup(cls):
@@ -82,6 +83,7 @@
'immutable user source and solely '
'provides read-only access to users.')
def test_user_update_own_password(self):
+ """Test updating user's own password"""
old_pass = self.creds.password
old_token = self.non_admin_client.token
new_pass = data_utils.rand_password()
@@ -111,6 +113,7 @@
'immutable user source and solely '
'provides read-only access to users.')
def test_password_history_check_self_service_api(self):
+ """Test checking password changing history"""
old_pass = self.creds.password
new_pass1 = data_utils.rand_password()
new_pass2 = data_utils.rand_password()
@@ -141,6 +144,7 @@
'Security compliance not available.')
@decorators.idempotent_id('a7ad8bbf-2cff-4520-8c1d-96332e151658')
def test_user_account_lockout(self):
+ """Test locking out user account after failure attempts"""
if (CONF.identity.user_lockout_failure_attempts <= 0 or
CONF.identity.user_lockout_duration <= 0):
raise self.skipException(
diff --git a/tempest/api/volume/admin/test_volumes_actions.py b/tempest/api/volume/admin/test_volumes_actions.py
index 33e503f..ecddfba 100644
--- a/tempest/api/volume/admin/test_volumes_actions.py
+++ b/tempest/api/volume/admin/test_volumes_actions.py
@@ -108,5 +108,4 @@
waiters.wait_for_volume_resource_status(self.volumes_client,
volume_id, 'available')
vol_info = self.volumes_client.show_volume(volume_id)['volume']
- self.assertIn('attachments', vol_info)
self.assertEmpty(vol_info['attachments'])
diff --git a/tempest/api/volume/test_volumes_actions.py b/tempest/api/volume/test_volumes_actions.py
index 9edffc6..e42ea40 100644
--- a/tempest/api/volume/test_volumes_actions.py
+++ b/tempest/api/volume/test_volumes_actions.py
@@ -84,7 +84,6 @@
self.volume['id'], 'available')
self.addCleanup(self.volumes_client.detach_volume, self.volume['id'])
volume = self.volumes_client.show_volume(self.volume['id'])['volume']
- self.assertIn('attachments', volume)
attachment = volume['attachments'][0]
self.assertEqual('/dev/%s' %
diff --git a/tempest/api/volume/test_volumes_get.py b/tempest/api/volume/test_volumes_get.py
index ade2deb..91728ab 100644
--- a/tempest/api/volume/test_volumes_get.py
+++ b/tempest/api/volume/test_volumes_get.py
@@ -37,11 +37,9 @@
kwargs['name'] = v_name
kwargs['metadata'] = metadata
volume = self.volumes_client.create_volume(**kwargs)['volume']
- self.assertIn('id', volume)
self.addCleanup(self.delete_volume, self.volumes_client, volume['id'])
waiters.wait_for_volume_resource_status(self.volumes_client,
volume['id'], 'available')
- self.assertIn('name', volume)
self.assertEqual(volume['name'], v_name,
"The created volume name is not equal "
"to the requested name")
@@ -101,7 +99,6 @@
'availability_zone': volume['availability_zone'],
'size': CONF.volume.volume_size}
new_volume = self.volumes_client.create_volume(**params)['volume']
- self.assertIn('id', new_volume)
self.addCleanup(self.delete_volume, self.volumes_client,
new_volume['id'])
waiters.wait_for_volume_resource_status(self.volumes_client,
@@ -153,7 +150,5 @@
@decorators.idempotent_id('c4f2431e-4920-4736-9e00-4040386b6feb')
def test_show_volume_summary(self):
"""Test showing volume summary"""
- volume_summary = \
- self.volumes_client.show_volume_summary()['volume-summary']
- for key in ['total_size', 'total_count']:
- self.assertIn(key, volume_summary)
+ # check response schema
+ self.volumes_client.show_volume_summary()
diff --git a/tempest/lib/api_schema/response/compute/v2_1/parameter_types.py b/tempest/lib/api_schema/response/compute/v2_1/parameter_types.py
index 28ed816..8aed37d 100644
--- a/tempest/lib/api_schema/response/compute/v2_1/parameter_types.py
+++ b/tempest/lib/api_schema/response/compute/v2_1/parameter_types.py
@@ -120,3 +120,10 @@
# 7: SUSPENDED
'enum': [0, 1, 3, 4, 6, 7]
}
+
+uuid_or_null = {
+ 'anyOf': [
+ {'type': 'string', 'format': 'uuid'},
+ {'type': 'null'}
+ ]
+}
diff --git a/tempest/lib/api_schema/response/volume/volumes.py b/tempest/lib/api_schema/response/volume/volumes.py
new file mode 100644
index 0000000..ffcf488
--- /dev/null
+++ b/tempest/lib/api_schema/response/volume/volumes.py
@@ -0,0 +1,368 @@
+# Copyright 2018 ZTE Corporation. All rights reserved.
+#
+# 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
+
+from tempest.lib.api_schema.response.compute.v2_1 import parameter_types
+
+attachments = {
+ 'type': 'array',
+ 'items': {
+ 'type': 'object',
+ 'properties': {
+ 'server_id': {'type': 'string', 'format': 'uuid'},
+ 'attachment_id': {'type': 'string', 'format': 'uuid'},
+ 'attached_at': parameter_types.date_time_or_null,
+ 'host_name': {'type': ['string', 'null']},
+ 'volume_id': {'type': 'string', 'format': 'uuid'},
+ 'device': {'type': ['string', 'null']},
+ 'id': {'type': 'string', 'format': 'uuid'}
+ },
+ 'additionalProperties': False,
+ 'required': ['server_id', 'attachment_id', 'host_name',
+ 'volume_id', 'device', 'id']
+ }
+}
+
+common_show_volume = {
+ 'type': 'object',
+ 'properties': {
+ 'migration_status': {'type': ['string', 'null']},
+ 'attachments': attachments,
+ 'links': parameter_types.links,
+ 'availability_zone': {'type': ['string', 'null']},
+ 'os-vol-host-attr:host': {
+ 'type': ['string', 'null'], 'pattern': '.+@.+#.+'},
+ 'encrypted': {'type': 'boolean'},
+ 'updated_at': parameter_types.date_time_or_null,
+ 'replication_status': {'type': ['string', 'null']},
+ 'snapshot_id': parameter_types.uuid_or_null,
+ 'id': {'type': 'string', 'format': 'uuid'},
+ 'size': {'type': 'integer'},
+ 'user_id': {'type': 'string', 'format': 'uuid'},
+ 'os-vol-tenant-attr:tenant_id': {'type': 'string',
+ 'format': 'uuid'},
+ 'os-vol-mig-status-attr:migstat': {'type': ['string', 'null']},
+ 'metadata': {'type': 'object'},
+ 'status': {'type': 'string'},
+ 'volume_image_metadata': {'type': ['object', 'null']},
+ 'description': {'type': ['string', 'null']},
+ 'multiattach': {'type': 'boolean'},
+ 'source_volid': parameter_types.uuid_or_null,
+ 'consistencygroup_id': parameter_types.uuid_or_null,
+ 'os-vol-mig-status-attr:name_id': parameter_types.uuid_or_null,
+ 'name': {'type': ['string', 'null']},
+ 'bootable': {'type': 'string'},
+ 'created_at': parameter_types.date_time,
+ 'volume_type': {'type': ['string', 'null']},
+ # TODO(zhufl): group_id is added in 3.13, we should move it to the
+ # 3.13 schema file when microversion is supported in volume interfaces
+ 'group_id': parameter_types.uuid_or_null,
+ # TODO(zhufl): provider_id is added in 3.21, we should move it to the
+ # 3.21 schema file when microversion is supported in volume interfaces
+ 'provider_id': parameter_types.uuid_or_null,
+ # TODO(zhufl): service_uuid and shared_targets are added in 3.48,
+ # we should move them to the 3.48 schema file when microversion
+ # is supported in volume interfaces.
+ 'service_uuid': parameter_types.uuid_or_null,
+ 'shared_targets': {'type': 'boolean'}
+ },
+ 'additionalProperties': False,
+ 'required': ['attachments', 'links', 'encrypted',
+ 'updated_at', 'replication_status', 'id',
+ 'size', 'user_id', 'availability_zone',
+ 'metadata', 'status', 'description',
+ 'multiattach', 'consistencygroup_id',
+ 'name', 'bootable', 'created_at',
+ 'volume_type', 'snapshot_id', 'source_volid']
+}
+
+list_volumes_no_detail = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'volumes': {
+ 'type': 'array',
+ 'items': {
+ 'type': 'object',
+ 'properties': {
+ 'links': parameter_types.links,
+ 'id': {'type': 'string', 'format': 'uuid'},
+ 'name': {'type': ['string', 'null']},
+ # TODO(zhufl): count is added in 3.45, we should move
+ # it to the 3.45 schema file when microversion is
+ # supported in volume interfaces
+ # 'count': {'type': 'integer'}
+ },
+ 'additionalProperties': False,
+ 'required': ['links', 'id', 'name']
+ }
+ },
+ 'volumes_links': parameter_types.links
+ },
+ 'additionalProperties': False,
+ 'required': ['volumes']
+ }
+}
+
+show_volume = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'volume': common_show_volume
+ },
+ 'additionalProperties': False,
+ 'required': ['volume']
+ }
+}
+
+list_volumes_detail = copy.deepcopy(common_show_volume)
+# TODO(zhufl): count is added in 3.45, we should move it to the 3.45 schema
+# file when microversion is supported in volume interfaces
+# list_volumes_detail['properties'].update({'count': {'type': 'integer'}})
+list_volumes_with_detail = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'volumes': {
+ 'type': 'array',
+ 'items': list_volumes_detail
+ },
+ 'volumes_links': parameter_types.links
+ },
+ 'additionalProperties': False,
+ 'required': ['volumes']
+ }
+}
+
+create_volume = {
+ 'status_code': [202],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'volume': {
+ 'type': 'object',
+ 'properties': {
+ 'migration_status': {'type': ['string', 'null']},
+ 'attachments': attachments,
+ 'links': parameter_types.links,
+ 'availability_zone': {'type': ['string', 'null']},
+ 'encrypted': {'type': 'boolean'},
+ 'updated_at': parameter_types.date_time_or_null,
+ 'replication_status': {'type': ['string', 'null']},
+ 'snapshot_id': parameter_types.uuid_or_null,
+ 'id': {'type': 'string', 'format': 'uuid'},
+ 'size': {'type': 'integer'},
+ 'user_id': {'type': 'string', 'format': 'uuid'},
+ 'metadata': {'type': 'object'},
+ 'status': {'type': 'string'},
+ 'description': {'type': ['string', 'null']},
+ 'multiattach': {'type': 'boolean'},
+ 'source_volid': parameter_types.uuid_or_null,
+ 'consistencygroup_id': parameter_types.uuid_or_null,
+ 'name': {'type': ['string', 'null']},
+ 'bootable': {'type': 'string'},
+ 'created_at': parameter_types.date_time,
+ 'volume_type': {'type': ['string', 'null']},
+ # TODO(zhufl): group_id is added in 3.13, we should move
+ # it to the 3.13 schema file when microversion is
+ # supported in volume interfaces.
+ 'group_id': parameter_types.uuid_or_null,
+ # TODO(zhufl): provider_id is added in 3.21, we should
+ # move it to the 3.21 schema file when microversion is
+ # supported in volume interfaces
+ 'provider_id': parameter_types.uuid_or_null,
+ # TODO(zhufl): service_uuid and shared_targets are added
+ # in 3.48, we should move them to the 3.48 schema file
+ # when microversion is supported in volume interfaces.
+ 'service_uuid': parameter_types.uuid_or_null,
+ 'shared_targets': {'type': 'boolean'}
+ },
+ 'additionalProperties': False,
+ 'required': ['attachments', 'links', 'encrypted',
+ 'updated_at', 'replication_status', 'id',
+ 'size', 'user_id', 'availability_zone',
+ 'metadata', 'status', 'description',
+ 'multiattach', 'consistencygroup_id',
+ 'name', 'bootable', 'created_at',
+ 'volume_type', 'snapshot_id', 'source_volid']
+ }
+ },
+ 'additionalProperties': False,
+ 'required': ['volume']
+ }
+}
+
+update_volume = copy.deepcopy(create_volume)
+update_volume.update({'status_code': [200]})
+
+delete_volume = {'status_code': [202]}
+
+show_volume_summary = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'volume-summary': {
+ 'type': 'object',
+ 'properties': {
+ 'total_size': {'type': 'integer'},
+ 'total_count': {'type': 'integer'},
+ # TODO(zhufl): metadata is added in 3.36, we should move
+ # it to the 3.36 schema file when microversion is
+ # supported in volume interfaces
+ 'metadata': {'type': 'object'},
+ },
+ 'additionalProperties': False,
+ 'required': ['total_size', 'total_count']
+ }
+ },
+ 'additionalProperties': False,
+ 'required': ['volume-summary']
+ }
+}
+
+# TODO(zhufl): This is under discussion, so will be merged in a seperate patch.
+# https://bugs.launchpad.net/cinder/+bug/1880566
+# upload_volume = {
+# 'status_code': [202],
+# 'response_body': {
+# 'type': 'object',
+# 'properties': {
+# 'os-volume_upload_image': {
+# 'type': 'object',
+# 'properties': {
+# 'status': {'type': 'string'},
+# 'image_name': {'type': 'string'},
+# 'disk_format': {'type': 'string'},
+# 'container_format': {'type': 'string'},
+# 'is_public': {'type': 'boolean'},
+# 'visibility': {'type': 'string'},
+# 'protected': {'type': 'boolean'},
+# 'updated_at': parameter_types.date_time_or_null,
+# 'image_id': {'type': 'string', 'format': 'uuid'},
+# 'display_description': {'type': ['string', 'null']},
+# 'id': {'type': 'string', 'format': 'uuid'},
+# 'size': {'type': 'integer'},
+# 'volume_type': {
+# 'type': ['object', 'null'],
+# 'properties': {
+# 'created_at': parameter_types.date_time,
+# 'deleted': {'type': 'boolean'},
+# 'deleted_at': parameter_types.date_time_or_null,
+# 'description': {'type': ['string', 'null']},
+# 'extra_specs': {
+# 'type': 'object',
+# 'patternProperties': {
+# '^.+$': {'type': 'string'}
+# }
+# },
+# 'id': {'type': 'string', 'format': 'uuid'},
+# 'is_public': {'type': 'boolean'},
+# 'name': {'type': ['string', 'null']},
+# 'qos_specs_id': parameter_types.uuid_or_null,
+# 'updated_at': parameter_types.date_time_or_null
+# },
+# }
+# },
+# 'additionalProperties': False,
+# 'required': ['status', 'image_name', 'updated_at',
+# 'image_id',
+# 'display_description', 'id', 'size',
+# 'volume_type', 'disk_format',
+# 'container_format']
+# }
+# },
+# 'additionalProperties': False,
+# 'required': ['os-volume_upload_image']
+# }
+# }
+
+attach_volume = {'status_code': [202]}
+set_bootable_volume = {'status_code': [200]}
+detach_volume = {'status_code': [202]}
+reserve_volume = {'status_code': [202]}
+unreserve_volume = {'status_code': [202]}
+extend_volume = {'status_code': [202]}
+reset_volume_status = {'status_code': [202]}
+update_volume_readonly = {'status_code': [202]}
+force_delete_volume = {'status_code': [202]}
+retype_volume = {'status_code': [202]}
+force_detach_volume = {'status_code': [202]}
+
+create_volume_metadata = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'metadata': {'type': 'object'},
+ },
+ 'additionalProperties': False,
+ 'required': ['metadata']
+ }
+}
+
+show_volume_metadata = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'metadata': {'type': 'object'},
+ },
+ 'additionalProperties': False,
+ 'required': ['metadata']
+ }
+}
+update_volume_metadata = copy.deepcopy(show_volume_metadata)
+
+show_volume_metadata_item = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'meta': {'type': 'object'},
+ },
+ 'additionalProperties': False,
+ 'required': ['meta']
+ }
+}
+update_volume_metadata_item = copy.deepcopy(show_volume_metadata_item)
+delete_volume_metadata_item = {'status_code': [200]}
+
+update_volume_image_metadata = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {'metadata': {'type': 'object'}},
+ 'additionalProperties': False,
+ 'required': ['metadata']
+ }
+}
+delete_volume_image_metadata = {'status_code': [200]}
+show_volume_image_metadata = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'metadata': {'type': 'object'},
+ },
+ 'additionalProperties': False,
+ 'required': ['metadata']
+ }
+}
+
+unmanage_volume = {'status_code': [202]}
diff --git a/tempest/lib/services/volume/v3/versions_client.py b/tempest/lib/services/volume/v3/versions_client.py
index aa6c867..4ac4112 100644
--- a/tempest/lib/services/volume/v3/versions_client.py
+++ b/tempest/lib/services/volume/v3/versions_client.py
@@ -54,8 +54,9 @@
"""
version_url = urljoin(self._get_base_version_url(), version + '/')
- resp, body = self.raw_request(version_url, 'GET',
- {'X-Auth-Token': self.token})
+ headers = self.get_headers()
+ headers['X-Auth-Token'] = self.token
+ resp, body = self.raw_request(version_url, 'GET', headers=headers)
self._error_checker(resp, body)
body = json.loads(body)
self.validate_response(schema.volume_api_version_details, resp, body)
diff --git a/tempest/lib/services/volume/v3/volumes_client.py b/tempest/lib/services/volume/v3/volumes_client.py
index 9c6729b..b8535d8 100644
--- a/tempest/lib/services/volume/v3/volumes_client.py
+++ b/tempest/lib/services/volume/v3/volumes_client.py
@@ -17,6 +17,7 @@
import six
from six.moves.urllib import parse as urllib
+from tempest.lib.api_schema.response.volume import volumes as schema
from tempest.lib.common import rest_client
from tempest.lib import exceptions as lib_exc
from tempest.lib.services.volume import base_client
@@ -55,14 +56,16 @@
https://docs.openstack.org/api-ref/block-storage/v3/index.html#list-accessible-volumes
"""
url = 'volumes'
+ list_schema = schema.list_volumes_no_detail
if detail:
+ list_schema = schema.list_volumes_with_detail
url += '/detail'
if params:
url += '?%s' % self._prepare_params(params)
resp, body = self.get(url)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(list_schema, resp, body)
return rest_client.ResponseBody(resp, body)
def migrate_volume(self, volume_id, **kwargs):
@@ -83,7 +86,7 @@
url = "volumes/%s" % volume_id
resp, body = self.get(url)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.show_volume, resp, body)
return rest_client.ResponseBody(resp, body)
def create_volume(self, **kwargs):
@@ -96,7 +99,7 @@
post_body = json.dumps({'volume': kwargs})
resp, body = self.post('volumes', post_body)
body = json.loads(body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.create_volume, resp, body)
return rest_client.ResponseBody(resp, body)
def update_volume(self, volume_id, **kwargs):
@@ -109,7 +112,7 @@
put_body = json.dumps({'volume': kwargs})
resp, body = self.put('volumes/%s' % volume_id, put_body)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.update_volume, resp, body)
return rest_client.ResponseBody(resp, body)
def delete_volume(self, volume_id, **params):
@@ -123,7 +126,7 @@
if params:
url += '?%s' % urllib.urlencode(params)
resp, body = self.delete(url)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.delete_volume, resp, body)
return rest_client.ResponseBody(resp, body)
def show_volume_summary(self, **params):
@@ -138,7 +141,7 @@
url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.show_volume_summary, resp, body)
return rest_client.ResponseBody(resp, body)
def upload_volume(self, volume_id, **kwargs):
@@ -152,6 +155,10 @@
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
body = json.loads(body)
+ # TODO(zhufl): This is under discussion, so will be merged
+ # in a seperate patch.
+ # https://bugs.launchpad.net/cinder/+bug/1880566
+ # self.validate_response(schema.upload_volume, resp, body)
self.expected_success(202, resp.status)
return rest_client.ResponseBody(resp, body)
@@ -165,7 +172,7 @@
post_body = json.dumps({'os-attach': kwargs})
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.attach_volume, resp, body)
return rest_client.ResponseBody(resp, body)
def set_bootable_volume(self, volume_id, **kwargs):
@@ -178,7 +185,7 @@
post_body = json.dumps({'os-set_bootable': kwargs})
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.set_bootable_volume, resp, body)
return rest_client.ResponseBody(resp, body)
def detach_volume(self, volume_id):
@@ -186,7 +193,7 @@
post_body = json.dumps({'os-detach': {}})
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.detach_volume, resp, body)
return rest_client.ResponseBody(resp, body)
def reserve_volume(self, volume_id):
@@ -194,7 +201,7 @@
post_body = json.dumps({'os-reserve': {}})
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.reserve_volume, resp, body)
return rest_client.ResponseBody(resp, body)
def unreserve_volume(self, volume_id):
@@ -202,7 +209,7 @@
post_body = json.dumps({'os-unreserve': {}})
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.unreserve_volume, resp, body)
return rest_client.ResponseBody(resp, body)
def is_resource_deleted(self, id):
@@ -237,7 +244,7 @@
post_body = json.dumps({'os-extend': kwargs})
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.extend_volume, resp, body)
return rest_client.ResponseBody(resp, body)
def reset_volume_status(self, volume_id, **kwargs):
@@ -249,7 +256,7 @@
"""
post_body = json.dumps({'os-reset_status': kwargs})
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.reset_volume_status, resp, body)
return rest_client.ResponseBody(resp, body)
def update_volume_readonly(self, volume_id, **kwargs):
@@ -262,14 +269,14 @@
post_body = json.dumps({'os-update_readonly_flag': kwargs})
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.update_volume_readonly, resp, body)
return rest_client.ResponseBody(resp, body)
def force_delete_volume(self, volume_id):
"""Force Delete Volume."""
post_body = json.dumps({'os-force_delete': {}})
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.force_delete_volume, resp, body)
return rest_client.ResponseBody(resp, body)
def create_volume_metadata(self, volume_id, metadata):
@@ -283,7 +290,7 @@
url = "volumes/%s/metadata" % volume_id
resp, body = self.post(url, put_body)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.create_volume_metadata, resp, body)
return rest_client.ResponseBody(resp, body)
def show_volume_metadata(self, volume_id):
@@ -291,7 +298,7 @@
url = "volumes/%s/metadata" % volume_id
resp, body = self.get(url)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.show_volume_metadata, resp, body)
return rest_client.ResponseBody(resp, body)
def update_volume_metadata(self, volume_id, metadata):
@@ -305,7 +312,7 @@
url = "volumes/%s/metadata" % volume_id
resp, body = self.put(url, put_body)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.update_volume_metadata, resp, body)
return rest_client.ResponseBody(resp, body)
def show_volume_metadata_item(self, volume_id, id):
@@ -313,7 +320,7 @@
url = "volumes/%s/metadata/%s" % (volume_id, id)
resp, body = self.get(url)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.show_volume_metadata_item, resp, body)
return rest_client.ResponseBody(resp, body)
def update_volume_metadata_item(self, volume_id, id, meta_item):
@@ -322,14 +329,14 @@
url = "volumes/%s/metadata/%s" % (volume_id, id)
resp, body = self.put(url, put_body)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.update_volume_metadata_item, resp, body)
return rest_client.ResponseBody(resp, body)
def delete_volume_metadata_item(self, volume_id, id):
"""Delete metadata item for the volume."""
url = "volumes/%s/metadata/%s" % (volume_id, id)
resp, body = self.delete(url)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.delete_volume_metadata_item, resp, body)
return rest_client.ResponseBody(resp, body)
def retype_volume(self, volume_id, **kwargs):
@@ -341,7 +348,7 @@
"""
post_body = json.dumps({'os-retype': kwargs})
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.retype_volume, resp, body)
return rest_client.ResponseBody(resp, body)
def force_detach_volume(self, volume_id, **kwargs):
@@ -354,7 +361,7 @@
post_body = json.dumps({'os-force_detach': kwargs})
url = 'volumes/%s/action' % volume_id
resp, body = self.post(url, post_body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.force_detach_volume, resp, body)
return rest_client.ResponseBody(resp, body)
def update_volume_image_metadata(self, volume_id, **kwargs):
@@ -368,7 +375,7 @@
url = "volumes/%s/action" % (volume_id)
resp, body = self.post(url, post_body)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.update_volume_image_metadata, resp, body)
return rest_client.ResponseBody(resp, body)
def delete_volume_image_metadata(self, volume_id, key_name):
@@ -376,7 +383,7 @@
post_body = json.dumps({'os-unset_image_metadata': {'key': key_name}})
url = "volumes/%s/action" % (volume_id)
resp, body = self.post(url, post_body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.delete_volume_image_metadata, resp, body)
return rest_client.ResponseBody(resp, body)
def show_volume_image_metadata(self, volume_id):
@@ -385,7 +392,7 @@
url = "volumes/%s/action" % volume_id
resp, body = self.post(url, post_body)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.show_volume_image_metadata, resp, body)
return rest_client.ResponseBody(resp, body)
def unmanage_volume(self, volume_id):
@@ -397,5 +404,5 @@
"""
post_body = json.dumps({'os-unmanage': {}})
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.unmanage_volume, resp, body)
return rest_client.ResponseBody(resp, body)
diff --git a/tempest/tests/cmd/test_cleanup_services.py b/tempest/tests/cmd/test_cleanup_services.py
index 7bf7315..fc44793 100644
--- a/tempest/tests/cmd/test_cleanup_services.py
+++ b/tempest/tests/cmd/test_cleanup_services.py
@@ -511,7 +511,8 @@
},
{
"id": "aa77asdf-1234",
- "name": "saved-volume"
+ "name": "saved-volume",
+ "links": [],
}
]
}
diff --git a/tempest/tests/lib/services/volume/v3/test_volumes_client.py b/tempest/tests/lib/services/volume/v3/test_volumes_client.py
index 56c1a35..6bd75d9 100644
--- a/tempest/tests/lib/services/volume/v3/test_volumes_client.py
+++ b/tempest/tests/lib/services/volume/v3/test_volumes_client.py
@@ -26,10 +26,6 @@
"volume-summary": {
"total_size": 4,
"total_count": 4,
- "metadata": {
- "key1": ["value1", "value2"],
- "key2": ["value2"]
- }
}
}