Merge 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 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: I3dda5820cf8e1897c7a3895edb43bc708db9073d
This commit is contained in:
ghanshyam 2015-04-03 14:32:38 +09:00 committed by Ghanshyam Mann
parent bf70df295b
commit f713c7c7b5
56 changed files with 233 additions and 494 deletions

View File

@ -1,18 +0,0 @@
{
"servers": [
{
"id": "e08e6d34-fcc1-480e-b11e-24a675b479f8",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/servers/e08e6d34-fcc1-480e-b11e-24a675b479f8",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/servers/e08e6d34-fcc1-480e-b11e-24a675b479f8",
"rel": "bookmark"
}
],
"name": "new-server-test"
}
]
}

View File

@ -1,3 +0,0 @@
{
"os-stop" : null
}

View File

@ -1,54 +0,0 @@
{
"server": {
"accessIPv4": "",
"accessIPv6": "",
"addresses": {
"private": [
{
"addr": "192.168.0.3",
"version": 4
}
]
},
"created": "2012-08-20T21:11:09Z",
"flavor": {
"id": "1",
"links": [
{
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
]
},
"hostId": "65201c14a29663e06d0748e561207d998b343e1d164bfa0aafa9c45d",
"id": "893c7791-f1df-4c3d-8383-3caae9656c62",
"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/893c7791-f1df-4c3d-8383-3caae9656c62",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/servers/893c7791-f1df-4c3d-8383-3caae9656c62",
"rel": "bookmark"
}
],
"metadata": {
"My Server Name": "Apache1"
},
"name": "new-server-test",
"progress": 0,
"status": "ACTIVE",
"tenant_id": "openstack",
"updated": "2012-08-20T21:11:09Z",
"user_id": "fake"
}
}

View File

@ -1,56 +0,0 @@
{
"servers": [
{
"accessIPv4": "",
"accessIPv6": "",
"addresses": {
"private": [
{
"addr": "192.168.0.3",
"version": 4
}
]
},
"created": "2012-09-07T16:56:37Z",
"flavor": {
"id": "1",
"links": [
{
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
]
},
"hostId": "16d193736a5cfdb60c697ca27ad071d6126fa13baeb670fc9d10645e",
"id": "05184ba3-00ba-4fbc-b7a2-03b62b884931",
"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/05184ba3-00ba-4fbc-b7a2-03b62b884931",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/servers/05184ba3-00ba-4fbc-b7a2-03b62b884931",
"rel": "bookmark"
}
],
"metadata": {
"My Server Name": "Apache1"
},
"name": "new-server-test",
"progress": 0,
"status": "ACTIVE",
"tenant_id": "openstack",
"updated": "2012-09-07T16:56:37Z",
"user_id": "fake"
}
]
}

View File

@ -1,18 +0,0 @@
{
"servers": [
{
"id": "616fb98f-46ca-475e-917e-2563e5a8cd19",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/servers/616fb98f-46ca-475e-917e-2563e5a8cd19",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/servers/616fb98f-46ca-475e-917e-2563e5a8cd19",
"rel": "bookmark"
}
],
"name": "new-server-test"
}
]
}

View File

@ -2,7 +2,7 @@
"createImage" : {
"name" : "foo-image",
"metadata": {
"myvar": "foobar"
"meta_var": "meta_val"
}
}
}

View File

@ -1,7 +1,8 @@
{
"server": {
"OS-DCF:diskConfig": "AUTO",
"accessIPv4": "1.2.3.4",
"accessIPv6": "fe80::100",
"accessIPv6": "80fe::",
"addresses": {
"private": [
{
@ -11,7 +12,7 @@
]
},
"adminPass": "seekr3t",
"created": "2012-09-12T17:20:36Z",
"created": "2012-09-25T13:36:08Z",
"flavor": {
"id": "1",
"links": [
@ -21,8 +22,8 @@
}
]
},
"hostId": "1e3da81662354c25560b7e5ea6d8123031f67168b6992f20bb84df69",
"id": "075e40fe-9f03-4652-ba8e-5f8e2547899a",
"hostId": "935dcd1019fd43814a1d2a6e9b320dcac352d3a02c69f8be7ba41002",
"id": "27568e59-cfb7-4283-a00e-4af933f2d539",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
@ -34,11 +35,11 @@
},
"links": [
{
"href": "http://openstack.example.com/v2/openstack/servers/075e40fe-9f03-4652-ba8e-5f8e2547899a",
"href": "http://openstack.example.com/v2/openstack/servers/27568e59-cfb7-4283-a00e-4af933f2d539",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/servers/075e40fe-9f03-4652-ba8e-5f8e2547899a",
"href": "http://openstack.example.com/openstack/servers/27568e59-cfb7-4283-a00e-4af933f2d539",
"rel": "bookmark"
}
],
@ -49,7 +50,7 @@
"progress": 0,
"status": "ACTIVE",
"tenant_id": "openstack",
"updated": "2012-09-12T17:20:37Z",
"updated": "2012-09-25T13:36:09Z",
"user_id": "fake"
}
}

View File

@ -4,7 +4,7 @@
"name" : "foobar",
"adminPass" : "seekr3t",
"accessIPv4" : "1.2.3.4",
"accessIPv6" : "fe80::100",
"accessIPv6" : "80fe::",
"metadata" : {
"meta var" : "meta val"
},

View File

@ -15,7 +15,7 @@
"id": "1",
"links": [
{
"href": "http://openstack.example.com/flavors/1",
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
]
@ -26,7 +26,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 +34,11 @@
"key_name": null,
"links": [
{
"href": "http://openstack.example.com/v3/servers/f474386b-4fb6-4e1f-b1d5-d6bf4437f7d5",
"href": "http://openstack.example.com/v2/openstack/servers/f474386b-4fb6-4e1f-b1d5-d6bf4437f7d5",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/f474386b-4fb6-4e1f-b1d5-d6bf4437f7d5",
"href": "http://openstack.example.com/openstack/servers/f474386b-4fb6-4e1f-b1d5-d6bf4437f7d5",
"rel": "bookmark"
}
],

View File

@ -5,11 +5,11 @@
"id": "8195065c-fea4-4d57-b93f-5c5c63fe90e8",
"links": [
{
"href": "http://openstack.example.com/v3/servers/8195065c-fea4-4d57-b93f-5c5c63fe90e8",
"href": "http://openstack.example.com/v2/openstack/servers/8195065c-fea4-4d57-b93f-5c5c63fe90e8",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/8195065c-fea4-4d57-b93f-5c5c63fe90e8",
"href": "http://openstack.example.com/openstack/servers/8195065c-fea4-4d57-b93f-5c5c63fe90e8",
"rel": "bookmark"
}
],

View File

@ -16,7 +16,7 @@
"id": "1",
"links": [
{
"href": "http://openstack.example.com/flavors/1",
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
]
@ -27,7 +27,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 +35,11 @@
"key_name": null,
"links": [
{
"href": "http://openstack.example.com/v3/servers/9cbefc35-d372-40c5-88e2-9fda1b6ea12c",
"href": "http://openstack.example.com/v2/openstack/servers/9cbefc35-d372-40c5-88e2-9fda1b6ea12c",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/9cbefc35-d372-40c5-88e2-9fda1b6ea12c",
"href": "http://openstack.example.com/openstack/servers/9cbefc35-d372-40c5-88e2-9fda1b6ea12c",
"rel": "bookmark"
}
],

View File

@ -4,11 +4,11 @@
"id": "a291599e-6de2-41a6-88df-c443ddcef70d",
"links": [
{
"href": "http://openstack.example.com/v3/servers/a291599e-6de2-41a6-88df-c443ddcef70d",
"href": "http://openstack.example.com/v2/openstack/servers/a291599e-6de2-41a6-88df-c443ddcef70d",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/a291599e-6de2-41a6-88df-c443ddcef70d",
"href": "http://openstack.example.com/openstack/servers/a291599e-6de2-41a6-88df-c443ddcef70d",
"rel": "bookmark"
}
],

View File

@ -4,11 +4,11 @@
"id": "e08e6d34-fcc1-480e-b11e-24a675b479f8",
"links": [
{
"href": "http://openstack.example.com/v3/servers/e08e6d34-fcc1-480e-b11e-24a675b479f8",
"href": "http://openstack.example.com/v2/openstack/servers/e08e6d34-fcc1-480e-b11e-24a675b479f8",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/e08e6d34-fcc1-480e-b11e-24a675b479f8",
"href": "http://openstack.example.com/openstack/servers/e08e6d34-fcc1-480e-b11e-24a675b479f8",
"rel": "bookmark"
}
],

View File

@ -1,5 +1,7 @@
{
"server": {
"accessIPv4": "1.2.3.4",
"accessIPv6": "80fe::",
"addresses": {
"private": [
{
@ -14,7 +16,7 @@
"id": "1",
"links": [
{
"href": "http://openstack.example.com/flavors/1",
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
]
@ -25,18 +27,18 @@
"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"
}
]
},
"links": [
{
"href": "http://openstack.example.com/v3/servers/a0a80a94-3d81-4a10-822a-daa0cf9e870b",
"href": "http://openstack.example.com/v2/openstack/servers/a0a80a94-3d81-4a10-822a-daa0cf9e870b",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/a0a80a94-3d81-4a10-822a-daa0cf9e870b",
"href": "http://openstack.example.com/openstack/servers/a0a80a94-3d81-4a10-822a-daa0cf9e870b",
"rel": "bookmark"
}
],

View File

@ -1,16 +1,12 @@
{
"rebuild" : {
"accessIPv4" : "1.2.3.4",
"accessIPv6" : "80fe::",
"imageRef" : "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"name" : "foobar",
"adminPass" : "seekr3t",
"metadata" : {
"meta_var" : "meta_val"
},
"personality" : [
{
"path" : "/etc/banner.txt",
"contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 b25zLiINCg0KLVJpY2hhcmQgQmFjaA=="
}
]
}
}
}

View File

@ -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/0e44cc9c-e052-415d-afbf-469b0d384170",
"href": "http://openstack.example.com/v2/openstack/servers/0e44cc9c-e052-415d-afbf-469b0d384170",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/0e44cc9c-e052-415d-afbf-469b0d384170",
"href": "http://openstack.example.com/openstack/servers/0e44cc9c-e052-415d-afbf-469b0d384170",
"rel": "bookmark"
}
],

View File

@ -1,5 +1,7 @@
{
"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",

View File

@ -4,11 +4,11 @@
"id": "f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"links": [
{
"href": "http://openstack.example.com/v3/servers/f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"href": "http://openstack.example.com/v2/openstack/servers/f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"href": "http://openstack.example.com/openstack/servers/f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"rel": "bookmark"
}
]

View File

@ -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/f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"href": "http://openstack.example.com/v2/openstack/servers/f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"href": "http://openstack.example.com/openstack/servers/f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"rel": "bookmark"
}
],

View File

@ -4,11 +4,11 @@
"id": "22c91117-08de-4894-9aa9-6ef382400985",
"links": [
{
"href": "http://openstack.example.com/v3/servers/22c91117-08de-4894-9aa9-6ef382400985",
"href": "http://openstack.example.com/v2/openstack/servers/22c91117-08de-4894-9aa9-6ef382400985",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/22c91117-08de-4894-9aa9-6ef382400985",
"href": "http://openstack.example.com/openstack/servers/22c91117-08de-4894-9aa9-6ef382400985",
"rel": "bookmark"
}
],

View File

@ -0,0 +1,10 @@
{
"server" : {
"name" : "new-server-test",
"imageRef" : "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"flavorRef" : "http://openstack.example.com/flavors/1",
"metadata" : {
"My Server Name" : "Apache1"
}
}
}

View File

@ -0,0 +1,16 @@
{
"server": {
"adminPass": "6NpUwoz2QDRN",
"id": "f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"links": [
{
"href": "http://openstack.example.com/v3/servers/f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"rel": "bookmark"
}
]
}
}

View File

@ -1,18 +0,0 @@
{
"servers": [
{
"id": "%(id)s",
"links": [
{
"href": "%(host)s/v2/openstack/servers/%(id)s",
"rel": "self"
},
{
"href": "%(host)s/openstack/servers/%(id)s",
"rel": "bookmark"
}
],
"name": "new-server-test"
}
]
}

View File

@ -1,3 +0,0 @@
{
"%(action)s" : null
}

View File

@ -1,54 +0,0 @@
{
"server": {
"accessIPv4": "",
"accessIPv6": "",
"addresses": {
"private": [
{
"addr": "%(ip)s",
"version": 4
}
]
},
"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"
}
}

View File

@ -1,56 +0,0 @@
{
"servers": [
{
"accessIPv4": "",
"accessIPv6": "",
"addresses": {
"private": [
{
"addr": "%(ip)s",
"version": 4
}
]
},
"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"
}
]
}

View File

@ -1,18 +0,0 @@
{
"servers": [
{
"id": "%(id)s",
"links": [
{
"href": "%(host)s/v2/openstack/servers/%(id)s",
"rel": "self"
},
{
"href": "%(host)s/openstack/servers/%(id)s",
"rel": "bookmark"
}
],
"name": "new-server-test"
}
]
}

View File

@ -197,8 +197,19 @@ class ServersSampleBase(ApiSampleTestBaseV2):
self.__class__._use_common_server_api_samples = orig_value
class ServersSampleJsonTest(ServersSampleBase):
sample_dir = 'servers'
class ServersSampleHideAddressesJsonTest(ServersSampleBase):
sample_dir = None
extension_name = '.'.join(('nova.api.openstack.compute.contrib',
'hide_server_addresses',
'Hide_server_addresses'))
def setUp(self):
# We override osapi_hide_server_address_states in order
# to have an example of in the json samples of the
# addresses being hidden
CONF.set_override("osapi_hide_server_address_states",
[vm_states.ACTIVE])
super(ServersSampleHideAddressesJsonTest, self).setUp()
def test_servers_post(self):
return self._post_server()
@ -231,25 +242,6 @@ class ServersSampleJsonTest(ServersSampleBase):
self._verify_response('servers-details-resp', subs, response, 200)
class ServersSampleAllExtensionJsonTest(ServersSampleJsonTest):
all_extensions = True
class ServersSampleHideAddressesJsonTest(ServersSampleJsonTest):
sample_dir = None
extension_name = '.'.join(('nova.api.openstack.compute.contrib',
'hide_server_addresses',
'Hide_server_addresses'))
def setUp(self):
# We override osapi_hide_server_address_states in order
# to have an example of in the json samples of the
# addresses being hidden
CONF.set_override("osapi_hide_server_address_states",
[vm_states.ACTIVE])
super(ServersSampleHideAddressesJsonTest, self).setUp()
class ServersSampleMultiStatusJsonTest(ServersSampleBase):
extension_name = '.'.join(('nova.api.openstack.compute.contrib',
'server_list_multi_status',
@ -468,78 +460,6 @@ class ServersActionsJsonTest(ServersSampleBase):
self._test_server_action(uuid, "changePassword",
{"password": "foo"})
def test_server_reboot_hard(self):
uuid = self._post_server()
self._test_server_action(uuid, "reboot",
{"type": "HARD"})
def test_server_reboot_soft(self):
uuid = self._post_server()
self._test_server_action(uuid, "reboot",
{"type": "SOFT"})
def test_server_rebuild(self):
uuid = self._post_server()
image = self.api.get_images()[0]['id']
subs = {'host': self._get_host(),
'uuid': image,
'name': 'foobar',
'pass': 'seekr3t',
'ip': '1.2.3.4',
'ip6': 'fe80::100',
'hostid': '[a-f0-9]+',
}
self._test_server_action(uuid, 'rebuild', subs,
'server-action-rebuild-resp')
def test_server_resize(self):
self.flags(allow_resize_to_same_host=True)
uuid = self._post_server()
self._test_server_action(uuid, "resize",
{"id": 2,
"host": self._get_host()})
return uuid
def test_server_revert_resize(self):
uuid = self.test_server_resize()
self._test_server_action(uuid, "revertResize")
def test_server_confirm_resize(self):
uuid = self.test_server_resize()
self._test_server_action(uuid, "confirmResize", code=204)
def test_server_create_image(self):
uuid = self._post_server()
self._test_server_action(uuid, 'createImage',
{'name': 'foo-image',
'meta_var': 'myvar',
'meta_val': 'foobar'})
class ServersActionsAllJsonTest(ServersActionsJsonTest):
all_extensions = True
class ServerStartStopJsonTest(ServersSampleBase):
extension_name = "nova.api.openstack.compute.contrib" + \
".server_start_stop.Server_start_stop"
def _test_server_action(self, uuid, action):
response = self._do_post('servers/%s/action' % uuid,
'server_start_stop',
{'action': action})
self.assertEqual(response.status_code, 202)
self.assertEqual(response.content, "")
def test_server_start(self):
uuid = self._post_server()
self._test_server_action(uuid, 'os-stop')
self._test_server_action(uuid, 'os-start')
def test_server_stop(self):
uuid = self._post_server()
self._test_server_action(uuid, 'os-stop')
class UserDataJsonTest(ApiSampleTestBaseV2):
extension_name = "nova.api.openstack.compute.contrib.user_data.User_data"
@ -3149,15 +3069,3 @@ class ServerGroupQuotas_QuotasSampleJsonTests(QuotasSampleJsonTests):
extension_name = ("nova.api.openstack.compute.contrib."
"server_group_quotas.Server_group_quotas")
extends_name = "nova.api.openstack.compute.contrib.quotas.Quotas"
class ServerSortKeysJsonTests(ServersSampleBase):
extension_name = ("nova.api.openstack.compute.contrib.server_sort_keys"
".Server_sort_keys")
def test_servers_list(self):
self._post_server()
response = self._do_get('servers?sort_key=display_name&sort_dir=asc')
subs = self._get_regexes()
self._verify_response('server-sort-keys-list-resp', subs, response,
200)

View File

@ -44,9 +44,9 @@ class ApiSampleTestBaseV3(testscenarios.WithScenarios,
raise testtools.TestCase.skipException('tests are not merged yet')
self.flags(use_ipv6=False,
osapi_compute_link_prefix=self._get_host(),
osapi_glance_link_prefix=self._get_glance_host(),
osapi_compute_extension=[])
osapi_glance_link_prefix=self._get_glance_host())
if not self.all_extensions:
self.flags(osapi_compute_extension=[])
# Set the whitelist to ensure only the extensions we are
# interested in are loaded so the api samples don't include
# data from extensions we are not interested in

View File

@ -2,7 +2,7 @@
"createImage" : {
"name" : "%(name)s",
"metadata": {
"%(meta_var)s": "%(meta_val)s"
"meta_var": "meta_val"
}
}
}

View File

@ -1,7 +1,8 @@
{
"server": {
"accessIPv4": "%(ip)s",
"accessIPv6": "%(ip6)s",
"OS-DCF:diskConfig": "AUTO",
"accessIPv4": "%(access_ip_v4)s",
"accessIPv6": "%(access_ip_v6)s",
"addresses": {
"private": [
{

View File

@ -3,8 +3,8 @@
"imageRef" : "%(host)s/v2/32278/images/%(uuid)s",
"name" : "%(name)s",
"adminPass" : "%(pass)s",
"accessIPv4" : "%(ip)s",
"accessIPv6" : "%(ip6)s",
"accessIPv4" : "%(access_ip_v4)s",
"accessIPv6" : "%(access_ip_v6)s",
"metadata" : {
"meta var" : "meta val"
},

View File

@ -17,7 +17,7 @@
"id": "1",
"links": [
{
"href": "%(host)s/flavors/1",
"href": "%(host)s/openstack/flavors/1",
"rel": "bookmark"
}
]
@ -28,7 +28,7 @@
"id": "%(uuid)s",
"links": [
{
"href": "%(host)s/images/%(uuid)s",
"href": "%(host)s/openstack/images/%(uuid)s",
"rel": "bookmark"
}
]
@ -36,11 +36,11 @@
"key_name": null,
"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"
}
],

View File

@ -5,11 +5,11 @@
"id": "%(id)s",
"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"
}
],

View File

@ -18,7 +18,7 @@
"id": "1",
"links": [
{
"href": "%(host)s/flavors/1",
"href": "%(host)s/openstack/flavors/1",
"rel": "bookmark"
}
]
@ -29,7 +29,7 @@
"id": "%(uuid)s",
"links": [
{
"href": "%(host)s/images/%(uuid)s",
"href": "%(host)s/openstack/images/%(uuid)s",
"rel": "bookmark"
}
]
@ -37,11 +37,11 @@
"key_name": null,
"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"
}
],

View File

@ -4,11 +4,11 @@
"id": "%(uuid)s",
"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"
}
],

View File

@ -4,11 +4,11 @@
"id": "%(id)s",
"links": [
{
"href": "%(host)s/v3/servers/%(id)s",
"href": "%(host)s/v2/openstack/servers/%(id)s",
"rel": "self"
},
{
"href": "%(host)s/servers/%(id)s",
"href": "%(host)s/openstack/servers/%(id)s",
"rel": "bookmark"
}
],

View File

@ -1,5 +1,7 @@
{
"server": {
"accessIPv4": "%(access_ip_v4)s",
"accessIPv6": "%(access_ip_v6)s",
"addresses": {
"private": [
{
@ -14,7 +16,7 @@
"id": "1",
"links": [
{
"href": "%(host)s/flavors/1",
"href": "%(host)s/openstack/flavors/1",
"rel": "bookmark"
}
]
@ -25,18 +27,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"
}
],

View File

@ -1,16 +1,12 @@
{
"rebuild" : {
"accessIPv4" : "%(access_ip_v4)s",
"accessIPv6" : "%(access_ip_v6)s",
"imageRef" : "%(glance_host)s/images/%(uuid)s",
"name" : "%(name)s",
"adminPass" : "%(pass)s",
"metadata" : {
"meta_var" : "meta_val"
},
"personality" : [
{
"path" : "/etc/banner.txt",
"contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 b25zLiINCg0KLVJpY2hhcmQgQmFjaA=="
}
]
}
}
}

View File

@ -1,5 +1,7 @@
{
"server": {
"accessIPv4": "%(access_ip_v4)s",
"accessIPv6": "%(access_ip_v6)s",
"addresses": {
"private": [
{
@ -15,7 +17,7 @@
"id": "1",
"links": [
{
"href": "%(host)s/flavors/1",
"href": "%(host)s/openstack/flavors/1",
"rel": "bookmark"
}
]
@ -26,7 +28,7 @@
"id": "%(uuid)s",
"links": [
{
"href": "%(host)s/images/%(uuid)s",
"href": "%(host)s/openstack/images/%(uuid)s",
"rel": "bookmark"
}
]
@ -34,11 +36,11 @@
"key_name": null,
"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"
}
],

View File

@ -1,5 +1,7 @@
{
"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",

View File

@ -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"
}
]

View File

@ -1,6 +1,8 @@
{
"servers": [
{
"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,7 +29,7 @@
"id": "%(uuid)s",
"links": [
{
"href": "%(host)s/images/%(uuid)s",
"href": "%(host)s/openstack/images/%(uuid)s",
"rel": "bookmark"
}
]
@ -35,11 +37,11 @@
"key_name": null,
"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"
}
],

View File

@ -4,11 +4,11 @@
"id": "%(id)s",
"links": [
{
"href": "%(host)s/v3/servers/%(id)s",
"href": "%(host)s/v2/openstack/servers/%(id)s",
"rel": "self"
},
{
"href": "%(host)s/servers/%(id)s",
"href": "%(host)s/openstack/servers/%(id)s",
"rel": "bookmark"
}
],

View File

@ -0,0 +1,10 @@
{
"server" : {
"name" : "new-server-test",
"imageRef" : "%(glance_host)s/images/%(image_id)s",
"flavorRef" : "%(host)s/flavors/1",
"metadata" : {
"My Server Name" : "Apache1"
}
}
}

View File

@ -0,0 +1,16 @@
{
"server": {
"adminPass": "%(password)s",
"id": "%(id)s",
"links": [
{
"href": "http://openstack.example.com/v3/servers/%(uuid)s",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/%(uuid)s",
"rel": "bookmark"
}
]
}
}

View File

@ -29,6 +29,8 @@ class ServersSampleHideAddressesJsonTest(test_servers.ServersSampleJsonTest):
# test_servers.ServersSampleJsonTest does and so it won't default
# to the extension name
sample_dir = extension_name
extra_extensions_to_load = []
_api_version = 'v3'
def setUp(self):
# We override osapi_hide_server_address_states in order

View File

@ -13,11 +13,18 @@
# 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
from nova.tests.unit.image import fake
CONF = cfg.CONF
CONF.import_opt('osapi_compute_extension',
'nova.api.openstack.compute.extensions')
class ServersSampleBase(api_sample_base.ApiSampleTestBaseV3):
def _post_server(self, use_common_server_api_samples=True):
# param use_common_server_api_samples: Boolean to set whether tests use
# common sample files for server post request and response.
@ -28,12 +35,23 @@ class ServersSampleBase(api_sample_base.ApiSampleTestBaseV3):
subs = {
'image_id': fake.get_valid_image_id(),
'host': self._get_host(),
'glance_host': self._get_glance_host()
'glance_host': self._get_glance_host(),
'access_ip_v4': '1.2.3.4',
'access_ip_v6': '80fe::'
}
orig_value = self.__class__._use_common_server_api_samples
orig_sample_dir = self.__class__.sample_dir
try:
self.__class__._use_common_server_api_samples = (
use_common_server_api_samples)
# TODO(gmann) This is temporary hack to let other tests
# inherited from ServersSampleBase run successfully.
# Once all inherited tests are merged, below if condition
# code needs to be removed.
if ((self._api_version == 'v3') and
use_common_server_api_samples):
self.__class__._use_common_server_api_samples = False
self.__class__.sample_dir = 'servers_v21'
response = self._do_post('servers', 'server-post-req', subs)
subs = self._get_regexes()
status = self._verify_response('server-post-resp', subs,
@ -41,10 +59,25 @@ class ServersSampleBase(api_sample_base.ApiSampleTestBaseV3):
return status
finally:
self.__class__._use_common_server_api_samples = orig_value
self.__class__.sample_dir = orig_sample_dir
class ServersSampleJsonTest(ServersSampleBase):
sample_dir = 'servers'
extra_extensions_to_load = ["os-access-ips"]
_api_version = 'v2'
def _get_flags(self):
f = super(ServersSampleBase, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
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 test_servers_post(self):
return self._post_server()
@ -57,6 +90,8 @@ class ServersSampleJsonTest(ServersSampleBase):
subs['id'] = uuid
subs['hypervisor_hostname'] = r'[\w\.\-]+'
subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}'
subs['access_ip_v4'] = '1.2.3.4'
subs['access_ip_v6'] = '80fe::'
self._verify_response('server-get-resp', subs, response, 200)
def test_servers_list(self):
@ -74,11 +109,23 @@ class ServersSampleJsonTest(ServersSampleBase):
subs['id'] = uuid
subs['hypervisor_hostname'] = r'[\w\.\-]+'
subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}'
subs['access_ip_v4'] = '1.2.3.4'
subs['access_ip_v6'] = '80fe::'
self._verify_response('servers-details-resp', subs, response, 200)
class ServerSortKeysJsonTests(ServersSampleBase):
sample_dir = 'servers-sort'
extra_extensions_to_load = ["os-access-ips"]
_api_version = 'v2'
def _get_flags(self):
f = super(ServerSortKeysJsonTests, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.server_sort_keys.'
'Server_sort_keys')
return f
def test_servers_list(self):
self._post_server()
@ -94,6 +141,8 @@ class ServersSampleAllExtensionJsonTest(ServersSampleJsonTest):
class ServersActionsJsonTest(ServersSampleBase):
sample_dir = 'servers'
extra_extensions_to_load = ["os-access-ips"]
_api_version = 'v2'
def _test_server_action(self, uuid, action, req_tpl,
subs=None, resp_tpl=None, code=202):
@ -130,6 +179,8 @@ class ServersActionsJsonTest(ServersSampleBase):
'name': 'foobar',
'pass': 'seekr3t',
'hostid': '[a-f0-9]+',
'access_ip_v4': '1.2.3.4',
'access_ip_v6': '80fe::',
}
self._test_server_action(uuid, 'rebuild',
'server-action-rebuild',
@ -163,8 +214,22 @@ class ServersActionsJsonTest(ServersSampleBase):
{'name': 'foo-image'})
class ServersActionsAllJsonTest(ServersActionsJsonTest):
all_extensions = True
class ServerStartStopJsonTest(ServersSampleBase):
sample_dir = 'servers'
extra_extensions_to_load = ["os-access-ips"]
_api_version = 'v2'
def _get_flags(self):
f = super(ServerStartStopJsonTest, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.server_start_stop.'
'Server_start_stop')
return f
def _test_server_action(self, uuid, action, req_tpl):
response = self._do_post('servers/%s/action' % uuid,