From 9a371de8f2ddd0a71783590c5b3e5c6328c7545b Mon Sep 17 00:00:00 2001 From: parklong Date: Thu, 16 Apr 2015 15:08:25 +0800 Subject: [PATCH] Merge create-backup 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 create-backup functional tests. Change-Id: I3edd045fa61e4e6469fce6ccc9d49e4f400c089f --- .../admin-actions-backup-server.json | 7 ------- .../admin-actions-backup-server.json.tpl | 7 ------- nova/tests/functional/test_api_samples.py | 15 --------------- nova/tests/functional/v3/test_create_backup.py | 18 ++++++++++++++++++ 4 files changed, 18 insertions(+), 29 deletions(-) delete mode 100644 doc/api_samples/os-admin-actions/admin-actions-backup-server.json delete mode 100644 nova/tests/functional/api_samples/os-admin-actions/admin-actions-backup-server.json.tpl diff --git a/doc/api_samples/os-admin-actions/admin-actions-backup-server.json b/doc/api_samples/os-admin-actions/admin-actions-backup-server.json deleted file mode 100644 index 38c03b0eb0..0000000000 --- a/doc/api_samples/os-admin-actions/admin-actions-backup-server.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "createBackup": { - "name": "Backup 1", - "backup_type": "daily", - "rotation": 1 - } -} \ No newline at end of file diff --git a/nova/tests/functional/api_samples/os-admin-actions/admin-actions-backup-server.json.tpl b/nova/tests/functional/api_samples/os-admin-actions/admin-actions-backup-server.json.tpl deleted file mode 100644 index 60f5e1d9fe..0000000000 --- a/nova/tests/functional/api_samples/os-admin-actions/admin-actions-backup-server.json.tpl +++ /dev/null @@ -1,7 +0,0 @@ -{ - "createBackup": { - "name": "Backup 1", - "backup_type": "daily", - "rotation": 1 - } -} diff --git a/nova/tests/functional/test_api_samples.py b/nova/tests/functional/test_api_samples.py index a6deeebb04..9046620078 100644 --- a/nova/tests/functional/test_api_samples.py +++ b/nova/tests/functional/test_api_samples.py @@ -1175,21 +1175,6 @@ class AdminActionsSamplesJsonTest(ServersSampleBase): 'admin-actions-unlock-server', {}) self.assertEqual(response.status_code, 202) - def test_post_backup_server(self): - # Get api samples to backup server request. - def image_details(self, context, **kwargs): - """This stub is specifically used on the backup action.""" - # NOTE(maurosr): I've added this simple stub cause backup action - # was trapped in infinite loop during fetch image phase since the - # fake Image Service always returns the same set of images - return [] - - self.stubs.Set(fake._FakeImageService, 'detail', image_details) - - response = self._do_post('servers/%s/action' % self.uuid, - 'admin-actions-backup-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_create_backup.py b/nova/tests/functional/v3/test_create_backup.py index 357026f0b5..39e423122f 100644 --- a/nova/tests/functional/v3/test_create_backup.py +++ b/nova/tests/functional/v3/test_create_backup.py @@ -13,14 +13,32 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo_config import cfg + import mock from nova.tests.functional.v3 import test_servers from nova.tests.unit.image import fake +CONF = cfg.CONF +CONF.import_opt('osapi_compute_extension', + 'nova.api.openstack.compute.extensions') + class CreateBackupSamplesJsonTest(test_servers.ServersSampleBase): extension_name = "os-create-backup" + 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(CreateBackupSamplesJsonTest, 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