From 8975dab649f0dbeafbd3b7870e980430031ab851 Mon Sep 17 00:00:00 2001 From: ghanshyam Date: Tue, 7 Apr 2015 12:15:20 +0900 Subject: [PATCH] Merge config_drive functional 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 config drive 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 for server tests to run merged functional tests for both v2 and v2.1. Change-Id: I17d3a057f1cf97241ec7c259c6ce943e7523f0d9 --- .../server-config-drive-get-resp.json | 55 ------------------ .../servers-config-drive-details-resp.json | 57 ------------------- .../server-config-drive-get-resp.json | 10 ++-- .../os-config-drive/server-post-req.json | 6 +- .../os-config-drive/server-post-resp.json | 4 +- .../servers-config-drive-details-resp.json | 10 ++-- .../server-config-drive-get-resp.json.tpl | 55 ------------------ ...servers-config-drive-details-resp.json.tpl | 57 ------------------- nova/tests/functional/test_api_samples.py | 31 ---------- .../server-config-drive-get-resp.json.tpl | 10 ++-- .../os-config-drive/server-post-req.json.tpl | 6 +- .../os-config-drive/server-post-resp.json.tpl | 4 +- ...servers-config-drive-details-resp.json.tpl | 10 ++-- nova/tests/functional/v3/test_config_drive.py | 29 ++++++++++ 14 files changed, 65 insertions(+), 279 deletions(-) delete mode 100644 doc/api_samples/os-config-drive/server-config-drive-get-resp.json delete mode 100644 doc/api_samples/os-config-drive/servers-config-drive-details-resp.json delete mode 100644 nova/tests/functional/api_samples/os-config-drive/server-config-drive-get-resp.json.tpl delete mode 100644 nova/tests/functional/api_samples/os-config-drive/servers-config-drive-details-resp.json.tpl diff --git a/doc/api_samples/os-config-drive/server-config-drive-get-resp.json b/doc/api_samples/os-config-drive/server-config-drive-get-resp.json deleted file mode 100644 index 8745b3d62788..000000000000 --- a/doc/api_samples/os-config-drive/server-config-drive-get-resp.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "server": { - "accessIPv4": "", - "accessIPv6": "", - "addresses": { - "private": [ - { - "addr": "192.168.0.3", - "version": 4 - } - ] - }, - "config_drive": "", - "created": "2013-02-04T13:17:50Z", - "flavor": { - "id": "1", - "links": [ - { - "href": "http://openstack.example.com/openstack/flavors/1", - "rel": "bookmark" - } - ] - }, - "hostId": "8725fb615b191d8249a40f3e90d1efde88d914412e4edb2719176afd", - "id": "dd3b0715-a3fc-43d8-bbd2-2720beb226fb", - "image": { - "id": "70a599e0-31e7-49b7-b260-868f441e862b", - "links": [ - { - "href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b", - "rel": "bookmark" - } - ] - }, - "links": [ - { - "href": "http://openstack.example.com/v2/openstack/servers/dd3b0715-a3fc-43d8-bbd2-2720beb226fb", - "rel": "self" - }, - { - "href": "http://openstack.example.com/openstack/servers/dd3b0715-a3fc-43d8-bbd2-2720beb226fb", - "rel": "bookmark" - } - ], - "metadata": { - "My Server Name": "Apache1" - }, - "name": "new-server-test", - "progress": 0, - "status": "ACTIVE", - "tenant_id": "openstack", - "updated": "2013-02-04T13:17:51Z", - "user_id": "fake" - } -} \ No newline at end of file diff --git a/doc/api_samples/os-config-drive/servers-config-drive-details-resp.json b/doc/api_samples/os-config-drive/servers-config-drive-details-resp.json deleted file mode 100644 index 1373721ef549..000000000000 --- a/doc/api_samples/os-config-drive/servers-config-drive-details-resp.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "servers": [ - { - "accessIPv4": "", - "accessIPv6": "", - "addresses": { - "private": [ - { - "addr": "192.168.0.3", - "version": 4 - } - ] - }, - "config_drive": "", - "created": "2013-02-04T13:21:44Z", - "flavor": { - "id": "1", - "links": [ - { - "href": "http://openstack.example.com/openstack/flavors/1", - "rel": "bookmark" - } - ] - }, - "hostId": "76e154b0015e25fad65a7ab0c35a86dd79acfa8312075a6534ef6176", - "id": "720e688f-5ec8-4d4f-b585-dbd1a89ceeb0", - "image": { - "id": "70a599e0-31e7-49b7-b260-868f441e862b", - "links": [ - { - "href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b", - "rel": "bookmark" - } - ] - }, - "links": [ - { - "href": "http://openstack.example.com/v2/openstack/servers/720e688f-5ec8-4d4f-b585-dbd1a89ceeb0", - "rel": "self" - }, - { - "href": "http://openstack.example.com/openstack/servers/720e688f-5ec8-4d4f-b585-dbd1a89ceeb0", - "rel": "bookmark" - } - ], - "metadata": { - "My Server Name": "Apache1" - }, - "name": "new-server-test", - "progress": 0, - "status": "ACTIVE", - "tenant_id": "openstack", - "updated": "2013-02-04T13:21:44Z", - "user_id": "fake" - } - ] -} \ No newline at end of file diff --git a/doc/v3/api_samples/os-config-drive/server-config-drive-get-resp.json b/doc/v3/api_samples/os-config-drive/server-config-drive-get-resp.json index 2987dde866e8..2948b78b95ba 100644 --- a/doc/v3/api_samples/os-config-drive/server-config-drive-get-resp.json +++ b/doc/v3/api_samples/os-config-drive/server-config-drive-get-resp.json @@ -1,5 +1,7 @@ { "server": { + "accessIPv4": "1.2.3.4", + "accessIPv6": "80fe::", "addresses": { "private": [ { @@ -15,7 +17,7 @@ "id": "1", "links": [ { - "href": "http://openstack.example.com/flavors/1", + "href": "http://openstack.example.com/openstack/flavors/1", "rel": "bookmark" } ] @@ -26,7 +28,7 @@ "id": "70a599e0-31e7-49b7-b260-868f441e862b", "links": [ { - "href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b", + "href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b", "rel": "bookmark" } ] @@ -34,11 +36,11 @@ "key_name": null, "links": [ { - "href": "http://openstack.example.com/v3/servers/7838ff1b-b71f-48b9-91e9-7c08de20b249", + "href": "http://openstack.example.com/v2/openstack/servers/7838ff1b-b71f-48b9-91e9-7c08de20b249", "rel": "self" }, { - "href": "http://openstack.example.com/servers/7838ff1b-b71f-48b9-91e9-7c08de20b249", + "href": "http://openstack.example.com/openstack/servers/7838ff1b-b71f-48b9-91e9-7c08de20b249", "rel": "bookmark" } ], diff --git a/doc/v3/api_samples/os-config-drive/server-post-req.json b/doc/v3/api_samples/os-config-drive/server-post-req.json index d4c7973c108d..3c4d1055d5c1 100644 --- a/doc/v3/api_samples/os-config-drive/server-post-req.json +++ b/doc/v3/api_samples/os-config-drive/server-post-req.json @@ -1,8 +1,10 @@ { "server" : { + "accessIPv4": "1.2.3.4", + "accessIPv6": "80fe::", "name" : "new-server-test", - "imageRef" : "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b", - "flavorRef" : "http://openstack.example.com/flavors/1", + "imageRef" : "http://glance.openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b", + "flavorRef" : "http://openstack.example.com/openstack/flavors/1", "metadata" : { "My Server Name" : "Apache1" } diff --git a/doc/v3/api_samples/os-config-drive/server-post-resp.json b/doc/v3/api_samples/os-config-drive/server-post-resp.json index 88388573a75e..25a1750e323c 100644 --- a/doc/v3/api_samples/os-config-drive/server-post-resp.json +++ b/doc/v3/api_samples/os-config-drive/server-post-resp.json @@ -4,11 +4,11 @@ "id": "f0318e69-11eb-4aed-9840-59b6c72beee8", "links": [ { - "href": "http://openstack.example.com/v3/servers/f0318e69-11eb-4aed-9840-59b6c72beee8", + "href": "http://openstack.example.com/v2/openstack/servers/f0318e69-11eb-4aed-9840-59b6c72beee8", "rel": "self" }, { - "href": "http://openstack.example.com/servers/f0318e69-11eb-4aed-9840-59b6c72beee8", + "href": "http://openstack.example.com/openstack/servers/f0318e69-11eb-4aed-9840-59b6c72beee8", "rel": "bookmark" } ] diff --git a/doc/v3/api_samples/os-config-drive/servers-config-drive-details-resp.json b/doc/v3/api_samples/os-config-drive/servers-config-drive-details-resp.json index 30f48065bcd3..81759bd949d5 100644 --- a/doc/v3/api_samples/os-config-drive/servers-config-drive-details-resp.json +++ b/doc/v3/api_samples/os-config-drive/servers-config-drive-details-resp.json @@ -1,6 +1,8 @@ { "servers": [ { + "accessIPv4": "1.2.3.4", + "accessIPv6": "80fe::", "addresses": { "private": [ { @@ -16,7 +18,7 @@ "id": "1", "links": [ { - "href": "http://openstack.example.com/flavors/1", + "href": "http://openstack.example.com/openstack/flavors/1", "rel": "bookmark" } ] @@ -27,7 +29,7 @@ "id": "70a599e0-31e7-49b7-b260-868f441e862b", "links": [ { - "href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b", + "href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b", "rel": "bookmark" } ] @@ -35,11 +37,11 @@ "key_name": null, "links": [ { - "href": "http://openstack.example.com/v3/servers/f0318e69-11eb-4aed-9840-59b6c72beee8", + "href": "http://openstack.example.com/v2/openstack/servers/f0318e69-11eb-4aed-9840-59b6c72beee8", "rel": "self" }, { - "href": "http://openstack.example.com/servers/f0318e69-11eb-4aed-9840-59b6c72beee8", + "href": "http://openstack.example.com/openstack/servers/f0318e69-11eb-4aed-9840-59b6c72beee8", "rel": "bookmark" } ], diff --git a/nova/tests/functional/api_samples/os-config-drive/server-config-drive-get-resp.json.tpl b/nova/tests/functional/api_samples/os-config-drive/server-config-drive-get-resp.json.tpl deleted file mode 100644 index 723714bf7390..000000000000 --- a/nova/tests/functional/api_samples/os-config-drive/server-config-drive-get-resp.json.tpl +++ /dev/null @@ -1,55 +0,0 @@ -{ - "server": { - "accessIPv4": "", - "accessIPv6": "", - "addresses": { - "private": [ - { - "addr": "%(ip)s", - "version": 4 - } - ] - }, - "config_drive": "%(cdrive)s", - "created": "%(isotime)s", - "flavor": { - "id": "1", - "links": [ - { - "href": "%(host)s/openstack/flavors/1", - "rel": "bookmark" - } - ] - }, - "hostId": "%(hostid)s", - "id": "%(id)s", - "image": { - "id": "%(uuid)s", - "links": [ - { - "href": "%(host)s/openstack/images/%(uuid)s", - "rel": "bookmark" - } - ] - }, - "links": [ - { - "href": "%(host)s/v2/openstack/servers/%(id)s", - "rel": "self" - }, - { - "href": "%(host)s/openstack/servers/%(id)s", - "rel": "bookmark" - } - ], - "metadata": { - "My Server Name": "Apache1" - }, - "name": "new-server-test", - "progress": 0, - "status": "ACTIVE", - "tenant_id": "openstack", - "updated": "%(isotime)s", - "user_id": "fake" - } -} diff --git a/nova/tests/functional/api_samples/os-config-drive/servers-config-drive-details-resp.json.tpl b/nova/tests/functional/api_samples/os-config-drive/servers-config-drive-details-resp.json.tpl deleted file mode 100644 index f3ae979ecb2f..000000000000 --- a/nova/tests/functional/api_samples/os-config-drive/servers-config-drive-details-resp.json.tpl +++ /dev/null @@ -1,57 +0,0 @@ -{ - "servers": [ - { - "accessIPv4": "", - "accessIPv6": "", - "addresses": { - "private": [ - { - "addr": "%(ip)s", - "version": 4 - } - ] - }, - "config_drive": "%(cdrive)s", - "created": "%(isotime)s", - "flavor": { - "id": "1", - "links": [ - { - "href": "%(host)s/openstack/flavors/1", - "rel": "bookmark" - } - ] - }, - "hostId": "%(hostid)s", - "id": "%(id)s", - "image": { - "id": "%(uuid)s", - "links": [ - { - "href": "%(host)s/openstack/images/%(uuid)s", - "rel": "bookmark" - } - ] - }, - "links": [ - { - "href": "%(host)s/v2/openstack/servers/%(id)s", - "rel": "self" - }, - { - "href": "%(host)s/openstack/servers/%(id)s", - "rel": "bookmark" - } - ], - "metadata": { - "My Server Name": "Apache1" - }, - "name": "new-server-test", - "progress": 0, - "status": "ACTIVE", - "tenant_id": "openstack", - "updated": "%(isotime)s", - "user_id": "fake" - } - ] -} diff --git a/nova/tests/functional/test_api_samples.py b/nova/tests/functional/test_api_samples.py index 4a94af276f5a..826a36f22e31 100644 --- a/nova/tests/functional/test_api_samples.py +++ b/nova/tests/functional/test_api_samples.py @@ -778,37 +778,6 @@ class ExtendedAvailabilityZoneJsonTests(ServersSampleBase): self._verify_response('servers-detail-resp', subs, response, 200) -class ConfigDriveSampleJsonTest(ServersSampleBase): - extension_name = ("nova.api.openstack.compute.contrib.config_drive." - "Config_drive") - - def setUp(self): - super(ConfigDriveSampleJsonTest, self).setUp() - fakes.stub_out_networking(self.stubs) - fakes.stub_out_rate_limiting(self.stubs) - fake.stub_out_image_service(self.stubs) - - def test_config_drive_show(self): - uuid = self._post_server() - response = self._do_get('servers/%s' % uuid) - subs = self._get_regexes() - subs['hostid'] = '[a-f0-9]+' - # config drive can be a string for True or empty value for False - subs['cdrive'] = '.*' - self._verify_response('server-config-drive-get-resp', subs, - response, 200) - - def test_config_drive_detail(self): - self._post_server() - response = self._do_get('servers/detail') - subs = self._get_regexes() - subs['hostid'] = '[a-f0-9]+' - # config drive can be a string for True or empty value for False - subs['cdrive'] = '.*' - self._verify_response('servers-config-drive-details-resp', - subs, response, 200) - - class PreserveEphemeralOnRebuildJsonTest(ServersSampleBase): extension_name = ('nova.api.openstack.compute.contrib.' 'preserve_ephemeral_rebuild.' diff --git a/nova/tests/functional/v3/api_samples/os-config-drive/server-config-drive-get-resp.json.tpl b/nova/tests/functional/v3/api_samples/os-config-drive/server-config-drive-get-resp.json.tpl index a9e9bc6564e7..65b858c0be84 100644 --- a/nova/tests/functional/v3/api_samples/os-config-drive/server-config-drive-get-resp.json.tpl +++ b/nova/tests/functional/v3/api_samples/os-config-drive/server-config-drive-get-resp.json.tpl @@ -1,6 +1,8 @@ { "server": { "config_drive": "%(cdrive)s", + "accessIPv4": "%(access_ip_v4)s", + "accessIPv6": "%(access_ip_v6)s", "addresses": { "private": [ { @@ -16,7 +18,7 @@ "id": "1", "links": [ { - "href": "%(host)s/flavors/1", + "href": "%(host)s/openstack/flavors/1", "rel": "bookmark" } ] @@ -27,18 +29,18 @@ "id": "%(uuid)s", "links": [ { - "href": "%(host)s/images/%(uuid)s", + "href": "%(host)s/openstack/images/%(uuid)s", "rel": "bookmark" } ] }, "links": [ { - "href": "%(host)s/v3/servers/%(uuid)s", + "href": "%(host)s/v2/openstack/servers/%(uuid)s", "rel": "self" }, { - "href": "%(host)s/servers/%(uuid)s", + "href": "%(host)s/openstack/servers/%(uuid)s", "rel": "bookmark" } ], diff --git a/nova/tests/functional/v3/api_samples/os-config-drive/server-post-req.json.tpl b/nova/tests/functional/v3/api_samples/os-config-drive/server-post-req.json.tpl index ab0a3bb797eb..99adbe8290da 100644 --- a/nova/tests/functional/v3/api_samples/os-config-drive/server-post-req.json.tpl +++ b/nova/tests/functional/v3/api_samples/os-config-drive/server-post-req.json.tpl @@ -1,8 +1,10 @@ { "server" : { + "accessIPv4": "%(access_ip_v4)s", + "accessIPv6": "%(access_ip_v6)s", "name" : "new-server-test", - "imageRef" : "%(glance_host)s/images/%(image_id)s", - "flavorRef" : "%(host)s/flavors/1", + "imageRef" : "%(glance_host)s/openstack/images/%(image_id)s", + "flavorRef" : "%(host)s/openstack/flavors/1", "metadata" : { "My Server Name" : "Apache1" } diff --git a/nova/tests/functional/v3/api_samples/os-config-drive/server-post-resp.json.tpl b/nova/tests/functional/v3/api_samples/os-config-drive/server-post-resp.json.tpl index 71654b4b8a8b..abbc7cf6b2c6 100644 --- a/nova/tests/functional/v3/api_samples/os-config-drive/server-post-resp.json.tpl +++ b/nova/tests/functional/v3/api_samples/os-config-drive/server-post-resp.json.tpl @@ -4,11 +4,11 @@ "id": "%(id)s", "links": [ { - "href": "http://openstack.example.com/v3/servers/%(uuid)s", + "href": "http://openstack.example.com/v2/openstack/servers/%(uuid)s", "rel": "self" }, { - "href": "http://openstack.example.com/servers/%(uuid)s", + "href": "http://openstack.example.com/openstack/servers/%(uuid)s", "rel": "bookmark" } ] diff --git a/nova/tests/functional/v3/api_samples/os-config-drive/servers-config-drive-details-resp.json.tpl b/nova/tests/functional/v3/api_samples/os-config-drive/servers-config-drive-details-resp.json.tpl index 21ed41cf7ddb..12ef2545d47b 100644 --- a/nova/tests/functional/v3/api_samples/os-config-drive/servers-config-drive-details-resp.json.tpl +++ b/nova/tests/functional/v3/api_samples/os-config-drive/servers-config-drive-details-resp.json.tpl @@ -2,6 +2,8 @@ "servers": [ { "config_drive": "%(cdrive)s", + "accessIPv4": "%(access_ip_v4)s", + "accessIPv6": "%(access_ip_v6)s", "addresses": { "private": [ { @@ -17,7 +19,7 @@ "id": "1", "links": [ { - "href": "%(host)s/flavors/1", + "href": "%(host)s/openstack/flavors/1", "rel": "bookmark" } ] @@ -28,18 +30,18 @@ "id": "%(uuid)s", "links": [ { - "href": "%(host)s/images/%(uuid)s", + "href": "%(host)s/openstack/images/%(uuid)s", "rel": "bookmark" } ] }, "links": [ { - "href": "%(host)s/v3/servers/%(uuid)s", + "href": "%(host)s/v2/openstack/servers/%(uuid)s", "rel": "self" }, { - "href": "%(host)s/servers/%(id)s", + "href": "%(host)s/openstack/servers/%(id)s", "rel": "bookmark" } ], diff --git a/nova/tests/functional/v3/test_config_drive.py b/nova/tests/functional/v3/test_config_drive.py index 8b181b0c2f41..b542ab54dbe7 100644 --- a/nova/tests/functional/v3/test_config_drive.py +++ b/nova/tests/functional/v3/test_config_drive.py @@ -13,13 +13,38 @@ # 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 from nova.tests.unit.api.openstack import fakes from nova.tests.unit.image import fake +CONF = cfg.CONF +CONF.import_opt('osapi_compute_extension', + 'nova.api.openstack.compute.extensions') + class ConfigDriveSampleJsonTest(test_servers.ServersSampleBase): extension_name = 'os-config-drive' + extra_extensions_to_load = ["os-access-ips"] + # TODO(gmann): 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(ConfigDriveSampleJsonTest, self)._get_flags() + f['osapi_compute_extension'] = CONF.osapi_compute_extension[:] + f['osapi_compute_extension'].append( + 'nova.api.openstack.compute.contrib.config_drive.Config_drive') + f['osapi_compute_extension'].append( + 'nova.api.openstack.compute.contrib.keypairs.Keypairs') + f['osapi_compute_extension'].append( + 'nova.api.openstack.compute.contrib.extended_ips.Extended_ips') + f['osapi_compute_extension'].append( + 'nova.api.openstack.compute.contrib.extended_ips_mac.' + 'Extended_ips_mac') + return f def setUp(self): super(ConfigDriveSampleJsonTest, self).setUp() @@ -34,6 +59,8 @@ class ConfigDriveSampleJsonTest(test_servers.ServersSampleBase): subs['hostid'] = '[a-f0-9]+' # config drive can be a string for True or empty value for False subs['cdrive'] = '.*' + subs['access_ip_v4'] = '1.2.3.4' + subs['access_ip_v6'] = '80fe::' self._verify_response('server-config-drive-get-resp', subs, response, 200) @@ -44,5 +71,7 @@ class ConfigDriveSampleJsonTest(test_servers.ServersSampleBase): subs['hostid'] = '[a-f0-9]+' # config drive can be a string for True or empty value for False subs['cdrive'] = '.*' + subs['access_ip_v4'] = '1.2.3.4' + subs['access_ip_v6'] = '80fe::' self._verify_response('servers-config-drive-details-resp', subs, response, 200)