From a3050ec75122c135c5b4986d97ec6ea06fa4b266 Mon Sep 17 00:00:00 2001 From: parklong Date: Thu, 16 Apr 2015 15:31:22 +0800 Subject: [PATCH] Merge suspend-server 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 suspend-server functional tests. Change-Id: I3074d2544acecabca57b199357ccdce0dcde6a04 --- .../os-admin-actions/admin-actions-resume.json | 3 --- .../admin-actions-suspend.json | 3 --- .../admin-actions-resume.json.tpl | 3 --- .../admin-actions-suspend.json.tpl | 3 --- nova/tests/functional/test_api_samples.py | 13 ------------- .../tests/functional/v3/test_suspend_server.py | 18 ++++++++++++++++++ 6 files changed, 18 insertions(+), 25 deletions(-) delete mode 100644 doc/api_samples/os-admin-actions/admin-actions-resume.json delete mode 100644 doc/api_samples/os-admin-actions/admin-actions-suspend.json delete mode 100644 nova/tests/functional/api_samples/os-admin-actions/admin-actions-resume.json.tpl delete mode 100644 nova/tests/functional/api_samples/os-admin-actions/admin-actions-suspend.json.tpl diff --git a/doc/api_samples/os-admin-actions/admin-actions-resume.json b/doc/api_samples/os-admin-actions/admin-actions-resume.json deleted file mode 100644 index 008ff18c71..0000000000 --- a/doc/api_samples/os-admin-actions/admin-actions-resume.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "resume": null -} \ No newline at end of file diff --git a/doc/api_samples/os-admin-actions/admin-actions-suspend.json b/doc/api_samples/os-admin-actions/admin-actions-suspend.json deleted file mode 100644 index 7bee702052..0000000000 --- a/doc/api_samples/os-admin-actions/admin-actions-suspend.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "suspend": null -} \ No newline at end of file diff --git a/nova/tests/functional/api_samples/os-admin-actions/admin-actions-resume.json.tpl b/nova/tests/functional/api_samples/os-admin-actions/admin-actions-resume.json.tpl deleted file mode 100644 index ff00d97a14..0000000000 --- a/nova/tests/functional/api_samples/os-admin-actions/admin-actions-resume.json.tpl +++ /dev/null @@ -1,3 +0,0 @@ -{ - "resume": null -} diff --git a/nova/tests/functional/api_samples/os-admin-actions/admin-actions-suspend.json.tpl b/nova/tests/functional/api_samples/os-admin-actions/admin-actions-suspend.json.tpl deleted file mode 100644 index 8c2206a063..0000000000 --- a/nova/tests/functional/api_samples/os-admin-actions/admin-actions-suspend.json.tpl +++ /dev/null @@ -1,3 +0,0 @@ -{ - "suspend": null -} diff --git a/nova/tests/functional/test_api_samples.py b/nova/tests/functional/test_api_samples.py index 960cb45573..6ebab978d1 100644 --- a/nova/tests/functional/test_api_samples.py +++ b/nova/tests/functional/test_api_samples.py @@ -1259,19 +1259,6 @@ class AdminActionsSamplesJsonTest(ServersSampleBase): 'admin-actions-unpause', {}) self.assertEqual(response.status_code, 202) - def test_post_suspend(self): - # Get api samples to suspend server request. - response = self._do_post('servers/%s/action' % self.uuid, - 'admin-actions-suspend', {}) - self.assertEqual(response.status_code, 202) - - def test_post_resume(self): - # Get api samples to server resume request. - self.test_post_suspend() - response = self._do_post('servers/%s/action' % self.uuid, - 'admin-actions-resume', {}) - self.assertEqual(response.status_code, 202) - @mock.patch('nova.conductor.manager.ComputeTaskManager._cold_migrate') def test_post_migrate(self, mock_cold_migrate): # Get api samples to migrate server request. diff --git a/nova/tests/functional/v3/test_suspend_server.py b/nova/tests/functional/v3/test_suspend_server.py index 8cd882db6f..97b2f05fd3 100644 --- a/nova/tests/functional/v3/test_suspend_server.py +++ b/nova/tests/functional/v3/test_suspend_server.py @@ -12,12 +12,30 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo_config import cfg + from nova.tests.functional.v3 import test_servers +CONF = cfg.CONF +CONF.import_opt('osapi_compute_extension', + 'nova.api.openstack.compute.extensions') + class SuspendServerSamplesJsonTest(test_servers.ServersSampleBase): extension_name = "os-suspend-server" ctype = 'json' + extra_extensions_to_load = ["os-access-ips"] + # 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(SuspendServerSamplesJsonTest, self)._get_flags() + f['osapi_compute_extension'] = CONF.osapi_compute_extension[:] + f['osapi_compute_extension'].append( + 'nova.api.openstack.compute.contrib.admin_actions.Admin_actions') + return f def setUp(self): """setUp Method for SuspendServer api samples extension