From 860c481503a49b6834f5b5f305908ea68a602e9b Mon Sep 17 00:00:00 2001 From: parklong Date: Wed, 25 Mar 2015 17:17:22 +0800 Subject: [PATCH] Merge quota_classes functional tests of v2 and v2.1 Currently v2 and v2.1 have separate functional tests and their corresponding sample files. As v2 and v2.1 are supposed to be identical, there is overhead to maintain two set of functional tests and sample files. We can have one set of tests which can run for both v2 and v2.1. This commit merges quota_classes functional tests. In V2 quota_classes has following extensions - os-server-group-quotas - os-quota-class-sets In V2.1, os-server-group-quotas extensions have been moved to extensions limits, and there is no functional test for it. so we merge os-quota-class-sets between V2 and V2.1, and delete os-server-group-quotas Partially implements merge_sample_tests Change-Id: I46838ddffdb0c950781502716acaa01925ff9f67 --- .../quota-classes-show-get-resp.json | 17 ----------- .../quota-classes-update-post-req.json | 15 ---------- .../quota-classes-update-post-resp.json | 16 ---------- .../quota-classes-show-get-resp.json.tpl | 17 ----------- .../quota-classes-update-post-req.json.tpl | 16 ---------- .../quota-classes-update-post-resp.json.tpl | 16 ---------- nova/tests/functional/test_api_samples.py | 30 ------------------- .../tests/functional/v3/test_quota_classes.py | 18 +++++++++++ 8 files changed, 18 insertions(+), 127 deletions(-) delete mode 100644 doc/api_samples/os-quota-class-sets/quota-classes-show-get-resp.json delete mode 100644 doc/api_samples/os-quota-class-sets/quota-classes-update-post-req.json delete mode 100644 doc/api_samples/os-quota-class-sets/quota-classes-update-post-resp.json delete mode 100644 nova/tests/functional/api_samples/os-quota-class-sets/quota-classes-show-get-resp.json.tpl delete mode 100644 nova/tests/functional/api_samples/os-quota-class-sets/quota-classes-update-post-req.json.tpl delete mode 100644 nova/tests/functional/api_samples/os-quota-class-sets/quota-classes-update-post-resp.json.tpl diff --git a/doc/api_samples/os-quota-class-sets/quota-classes-show-get-resp.json b/doc/api_samples/os-quota-class-sets/quota-classes-show-get-resp.json deleted file mode 100644 index 6e477722dda8..000000000000 --- a/doc/api_samples/os-quota-class-sets/quota-classes-show-get-resp.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "quota_class_set": { - "cores": 20, - "fixed_ips": -1, - "floating_ips": 10, - "id": "test_class", - "injected_file_content_bytes": 10240, - "injected_file_path_bytes": 255, - "injected_files": 5, - "instances": 10, - "key_pairs": 100, - "metadata_items": 128, - "ram": 51200, - "security_group_rules": 20, - "security_groups": 10 - } -} diff --git a/doc/api_samples/os-quota-class-sets/quota-classes-update-post-req.json b/doc/api_samples/os-quota-class-sets/quota-classes-update-post-req.json deleted file mode 100644 index f074c829ffaa..000000000000 --- a/doc/api_samples/os-quota-class-sets/quota-classes-update-post-req.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "quota_class_set": { - "instances": 50, - "cores": 50, - "ram": 51200, - "floating_ips": 10, - "metadata_items": 128, - "injected_files": 5, - "injected_file_content_bytes": 10240, - "injected_file_path_bytes": 255, - "security_groups": 10, - "security_group_rules": 20, - "key_pairs": 100 - } -} diff --git a/doc/api_samples/os-quota-class-sets/quota-classes-update-post-resp.json b/doc/api_samples/os-quota-class-sets/quota-classes-update-post-resp.json deleted file mode 100644 index c86f86063b88..000000000000 --- a/doc/api_samples/os-quota-class-sets/quota-classes-update-post-resp.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "quota_class_set": { - "cores": 50, - "fixed_ips": -1, - "floating_ips": 10, - "injected_file_content_bytes": 10240, - "injected_file_path_bytes": 255, - "injected_files": 5, - "instances": 50, - "key_pairs": 100, - "metadata_items": 128, - "ram": 51200, - "security_group_rules": 20, - "security_groups": 10 - } -} diff --git a/nova/tests/functional/api_samples/os-quota-class-sets/quota-classes-show-get-resp.json.tpl b/nova/tests/functional/api_samples/os-quota-class-sets/quota-classes-show-get-resp.json.tpl deleted file mode 100644 index f9a94e760af7..000000000000 --- a/nova/tests/functional/api_samples/os-quota-class-sets/quota-classes-show-get-resp.json.tpl +++ /dev/null @@ -1,17 +0,0 @@ -{ - "quota_class_set": { - "cores": 20, - "floating_ips": 10, - "fixed_ips": -1, - "id": "%(set_id)s", - "injected_file_content_bytes": 10240, - "injected_file_path_bytes": 255, - "injected_files": 5, - "instances": 10, - "key_pairs": 100, - "metadata_items": 128, - "ram": 51200, - "security_group_rules": 20, - "security_groups": 10 - } -} diff --git a/nova/tests/functional/api_samples/os-quota-class-sets/quota-classes-update-post-req.json.tpl b/nova/tests/functional/api_samples/os-quota-class-sets/quota-classes-update-post-req.json.tpl deleted file mode 100644 index 483fda8c53e7..000000000000 --- a/nova/tests/functional/api_samples/os-quota-class-sets/quota-classes-update-post-req.json.tpl +++ /dev/null @@ -1,16 +0,0 @@ -{ - "quota_class_set": { - "instances": 50, - "cores": 50, - "ram": 51200, - "floating_ips": 10, - "fixed_ips": -1, - "metadata_items": 128, - "injected_files": 5, - "injected_file_content_bytes": 10240, - "injected_file_path_bytes": 255, - "security_groups": 10, - "security_group_rules": 20, - "key_pairs": 100 - } -} diff --git a/nova/tests/functional/api_samples/os-quota-class-sets/quota-classes-update-post-resp.json.tpl b/nova/tests/functional/api_samples/os-quota-class-sets/quota-classes-update-post-resp.json.tpl deleted file mode 100644 index c36783f2f0e6..000000000000 --- a/nova/tests/functional/api_samples/os-quota-class-sets/quota-classes-update-post-resp.json.tpl +++ /dev/null @@ -1,16 +0,0 @@ -{ - "quota_class_set": { - "cores": 50, - "floating_ips": 10, - "fixed_ips": -1, - "injected_file_content_bytes": 10240, - "injected_file_path_bytes": 255, - "injected_files": 5, - "instances": 50, - "key_pairs": 100, - "metadata_items": 128, - "ram": 51200, - "security_group_rules": 20, - "security_groups": 10 - } -} diff --git a/nova/tests/functional/test_api_samples.py b/nova/tests/functional/test_api_samples.py index 25092988f945..2548ac5bfc16 100644 --- a/nova/tests/functional/test_api_samples.py +++ b/nova/tests/functional/test_api_samples.py @@ -2489,28 +2489,6 @@ class NetworksAssociateJsonTests(ApiSampleTestBaseV2): self.assertEqual(response.content, "") -class QuotaClassesSampleJsonTests(ApiSampleTestBaseV2): - ADMIN_API = True - extension_name = ("nova.api.openstack.compute.contrib.quota_classes." - "Quota_classes") - set_id = 'test_class' - - def test_show_quota_classes(self): - # Get api sample to show quota classes. - response = self._do_get('os-quota-class-sets/%s' % self.set_id) - subs = {'set_id': self.set_id} - self._verify_response('quota-classes-show-get-resp', subs, - response, 200) - - def test_update_quota_classes(self): - # Get api sample to update quota classes. - response = self._do_put('os-quota-class-sets/%s' % self.set_id, - 'quota-classes-update-post-req', - {}) - self._verify_response('quota-classes-update-post-resp', - {}, response, 200) - - class FakeNode(object): def __init__(self, uuid='058d27fa-241b-445a-a386-08c04f96db43'): self.uuid = uuid @@ -4012,14 +3990,6 @@ class ServerGroupQuotas_QuotasSampleJsonTests(QuotasSampleJsonTests): extends_name = "nova.api.openstack.compute.contrib.quotas.Quotas" -class ServerGroupQuotasQuota_ClassesSampleJsonTests( - QuotaClassesSampleJsonTests): - extension_name = ("nova.api.openstack.compute.contrib." - "server_group_quotas.Server_group_quotas") - extends_name = ("nova.api.openstack.compute.contrib.quota_classes." - "Quota_classes") - - class ServerSortKeysJsonTests(ServersSampleBase): extension_name = ("nova.api.openstack.compute.contrib.server_sort_keys" ".Server_sort_keys") diff --git a/nova/tests/functional/v3/test_quota_classes.py b/nova/tests/functional/v3/test_quota_classes.py index cd1106a067ca..187c69b0e03c 100644 --- a/nova/tests/functional/v3/test_quota_classes.py +++ b/nova/tests/functional/v3/test_quota_classes.py @@ -13,13 +13,31 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo_config import cfg + from nova.tests.functional.v3 import api_sample_base +CONF = cfg.CONF +CONF.import_opt('osapi_compute_extension', + 'nova.api.openstack.compute.extensions') + class QuotaClassesSampleJsonTests(api_sample_base.ApiSampleTestBaseV3): ADMIN_API = True extension_name = "os-quota-class-sets" set_id = 'test_class' + # TODO(Park): Overriding '_api_version' till all functional tests + # are merged between v2 and v2.1. After that base class variable + # itself can be changed to 'v2' + _api_version = 'v2' + + def _get_flags(self): + f = super(QuotaClassesSampleJsonTests, self)._get_flags() + f['osapi_compute_extension'] = CONF.osapi_compute_extension[:] + f['osapi_compute_extension'].append( + 'nova.api.openstack.compute.contrib.quota_classes.' + 'Quota_classes') + return f def test_show_quota_classes(self): # Get api sample to show quota classes.