From 4aa5ca5424802a5978dbddb0c333758cd73f1b14 Mon Sep 17 00:00:00 2001 From: ghanshyam Date: Fri, 10 Apr 2015 14:53:15 +0900 Subject: [PATCH] Merge lock/pause server tests between 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 servers actions lock/unlock, pause/unpause server functional tests. In V2.1 os-access-ip is separate plugin where in v2 it was mixed in server plugin itself. So os-access-ip extension is enabled to run merged functional tests for both v2 and v2.1. Change-Id: I7e6c9d414959019eb6d29b2e87e1d8104c801903 --- .../admin-actions-lock-server.json | 3 --- .../os-admin-actions/admin-actions-pause.json | 3 --- .../admin-actions-unlock-server.json | 3 --- .../admin-actions-unlock.json | 3 --- .../admin-actions-unpause.json | 3 --- .../admin-actions-lock-server.json.tpl | 3 --- .../admin-actions-pause.json.tpl | 3 --- .../admin-actions-unlock-server.json.tpl | 3 --- .../admin-actions-unpause.json.tpl | 3 --- nova/tests/functional/test_api_samples.py | 26 ------------------- nova/tests/functional/v3/test_lock_server.py | 15 +++++++++++ nova/tests/functional/v3/test_pause_server.py | 15 +++++++++++ 12 files changed, 30 insertions(+), 53 deletions(-) delete mode 100644 doc/api_samples/os-admin-actions/admin-actions-lock-server.json delete mode 100644 doc/api_samples/os-admin-actions/admin-actions-pause.json delete mode 100644 doc/api_samples/os-admin-actions/admin-actions-unlock-server.json delete mode 100644 doc/api_samples/os-admin-actions/admin-actions-unlock.json delete mode 100644 doc/api_samples/os-admin-actions/admin-actions-unpause.json delete mode 100644 nova/tests/functional/api_samples/os-admin-actions/admin-actions-lock-server.json.tpl delete mode 100644 nova/tests/functional/api_samples/os-admin-actions/admin-actions-pause.json.tpl delete mode 100644 nova/tests/functional/api_samples/os-admin-actions/admin-actions-unlock-server.json.tpl delete mode 100644 nova/tests/functional/api_samples/os-admin-actions/admin-actions-unpause.json.tpl diff --git a/doc/api_samples/os-admin-actions/admin-actions-lock-server.json b/doc/api_samples/os-admin-actions/admin-actions-lock-server.json deleted file mode 100644 index d7e96964ef23..000000000000 --- a/doc/api_samples/os-admin-actions/admin-actions-lock-server.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "lock": null -} \ No newline at end of file diff --git a/doc/api_samples/os-admin-actions/admin-actions-pause.json b/doc/api_samples/os-admin-actions/admin-actions-pause.json deleted file mode 100644 index c44ca70599da..000000000000 --- a/doc/api_samples/os-admin-actions/admin-actions-pause.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "pause": null -} \ No newline at end of file diff --git a/doc/api_samples/os-admin-actions/admin-actions-unlock-server.json b/doc/api_samples/os-admin-actions/admin-actions-unlock-server.json deleted file mode 100644 index 0eba7e725291..000000000000 --- a/doc/api_samples/os-admin-actions/admin-actions-unlock-server.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "unlock": null -} \ No newline at end of file diff --git a/doc/api_samples/os-admin-actions/admin-actions-unlock.json b/doc/api_samples/os-admin-actions/admin-actions-unlock.json deleted file mode 100644 index 9e905ca2b99e..000000000000 --- a/doc/api_samples/os-admin-actions/admin-actions-unlock.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "unlock": null -} diff --git a/doc/api_samples/os-admin-actions/admin-actions-unpause.json b/doc/api_samples/os-admin-actions/admin-actions-unpause.json deleted file mode 100644 index fdc0c410c3d5..000000000000 --- a/doc/api_samples/os-admin-actions/admin-actions-unpause.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "unpause": null -} \ No newline at end of file diff --git a/nova/tests/functional/api_samples/os-admin-actions/admin-actions-lock-server.json.tpl b/nova/tests/functional/api_samples/os-admin-actions/admin-actions-lock-server.json.tpl deleted file mode 100644 index a1863f2f3914..000000000000 --- a/nova/tests/functional/api_samples/os-admin-actions/admin-actions-lock-server.json.tpl +++ /dev/null @@ -1,3 +0,0 @@ -{ - "lock": null -} diff --git a/nova/tests/functional/api_samples/os-admin-actions/admin-actions-pause.json.tpl b/nova/tests/functional/api_samples/os-admin-actions/admin-actions-pause.json.tpl deleted file mode 100644 index 2e7c1fad307f..000000000000 --- a/nova/tests/functional/api_samples/os-admin-actions/admin-actions-pause.json.tpl +++ /dev/null @@ -1,3 +0,0 @@ -{ - "pause": null -} diff --git a/nova/tests/functional/api_samples/os-admin-actions/admin-actions-unlock-server.json.tpl b/nova/tests/functional/api_samples/os-admin-actions/admin-actions-unlock-server.json.tpl deleted file mode 100644 index 9e905ca2b99e..000000000000 --- a/nova/tests/functional/api_samples/os-admin-actions/admin-actions-unlock-server.json.tpl +++ /dev/null @@ -1,3 +0,0 @@ -{ - "unlock": null -} diff --git a/nova/tests/functional/api_samples/os-admin-actions/admin-actions-unpause.json.tpl b/nova/tests/functional/api_samples/os-admin-actions/admin-actions-unpause.json.tpl deleted file mode 100644 index ce5024f0c92a..000000000000 --- a/nova/tests/functional/api_samples/os-admin-actions/admin-actions-unpause.json.tpl +++ /dev/null @@ -1,3 +0,0 @@ -{ - "unpause": null -} diff --git a/nova/tests/functional/test_api_samples.py b/nova/tests/functional/test_api_samples.py index 16e6f6a4c4ab..ab4d4422cdfc 100644 --- a/nova/tests/functional/test_api_samples.py +++ b/nova/tests/functional/test_api_samples.py @@ -875,19 +875,6 @@ class AdminActionsSamplesJsonTest(ServersSampleBase): super(AdminActionsSamplesJsonTest, self).setUp() self.uuid = self._post_server() - def test_post_pause(self): - # Get api samples to pause server request. - response = self._do_post('servers/%s/action' % self.uuid, - 'admin-actions-pause', {}) - self.assertEqual(response.status_code, 202) - - def test_post_unpause(self): - # Get api samples to unpause server request. - self.test_post_pause() - response = self._do_post('servers/%s/action' % self.uuid, - 'admin-actions-unpause', {}) - 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. @@ -907,19 +894,6 @@ class AdminActionsSamplesJsonTest(ServersSampleBase): 'admin-actions-inject-network-info', {}) self.assertEqual(response.status_code, 202) - def test_post_lock_server(self): - # Get api samples to lock server request. - response = self._do_post('servers/%s/action' % self.uuid, - 'admin-actions-lock-server', {}) - self.assertEqual(response.status_code, 202) - - def test_post_unlock_server(self): - # Get api samples to unlock server request. - self.test_post_lock_server() - response = self._do_post('servers/%s/action' % self.uuid, - 'admin-actions-unlock-server', {}) - self.assertEqual(response.status_code, 202) - def test_post_live_migrate_server(self): # Get api samples to server live migrate request. def fake_live_migrate(_self, context, instance, scheduler_hint, diff --git a/nova/tests/functional/v3/test_lock_server.py b/nova/tests/functional/v3/test_lock_server.py index 7baa68250110..bbd72f8a83ac 100644 --- a/nova/tests/functional/v3/test_lock_server.py +++ b/nova/tests/functional/v3/test_lock_server.py @@ -13,11 +13,26 @@ # 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 LockServerSamplesJsonTest(test_servers.ServersSampleBase): extension_name = "os-lock-server" + extra_extensions_to_load = ["os-access-ips"] + _api_version = 'v2' + + def _get_flags(self): + f = super(LockServerSamplesJsonTest, 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 LockServer api samples extension diff --git a/nova/tests/functional/v3/test_pause_server.py b/nova/tests/functional/v3/test_pause_server.py index 94228573c426..f0aad8fa0443 100644 --- a/nova/tests/functional/v3/test_pause_server.py +++ b/nova/tests/functional/v3/test_pause_server.py @@ -13,11 +13,26 @@ # 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 PauseServerSamplesJsonTest(test_servers.ServersSampleBase): extension_name = "os-pause-server" + extra_extensions_to_load = ["os-access-ips"] + _api_version = 'v2' + + def _get_flags(self): + f = super(PauseServerSamplesJsonTest, 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 PauseServer api samples extension