From e354fa7675a614e63f8430b86ab1539d33e1154b Mon Sep 17 00:00:00 2001 From: zhufl Date: Wed, 12 Aug 2020 17:07:50 +0800 Subject: [PATCH] Adding description for testcases - compute part9 When Tempest is used in customer site, often we are required to provide a testcase list including testcase names and descriptions. Now no this kind of doc is available, so we can add descriptions with the format of doc string for every testcase, so later we can generata such a testcase description list. There are hundreds of testcases missing descriptions, so we can add them gradually, and limit the modified files in one patch for the convenience of reviewing. Change-Id: Iffbaa7489d219ae4138874fe6c5702e858417573 partially-implements: blueprint testcase-description --- tempest/api/compute/admin/test_aggregates.py | 35 ++++++++++++++----- .../compute/admin/test_availability_zone.py | 4 +-- .../admin/test_availability_zone_negative.py | 10 ++++-- tempest/api/compute/admin/test_fixed_ips.py | 4 +++ .../compute/admin/test_fixed_ips_negative.py | 6 ++++ .../api/compute/admin/test_flavors_access.py | 10 ++++-- .../admin/test_flavors_microversions.py | 8 +++++ .../compute/admin/test_simple_tenant_usage.py | 7 ++-- .../test_simple_tenant_usage_negative.py | 7 ++-- .../floating_ips/test_floating_ips_actions.py | 18 ++++++---- 10 files changed, 79 insertions(+), 30 deletions(-) diff --git a/tempest/api/compute/admin/test_aggregates.py b/tempest/api/compute/admin/test_aggregates.py index 7a3bfdf387..27162594fd 100644 --- a/tempest/api/compute/admin/test_aggregates.py +++ b/tempest/api/compute/admin/test_aggregates.py @@ -71,10 +71,11 @@ class AggregatesAdminTestBase(base.BaseV2ComputeAdminTest): class AggregatesAdminTestJSON(AggregatesAdminTestBase): + """Tests Aggregates API that require admin privileges""" @decorators.idempotent_id('0d148aa3-d54c-4317-aa8d-42040a475e20') def test_aggregate_create_delete(self): - # Create and delete an aggregate. + """Test create/delete aggregate""" aggregate = self._create_test_aggregate() self.assertIsNone(aggregate['availability_zone']) @@ -83,7 +84,7 @@ class AggregatesAdminTestJSON(AggregatesAdminTestBase): @decorators.idempotent_id('5873a6f8-671a-43ff-8838-7ce430bb6d0b') def test_aggregate_create_delete_with_az(self): - # Create and delete an aggregate. + """Test create/delete aggregate with availability_zone""" az_name = data_utils.rand_name(self.az_name_prefix) aggregate = self._create_test_aggregate(availability_zone=az_name) self.assertEqual(az_name, aggregate['availability_zone']) @@ -93,7 +94,7 @@ class AggregatesAdminTestJSON(AggregatesAdminTestBase): @decorators.idempotent_id('68089c38-04b1-4758-bdf0-cf0daec4defd') def test_aggregate_create_verify_entry_in_list(self): - # Create an aggregate and ensure it is listed. + """Test listing aggregate should contain the created aggregate""" aggregate = self._create_test_aggregate() aggregates = self.client.list_aggregates()['aggregates'] self.assertIn((aggregate['id'], aggregate['availability_zone']), @@ -102,7 +103,7 @@ class AggregatesAdminTestJSON(AggregatesAdminTestBase): @decorators.idempotent_id('36ec92ca-7a73-43bc-b920-7531809e8540') def test_aggregate_create_update_metadata_get_details(self): - # Create an aggregate and ensure its details are returned. + """Test set/get aggregate metadata""" aggregate = self._create_test_aggregate() body = self.client.show_aggregate(aggregate['id'])['aggregate'] self.assertEqual(aggregate['name'], body['name']) @@ -121,7 +122,7 @@ class AggregatesAdminTestJSON(AggregatesAdminTestBase): @decorators.idempotent_id('4d2b2004-40fa-40a1-aab2-66f4dab81beb') def test_aggregate_create_update_with_az(self): - # Update an aggregate and ensure properties are updated correctly + """Test create/update aggregate with availability_zone""" aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) az_name = data_utils.rand_name(self.az_name_prefix) aggregate = self._create_test_aggregate( @@ -148,7 +149,7 @@ class AggregatesAdminTestJSON(AggregatesAdminTestBase): @decorators.idempotent_id('c8e85064-e79b-4906-9931-c11c24294d02') def test_aggregate_add_remove_host(self): - # Add a host to the given aggregate and remove. + """Test adding host to and removing host from aggregate""" self.useFixture(fixtures.LockFixture('availability_zone')) aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) aggregate = self._create_test_aggregate(name=aggregate_name) @@ -169,7 +170,10 @@ class AggregatesAdminTestJSON(AggregatesAdminTestBase): @decorators.idempotent_id('7f6a1cc5-2446-4cdb-9baa-b6ae0a919b72') def test_aggregate_add_host_list(self): - # Add a host to the given aggregate and list. + """Test listing aggregate contains the host added to the aggregate + + Add a host to the given aggregate and list. + """ self.useFixture(fixtures.LockFixture('availability_zone')) aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) aggregate = self._create_test_aggregate(name=aggregate_name) @@ -188,7 +192,10 @@ class AggregatesAdminTestJSON(AggregatesAdminTestBase): @decorators.idempotent_id('eeef473c-7c52-494d-9f09-2ed7fc8fc036') def test_aggregate_add_host_get_details(self): - # Add a host to the given aggregate and get details. + """Test showing aggregate contains the host added to the aggregate + + Add a host to the given aggregate and get details. + """ self.useFixture(fixtures.LockFixture('availability_zone')) aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) aggregate = self._create_test_aggregate(name=aggregate_name) @@ -204,7 +211,7 @@ class AggregatesAdminTestJSON(AggregatesAdminTestBase): @decorators.idempotent_id('96be03c7-570d-409c-90f8-e4db3c646996') def test_aggregate_add_host_create_server_with_az(self): - # Add a host to the given aggregate and create a server. + """Test adding a host to the given aggregate and creating a server""" self.useFixture(fixtures.LockFixture('availability_zone')) az_name = data_utils.rand_name(self.az_name_prefix) aggregate = self._create_test_aggregate(availability_zone=az_name) @@ -233,6 +240,11 @@ class AggregatesAdminTestJSON(AggregatesAdminTestBase): class AggregatesAdminTestV241(AggregatesAdminTestBase): + """Tests Aggregates API that require admin privileges + + Tests Aggregates API that require admin privileges with compute + microversion greater than 2.40. + """ min_microversion = '2.41' # NOTE(gmann): This test tests the Aggregate APIs response schema @@ -241,6 +253,11 @@ class AggregatesAdminTestV241(AggregatesAdminTestBase): @decorators.idempotent_id('fdf24d9e-8afa-4700-b6aa-9c498351504f') def test_create_update_show_aggregate_add_remove_host(self): + """Test response schema of aggregates API + + Test response schema of aggregates API(create/update/show/add host/ + remove host) with compute microversion greater than 2.40. + """ # Update and add a host to the given aggregate and get details. self.useFixture(fixtures.LockFixture('availability_zone')) # Checking create aggregate API response schema diff --git a/tempest/api/compute/admin/test_availability_zone.py b/tempest/api/compute/admin/test_availability_zone.py index bbd39b6859..3eb0d9aacc 100644 --- a/tempest/api/compute/admin/test_availability_zone.py +++ b/tempest/api/compute/admin/test_availability_zone.py @@ -27,12 +27,12 @@ class AZAdminV2TestJSON(base.BaseV2ComputeAdminTest): @decorators.idempotent_id('d3431479-8a09-4f76-aa2d-26dc580cb27c') def test_get_availability_zone_list(self): - # List of availability zone + """Test listing availability zones""" availability_zone = self.client.list_availability_zones() self.assertNotEmpty(availability_zone['availabilityZoneInfo']) @decorators.idempotent_id('ef726c58-530f-44c2-968c-c7bed22d5b8c') def test_get_availability_zone_list_detail(self): - # List of availability zones and available services + """Test listing availability zones with detail""" availability_zone = self.client.list_availability_zones(detail=True) self.assertNotEmpty(availability_zone['availabilityZoneInfo']) diff --git a/tempest/api/compute/admin/test_availability_zone_negative.py b/tempest/api/compute/admin/test_availability_zone_negative.py index a58c22cb2b..6e576e8ac1 100644 --- a/tempest/api/compute/admin/test_availability_zone_negative.py +++ b/tempest/api/compute/admin/test_availability_zone_negative.py @@ -18,7 +18,7 @@ from tempest.lib import exceptions as lib_exc class AZAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): - """Tests Availability Zone API List""" + """Negative Tests of Availability Zone API List""" @classmethod def setup_clients(cls): @@ -28,8 +28,12 @@ class AZAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): @decorators.attr(type=['negative']) @decorators.idempotent_id('bf34dca2-fdc3-4073-9c02-7648d9eae0d7') def test_get_availability_zone_list_detail_with_non_admin_user(self): - # List of availability zones and available services with - # non-administrator user + """Test listing availability zone with detail by non-admin user + + List of availability zones and available services with + non-administrator user is not allowed. + """ + self.assertRaises( lib_exc.Forbidden, self.non_adm_client.list_availability_zones, detail=True) diff --git a/tempest/api/compute/admin/test_fixed_ips.py b/tempest/api/compute/admin/test_fixed_ips.py index 66c2c2dd5e..9de3da9eb6 100644 --- a/tempest/api/compute/admin/test_fixed_ips.py +++ b/tempest/api/compute/admin/test_fixed_ips.py @@ -22,6 +22,7 @@ CONF = config.CONF class FixedIPsTestJson(base.BaseV2ComputeAdminTest): + """Test fixed ips API""" @classmethod def skip_checks(cls): @@ -56,13 +57,16 @@ class FixedIPsTestJson(base.BaseV2ComputeAdminTest): @decorators.idempotent_id('16b7d848-2f7c-4709-85a3-2dfb4576cc52') def test_list_fixed_ip_details(self): + """Test getting fixed ip details""" fixed_ip = self.client.show_fixed_ip(self.ip) self.assertEqual(fixed_ip['fixed_ip']['address'], self.ip) @decorators.idempotent_id('5485077b-7e46-4cec-b402-91dc3173433b') def test_set_reserve(self): + """Test reserving fixed ip""" self.client.reserve_fixed_ip(self.ip, reserve="None") @decorators.idempotent_id('7476e322-b9ff-4710-bf82-49d51bac6e2e') def test_set_unreserve(self): + """Test unreserving fixed ip""" self.client.reserve_fixed_ip(self.ip, unreserve="None") diff --git a/tempest/api/compute/admin/test_fixed_ips_negative.py b/tempest/api/compute/admin/test_fixed_ips_negative.py index 7d41f466f3..1629faadaa 100644 --- a/tempest/api/compute/admin/test_fixed_ips_negative.py +++ b/tempest/api/compute/admin/test_fixed_ips_negative.py @@ -22,6 +22,7 @@ CONF = config.CONF class FixedIPsNegativeTestJson(base.BaseV2ComputeAdminTest): + """Negative tests of fixed ips API""" @classmethod def skip_checks(cls): @@ -58,12 +59,14 @@ class FixedIPsNegativeTestJson(base.BaseV2ComputeAdminTest): @decorators.attr(type=['negative']) @decorators.idempotent_id('9f17f47d-daad-4adc-986e-12370c93e407') def test_list_fixed_ip_details_with_non_admin_user(self): + """Test listing fixed ip with detail by non-admin user is forbidden""" self.assertRaises(lib_exc.Forbidden, self.non_admin_client.show_fixed_ip, self.ip) @decorators.attr(type=['negative']) @decorators.idempotent_id('ce60042c-fa60-4836-8d43-1c8e3359dc47') def test_set_reserve_with_non_admin_user(self): + """Test reserving fixed ip by non-admin user is forbidden""" self.assertRaises(lib_exc.Forbidden, self.non_admin_client.reserve_fixed_ip, self.ip, reserve="None") @@ -71,6 +74,7 @@ class FixedIPsNegativeTestJson(base.BaseV2ComputeAdminTest): @decorators.attr(type=['negative']) @decorators.idempotent_id('f1f7a35b-0390-48c5-9803-5f27461439db') def test_set_unreserve_with_non_admin_user(self): + """Test unreserving fixed ip by non-admin user is forbidden""" self.assertRaises(lib_exc.Forbidden, self.non_admin_client.reserve_fixed_ip, self.ip, unreserve="None") @@ -78,6 +82,7 @@ class FixedIPsNegativeTestJson(base.BaseV2ComputeAdminTest): @decorators.attr(type=['negative']) @decorators.idempotent_id('f51cf464-7fc5-4352-bc3e-e75cfa2cb717') def test_set_reserve_with_invalid_ip(self): + """Test reserving invalid fixed ip should fail""" # NOTE(maurosr): since this exercises the same code snippet, we do it # only for reserve action # NOTE(eliqiao): in Juno, the exception is NotFound, but in master, we @@ -90,6 +95,7 @@ class FixedIPsNegativeTestJson(base.BaseV2ComputeAdminTest): @decorators.attr(type=['negative']) @decorators.idempotent_id('fd26ef50-f135-4232-9d32-281aab3f9176') def test_fixed_ip_with_invalid_action(self): + """Test operating fixed ip with invalid action should fail""" self.assertRaises(lib_exc.BadRequest, self.client.reserve_fixed_ip, self.ip, invalid_action="None") diff --git a/tempest/api/compute/admin/test_flavors_access.py b/tempest/api/compute/admin/test_flavors_access.py index b8e2b42a04..87ab7c71d7 100644 --- a/tempest/api/compute/admin/test_flavors_access.py +++ b/tempest/api/compute/admin/test_flavors_access.py @@ -43,8 +43,12 @@ class FlavorsAccessTestJSON(base.BaseV2ComputeAdminTest): @decorators.idempotent_id('ea2c2211-29fa-4db9-97c3-906d36fad3e0') def test_flavor_access_list_with_private_flavor(self): - # Test to make sure that list flavor access on a newly created - # private flavor will return an empty access list + """Test listing flavor access for a private flavor + + Listing flavor access on a newly created private flavor will return + an empty access list. + """ + # Test to make sure that flavor = self.create_flavor(ram=self.ram, vcpus=self.vcpus, disk=self.disk, is_public='False') @@ -54,7 +58,7 @@ class FlavorsAccessTestJSON(base.BaseV2ComputeAdminTest): @decorators.idempotent_id('59e622f6-bdf6-45e3-8ba8-fedad905a6b4') def test_flavor_access_add_remove(self): - # Test to add and remove flavor access to a given tenant. + """Test add/remove flavor access to a given project""" flavor = self.create_flavor(ram=self.ram, vcpus=self.vcpus, disk=self.disk, is_public='False') diff --git a/tempest/api/compute/admin/test_flavors_microversions.py b/tempest/api/compute/admin/test_flavors_microversions.py index 31b9217962..d904cbd2f6 100644 --- a/tempest/api/compute/admin/test_flavors_microversions.py +++ b/tempest/api/compute/admin/test_flavors_microversions.py @@ -18,6 +18,8 @@ from tempest.lib import decorators class FlavorsV255TestJSON(base.BaseV2ComputeAdminTest): + """Test flavors API with compute microversion greater than 2.54""" + min_microversion = '2.55' max_microversion = 'latest' @@ -26,6 +28,11 @@ class FlavorsV255TestJSON(base.BaseV2ComputeAdminTest): @decorators.idempotent_id('61976b25-488d-41dc-9dcb-cb9693a7b075') def test_crud_flavor(self): + """Test create/show/update/list flavor + + Check the response schema of flavors API with microversion greater + than 2.54. + """ flavor_id = data_utils.rand_int_id(start=1000) # Checking create API response schema new_flavor_id = self.create_flavor(ram=512, @@ -44,6 +51,7 @@ class FlavorsV255TestJSON(base.BaseV2ComputeAdminTest): class FlavorsV261TestJSON(FlavorsV255TestJSON): + """Test flavors API with compute microversion greater than 2.60""" min_microversion = '2.61' max_microversion = 'latest' diff --git a/tempest/api/compute/admin/test_simple_tenant_usage.py b/tempest/api/compute/admin/test_simple_tenant_usage.py index d4c60b349e..c24f420294 100644 --- a/tempest/api/compute/admin/test_simple_tenant_usage.py +++ b/tempest/api/compute/admin/test_simple_tenant_usage.py @@ -26,6 +26,7 @@ VALID_WAIT = 30 class TenantUsagesTestJSON(base.BaseV2ComputeAdminTest): + """Test tenant usages""" @classmethod def setup_clients(cls): @@ -67,7 +68,7 @@ class TenantUsagesTestJSON(base.BaseV2ComputeAdminTest): @decorators.idempotent_id('062c8ae9-9912-4249-8b51-e38d664e926e') def test_list_usage_all_tenants(self): - # Get usage for all tenants + """Test getting usage for all tenants""" tenant_usage = self.call_until_valid( self.adm_client.list_tenant_usages, VALID_WAIT, start=self.start, end=self.end, detailed="1")['tenant_usages'][0] @@ -75,7 +76,7 @@ class TenantUsagesTestJSON(base.BaseV2ComputeAdminTest): @decorators.idempotent_id('94135049-a4c5-4934-ad39-08fa7da4f22e') def test_get_usage_tenant(self): - # Get usage for a specific tenant + """Test getting usage for a specific tenant""" tenant_usage = self.call_until_valid( self.adm_client.show_tenant_usage, VALID_WAIT, self.tenant_id, start=self.start, end=self.end)['tenant_usage'] @@ -84,7 +85,7 @@ class TenantUsagesTestJSON(base.BaseV2ComputeAdminTest): @decorators.idempotent_id('9d00a412-b40e-4fd9-8eba-97b496316116') def test_get_usage_tenant_with_non_admin_user(self): - # Get usage for a specific tenant with non admin user + """Test getting usage for a specific tenant with non admin user""" tenant_usage = self.call_until_valid( self.client.show_tenant_usage, VALID_WAIT, self.tenant_id, start=self.start, end=self.end)['tenant_usage'] diff --git a/tempest/api/compute/admin/test_simple_tenant_usage_negative.py b/tempest/api/compute/admin/test_simple_tenant_usage_negative.py index cb60b8d30f..4b5a5d5156 100644 --- a/tempest/api/compute/admin/test_simple_tenant_usage_negative.py +++ b/tempest/api/compute/admin/test_simple_tenant_usage_negative.py @@ -21,6 +21,7 @@ from tempest.lib import exceptions as lib_exc class TenantUsagesNegativeTestJSON(base.BaseV2ComputeAdminTest): + """Negative tests of compute tenant usages API""" @classmethod def setup_clients(cls): @@ -43,7 +44,7 @@ class TenantUsagesNegativeTestJSON(base.BaseV2ComputeAdminTest): @decorators.attr(type=['negative']) @decorators.idempotent_id('8b21e135-d94b-4991-b6e9-87059609c8ed') def test_get_usage_tenant_with_empty_tenant_id(self): - # Get usage for a specific tenant empty + """Test getting tenant usage with empty tenant id should fail""" params = {'start': self.start, 'end': self.end} self.assertRaises(lib_exc.NotFound, @@ -53,7 +54,7 @@ class TenantUsagesNegativeTestJSON(base.BaseV2ComputeAdminTest): @decorators.attr(type=['negative']) @decorators.idempotent_id('4079dd2a-9e8d-479f-869d-6fa985ce45b6') def test_get_usage_tenant_with_invalid_date(self): - # Get usage for tenant with invalid date + """Test getting tenant usage with invalid time range should fail""" params = {'start': self.end, 'end': self.start} self.assertRaises(lib_exc.BadRequest, @@ -63,7 +64,7 @@ class TenantUsagesNegativeTestJSON(base.BaseV2ComputeAdminTest): @decorators.attr(type=['negative']) @decorators.idempotent_id('bbe6fe2c-15d8-404c-a0a2-44fad0ad5cc7') def test_list_usage_all_tenants_with_non_admin_user(self): - # Get usage for all tenants with non admin user + """Test listing usage of all tenants by non-admin user is forbidden""" params = {'start': self.start, 'end': self.end, 'detailed': "1"} diff --git a/tempest/api/compute/floating_ips/test_floating_ips_actions.py b/tempest/api/compute/floating_ips/test_floating_ips_actions.py index 2adc4826f0..6097bbc51d 100644 --- a/tempest/api/compute/floating_ips/test_floating_ips_actions.py +++ b/tempest/api/compute/floating_ips/test_floating_ips_actions.py @@ -25,13 +25,13 @@ CONF = config.CONF class FloatingIPsTestJSON(base.BaseFloatingIPsTest): + """Test floating ips API with compute microversion less than 2.36""" max_microversion = '2.35' @decorators.idempotent_id('f7bfb946-297e-41b8-9e8c-aba8e9bb5194') def test_allocate_floating_ip(self): - # Positive test:Allocation of a new floating IP to a project - # should be successful + """Test allocating a floating ip to a project""" body = self.client.create_floating_ip( pool=CONF.network.floating_network_name)['floating_ip'] floating_ip_id_allocated = body['id'] @@ -45,8 +45,7 @@ class FloatingIPsTestJSON(base.BaseFloatingIPsTest): @decorators.idempotent_id('de45e989-b5ca-4a9b-916b-04a52e7bbb8b') def test_delete_floating_ip(self): - # Positive test:Deletion of valid floating IP from project - # should be successful + """Test deleting a valid floating ip from project""" # Creating the floating IP that is to be deleted in this method floating_ip_body = self.client.create_floating_ip( pool=CONF.network.floating_network_name)['floating_ip'] @@ -59,6 +58,7 @@ class FloatingIPsTestJSON(base.BaseFloatingIPsTest): class FloatingIPsAssociationTestJSON(base.BaseFloatingIPsTest): + """Test floating ips association with microversion less than 2.44""" max_microversion = '2.43' @@ -80,9 +80,7 @@ class FloatingIPsAssociationTestJSON(base.BaseFloatingIPsTest): @testtools.skipUnless(CONF.network.public_network_id, 'The public_network_id option must be specified.') def test_associate_disassociate_floating_ip(self): - # Positive test:Associate and disassociate the provided floating IP - # to a specific server should be successful - + """Test associate/disassociate floating ip to a server""" # Association of floating IP to fixed IP address self.client.associate_floating_ip_to_server( self.floating_ip, @@ -102,6 +100,12 @@ class FloatingIPsAssociationTestJSON(base.BaseFloatingIPsTest): @testtools.skipUnless(CONF.network.public_network_id, 'The public_network_id option must be specified.') def test_associate_already_associated_floating_ip(self): + """Test associating an already associated floating ip + + First associate a floating ip to server1, then associate the floating + ip to server2, the floating ip will be associated to server2 and no + longer associated to server1. + """ # positive test:Association of an already associated floating IP # to specific server should change the association of the Floating IP # Create server so as to use for Multiple association