Merge V2 and V2.1 functional tests

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 use the testscenearios to generate the tests one for v2 and one for v2.1
and make v2.1 tests to run against v2.1 plugins by redirecting /v2 endpoint to v2.1
plugins in api-paste.ini

As example this commit merge flavor APIs functional tests between v2 & v2.1.
In V2 flavor API has following extensions
- Flavor_swap
- Flavor_disabled
- Flavorextradata
In V2.1 above extensions have been merged together in flavor plugins

NOTE- As testscenarios is applied in base class. v2 tests will be generated
for all the existing tests but for tests which are not merged yet
their v2 generated tests will be skipped till they gets
merged. After merge, both version tests are expected to pass like
flavor tests in this patch. So you may see lot of skipped tests
which is expected and will gets disappear as tests gets merged.

Change-Id: I0e0262f818c7d7fb15528b16d3225b9578910996
This commit is contained in:
ghanshyam 2015-03-23 17:27:55 +09:00
parent 905c2d2373
commit e24c2239fb
30 changed files with 136 additions and 957 deletions

View File

@ -1,94 +0,0 @@
{
"flavors": [
{
"OS-FLV-DISABLED:disabled": false,
"disk": 1,
"id": "1",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/1",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
],
"name": "m1.tiny",
"ram": 512,
"vcpus": 1
},
{
"OS-FLV-DISABLED:disabled": false,
"disk": 20,
"id": "2",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/2",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/2",
"rel": "bookmark"
}
],
"name": "m1.small",
"ram": 2048,
"vcpus": 1
},
{
"OS-FLV-DISABLED:disabled": false,
"disk": 40,
"id": "3",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/3",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/3",
"rel": "bookmark"
}
],
"name": "m1.medium",
"ram": 4096,
"vcpus": 2
},
{
"OS-FLV-DISABLED:disabled": false,
"disk": 80,
"id": "4",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/4",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/4",
"rel": "bookmark"
}
],
"name": "m1.large",
"ram": 8192,
"vcpus": 4
},
{
"OS-FLV-DISABLED:disabled": false,
"disk": 160,
"id": "5",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/5",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/5",
"rel": "bookmark"
}
],
"name": "m1.xlarge",
"ram": 16384,
"vcpus": 8
}
]
}

View File

@ -1,20 +0,0 @@
{
"flavor": {
"OS-FLV-DISABLED:disabled": false,
"disk": 1,
"id": "1",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/1",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
],
"name": "m1.tiny",
"ram": 512,
"vcpus": 1
}
}

View File

@ -1,20 +0,0 @@
{
"flavor": {
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 1,
"id": "1",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/1",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
],
"name": "m1.tiny",
"ram": 512,
"vcpus": 1
}
}

View File

@ -1,94 +0,0 @@
{
"flavors": [
{
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 1,
"id": "1",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/1",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
],
"name": "m1.tiny",
"ram": 512,
"vcpus": 1
},
{
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 20,
"id": "2",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/2",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/2",
"rel": "bookmark"
}
],
"name": "m1.small",
"ram": 2048,
"vcpus": 1
},
{
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 40,
"id": "3",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/3",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/3",
"rel": "bookmark"
}
],
"name": "m1.medium",
"ram": 4096,
"vcpus": 2
},
{
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 80,
"id": "4",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/4",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/4",
"rel": "bookmark"
}
],
"name": "m1.large",
"ram": 8192,
"vcpus": 4
},
{
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 160,
"id": "5",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/5",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/5",
"rel": "bookmark"
}
],
"name": "m1.xlarge",
"ram": 16384,
"vcpus": 8
}
]
}

View File

@ -1,12 +0,0 @@
{
"flavor": {
"name": "flavortest",
"ram": 1024,
"vcpus": 2,
"disk": 10,
"id": "666",
"rxtx_factor": 2.0,
"OS-FLV-EXT-DATA:ephemeral": 30,
"swap": 5
}
}

View File

@ -1,20 +0,0 @@
{
"flavor": {
"OS-FLV-EXT-DATA:ephemeral": 30,
"disk": 10,
"id": "666",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/666",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/666",
"rel": "bookmark"
}
],
"name": "flavortest",
"ram": 1024,
"vcpus": 2
}
}

View File

@ -1,20 +0,0 @@
{
"flavor": {
"disk": 1,
"id": "1",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/1",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
],
"name": "m1.tiny",
"ram": 512,
"swap": "",
"vcpus": 1
}
}

View File

@ -1,94 +0,0 @@
{
"flavors": [
{
"disk": 1,
"id": "1",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/1",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
],
"name": "m1.tiny",
"ram": 512,
"swap": "",
"vcpus": 1
},
{
"disk": 20,
"id": "2",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/2",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/2",
"rel": "bookmark"
}
],
"name": "m1.small",
"ram": 2048,
"swap": "",
"vcpus": 1
},
{
"disk": 40,
"id": "3",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/3",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/3",
"rel": "bookmark"
}
],
"name": "m1.medium",
"ram": 4096,
"swap": "",
"vcpus": 2
},
{
"disk": 80,
"id": "4",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/4",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/4",
"rel": "bookmark"
}
],
"name": "m1.large",
"ram": 8192,
"swap": "",
"vcpus": 4
},
{
"disk": 160,
"id": "5",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/5",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/5",
"rel": "bookmark"
}
],
"name": "m1.xlarge",
"ram": 16384,
"swap": "",
"vcpus": 8
}
]
}

View File

@ -1,10 +0,0 @@
{
"flavor": {
"name": "flavortest",
"ram": 1024,
"vcpus": 2,
"disk": 10,
"id": "100",
"swap": 5
}
}

View File

@ -1,20 +0,0 @@
{
"flavor": {
"disk": 10,
"id": "100",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/100",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/100",
"rel": "bookmark"
}
],
"name": "flavortest",
"ram": 1024,
"swap": 5,
"vcpus": 2
}
}

View File

@ -7,11 +7,11 @@
"id": "1",
"links": [
{
"href": "http://openstack.example.com/v3/flavors/1",
"href": "http://openstack.example.com/v2/openstack/flavors/1",
"rel": "self"
},
{
"href": "http://openstack.example.com/flavors/1",
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
],

View File

@ -8,11 +8,11 @@
"id": "1",
"links": [
{
"href": "http://openstack.example.com/v3/flavors/1",
"href": "http://openstack.example.com/v2/openstack/flavors/1",
"rel": "self"
},
{
"href": "http://openstack.example.com/flavors/1",
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
],
@ -29,11 +29,11 @@
"id": "2",
"links": [
{
"href": "http://openstack.example.com/v3/flavors/2",
"href": "http://openstack.example.com/v2/openstack/flavors/2",
"rel": "self"
},
{
"href": "http://openstack.example.com/flavors/2",
"href": "http://openstack.example.com/openstack/flavors/2",
"rel": "bookmark"
}
],
@ -50,11 +50,11 @@
"id": "3",
"links": [
{
"href": "http://openstack.example.com/v3/flavors/3",
"href": "http://openstack.example.com/v2/openstack/flavors/3",
"rel": "self"
},
{
"href": "http://openstack.example.com/flavors/3",
"href": "http://openstack.example.com/openstack/flavors/3",
"rel": "bookmark"
}
],
@ -71,11 +71,11 @@
"id": "4",
"links": [
{
"href": "http://openstack.example.com/v3/flavors/4",
"href": "http://openstack.example.com/v2/openstack/flavors/4",
"rel": "self"
},
{
"href": "http://openstack.example.com/flavors/4",
"href": "http://openstack.example.com/openstack/flavors/4",
"rel": "bookmark"
}
],
@ -92,11 +92,11 @@
"id": "5",
"links": [
{
"href": "http://openstack.example.com/v3/flavors/5",
"href": "http://openstack.example.com/v2/openstack/flavors/5",
"rel": "self"
},
{
"href": "http://openstack.example.com/flavors/5",
"href": "http://openstack.example.com/openstack/flavors/5",
"rel": "bookmark"
}
],

View File

@ -4,11 +4,11 @@
"id": "1",
"links": [
{
"href": "http://openstack.example.com/v3/flavors/1",
"href": "http://openstack.example.com/v2/openstack/flavors/1",
"rel": "self"
},
{
"href": "http://openstack.example.com/flavors/1",
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
],
@ -18,11 +18,11 @@
"id": "2",
"links": [
{
"href": "http://openstack.example.com/v3/flavors/2",
"href": "http://openstack.example.com/v2/openstack/flavors/2",
"rel": "self"
},
{
"href": "http://openstack.example.com/flavors/2",
"href": "http://openstack.example.com/openstack/flavors/2",
"rel": "bookmark"
}
],
@ -32,11 +32,11 @@
"id": "3",
"links": [
{
"href": "http://openstack.example.com/v3/flavors/3",
"href": "http://openstack.example.com/v2/openstack/flavors/3",
"rel": "self"
},
{
"href": "http://openstack.example.com/flavors/3",
"href": "http://openstack.example.com/openstack/flavors/3",
"rel": "bookmark"
}
],
@ -46,11 +46,11 @@
"id": "4",
"links": [
{
"href": "http://openstack.example.com/v3/flavors/4",
"href": "http://openstack.example.com/v2/openstack/flavors/4",
"rel": "self"
},
{
"href": "http://openstack.example.com/flavors/4",
"href": "http://openstack.example.com/openstack/flavors/4",
"rel": "bookmark"
}
],
@ -60,11 +60,11 @@
"id": "5",
"links": [
{
"href": "http://openstack.example.com/v3/flavors/5",
"href": "http://openstack.example.com/v2/openstack/flavors/5",
"rel": "self"
},
{
"href": "http://openstack.example.com/flavors/5",
"href": "http://openstack.example.com/openstack/flavors/5",
"rel": "bookmark"
}
],

View File

@ -1,94 +0,0 @@
{
"flavors": [
{
"OS-FLV-DISABLED:disabled": false,
"disk": 1,
"id": "1",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/1",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/1",
"rel": "bookmark"
}
],
"name": "m1.tiny",
"ram": 512,
"vcpus": 1
},
{
"OS-FLV-DISABLED:disabled": false,
"disk": 20,
"id": "2",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/2",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/2",
"rel": "bookmark"
}
],
"name": "m1.small",
"ram": 2048,
"vcpus": 1
},
{
"OS-FLV-DISABLED:disabled": false,
"disk": 40,
"id": "3",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/3",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/3",
"rel": "bookmark"
}
],
"name": "m1.medium",
"ram": 4096,
"vcpus": 2
},
{
"OS-FLV-DISABLED:disabled": false,
"disk": 80,
"id": "4",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/4",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/4",
"rel": "bookmark"
}
],
"name": "m1.large",
"ram": 8192,
"vcpus": 4
},
{
"OS-FLV-DISABLED:disabled": false,
"disk": 160,
"id": "5",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/5",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/5",
"rel": "bookmark"
}
],
"name": "m1.xlarge",
"ram": 16384,
"vcpus": 8
}
]
}

View File

@ -1,20 +0,0 @@
{
"flavor": {
"OS-FLV-DISABLED:disabled": false,
"disk": 1,
"id": "%(flavor_id)s",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/%(flavor_id)s",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/%(flavor_id)s",
"rel": "bookmark"
}
],
"name": "m1.tiny",
"ram": 512,
"vcpus": 1
}
}

View File

@ -1,20 +0,0 @@
{
"flavor": {
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 1,
"id": "%(flavor_id)s",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/%(flavor_id)s",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/%(flavor_id)s",
"rel": "bookmark"
}
],
"name": "%(flavor_name)s",
"ram": 512,
"vcpus": 1
}
}

View File

@ -1,94 +0,0 @@
{
"flavors": [
{
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 1,
"id": "1",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/1",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/1",
"rel": "bookmark"
}
],
"name": "m1.tiny",
"ram": 512,
"vcpus": 1
},
{
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 20,
"id": "2",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/2",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/2",
"rel": "bookmark"
}
],
"name": "m1.small",
"ram": 2048,
"vcpus": 1
},
{
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 40,
"id": "3",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/3",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/3",
"rel": "bookmark"
}
],
"name": "m1.medium",
"ram": 4096,
"vcpus": 2
},
{
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 80,
"id": "4",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/4",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/4",
"rel": "bookmark"
}
],
"name": "m1.large",
"ram": 8192,
"vcpus": 4
},
{
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 160,
"id": "5",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/5",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/5",
"rel": "bookmark"
}
],
"name": "m1.xlarge",
"ram": 16384,
"vcpus": 8
}
]
}

View File

@ -1,12 +0,0 @@
{
"flavor": {
"name": "%(flavor_name)s",
"ram": 1024,
"vcpus": 2,
"disk": 10,
"id": "%(flavor_id)s",
"rxtx_factor": 2.0,
"OS-FLV-EXT-DATA:ephemeral": 30,
"swap": 5
}
}

View File

@ -1,20 +0,0 @@
{
"flavor": {
"OS-FLV-EXT-DATA:ephemeral": 30,
"disk": 10,
"id": "%(flavor_id)s",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/%(flavor_id)s",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/%(flavor_id)s",
"rel": "bookmark"
}
],
"name": "%(flavor_name)s",
"ram": 1024,
"vcpus": 2
}
}

View File

@ -1,20 +0,0 @@
{
"flavor": {
"disk": 1,
"id": "%(flavor_id)s",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/%(flavor_id)s",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/%(flavor_id)s",
"rel": "bookmark"
}
],
"name": "%(flavor_name)s",
"ram": 512,
"swap": "",
"vcpus": 1
}
}

View File

@ -1,94 +0,0 @@
{
"flavors": [
{
"disk": 1,
"id": "1",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/1",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/1",
"rel": "bookmark"
}
],
"name": "m1.tiny",
"ram": 512,
"swap": "",
"vcpus": 1
},
{
"disk": 20,
"id": "2",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/2",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/2",
"rel": "bookmark"
}
],
"name": "m1.small",
"ram": 2048,
"swap": "",
"vcpus": 1
},
{
"disk": 40,
"id": "3",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/3",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/3",
"rel": "bookmark"
}
],
"name": "m1.medium",
"ram": 4096,
"swap": "",
"vcpus": 2
},
{
"disk": 80,
"id": "4",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/4",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/4",
"rel": "bookmark"
}
],
"name": "m1.large",
"ram": 8192,
"swap": "",
"vcpus": 4
},
{
"disk": 160,
"id": "5",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/5",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/5",
"rel": "bookmark"
}
],
"name": "m1.xlarge",
"ram": 16384,
"swap": "",
"vcpus": 8
}
]
}

View File

@ -1,10 +0,0 @@
{
"flavor": {
"name": "%(flavor_name)s",
"ram": 1024,
"vcpus": 2,
"disk": 10,
"id": "%(flavor_id)s",
"swap": 5
}
}

View File

@ -1,20 +0,0 @@
{
"flavor": {
"disk": 10,
"id": "%(flavor_id)s",
"links": [
{
"href": "%(host)s/v2/openstack/flavors/%(flavor_id)s",
"rel": "self"
},
{
"href": "%(host)s/openstack/flavors/%(flavor_id)s",
"rel": "bookmark"
}
],
"name": "%(flavor_name)s",
"ram": 1024,
"swap": 5,
"vcpus": 2
}
}

View File

@ -28,6 +28,7 @@ from oslo_log import log as logging
from oslo_serialization import jsonutils
from oslo_utils import importutils
from oslo_utils import timeutils
import testtools
from nova.api.metadata import password
from nova.api.openstack.compute.contrib import fping
@ -137,6 +138,14 @@ class ApiSamplesTrap(ApiSampleTestBaseV2):
# in the tree but that don't (yet) have tests. This list should
# NOT be allowed to grow, and should shrink to zero (and be
# removed) soon.
# TODO(gmann): skip this tests as merging of sample tests for v2
# and v2.1 are in progress. After merging all tests, this tests
# need to implement in different way.
raise testtools.TestCase.skipException('Merging of v2 and v2.1 '
'sample tests is in progress. '
'This test will be enabled '
'after all tests gets merged.')
do_not_approve_additions = []
do_not_approve_additions.append('os-create-server-ext')
do_not_approve_additions.append('os-baremetal-ext-status')
@ -591,49 +600,6 @@ class UserDataJsonTest(ApiSampleTestBaseV2):
self._verify_response('userdata-post-resp', subs, response, 202)
class FlavorsExtraDataJsonTest(ApiSampleTestBaseV2):
ADMIN_API = True
extension_name = ('nova.api.openstack.compute.contrib.flavorextradata.'
'Flavorextradata')
def _get_flags(self):
f = super(FlavorsExtraDataJsonTest, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
# Flavorextradata extension also needs Flavormanage to be loaded.
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.flavormanage.Flavormanage')
return f
def test_flavors_extra_data_get(self):
flavor_id = 1
response = self._do_get('flavors/%s' % flavor_id)
subs = {
'flavor_id': flavor_id,
'flavor_name': 'm1.tiny'
}
subs.update(self._get_regexes())
self._verify_response('flavors-extra-data-get-resp',
subs, response, 200)
def test_flavors_extra_data_list(self):
response = self._do_get('flavors/detail')
subs = self._get_regexes()
self._verify_response('flavors-extra-data-list-resp',
subs, response, 200)
def test_flavors_extra_data_create(self):
subs = {
'flavor_id': 666,
'flavor_name': 'flavortest'
}
response = self._do_post('flavors',
'flavors-extra-data-post-req',
subs)
subs.update(self._get_regexes())
self._verify_response('flavors-extra-data-post-resp',
subs, response, 200)
class FlavorRxtxJsonTest(ApiSampleTestBaseV2):
ADMIN_API = True
extension_name = ('nova.api.openstack.compute.contrib.flavor_rxtx.'
@ -674,46 +640,6 @@ class FlavorRxtxJsonTest(ApiSampleTestBaseV2):
self._verify_response('flavor-rxtx-post-resp', subs, response, 200)
class FlavorSwapJsonTest(ApiSampleTestBaseV2):
ADMIN_API = True
extension_name = ('nova.api.openstack.compute.contrib.flavor_swap.'
'Flavor_swap')
def _get_flags(self):
f = super(FlavorSwapJsonTest, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
# FlavorSwap extension also needs Flavormanage to be loaded.
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.flavormanage.Flavormanage')
return f
def test_flavor_swap_get(self):
flavor_id = 1
response = self._do_get('flavors/%s' % flavor_id)
subs = {
'flavor_id': flavor_id,
'flavor_name': 'm1.tiny'
}
subs.update(self._get_regexes())
self._verify_response('flavor-swap-get-resp', subs, response, 200)
def test_flavor_swap_list(self):
response = self._do_get('flavors/detail')
subs = self._get_regexes()
self._verify_response('flavor-swap-list-resp', subs, response, 200)
def test_flavor_swap_create(self):
subs = {
'flavor_id': 100,
'flavor_name': 'flavortest'
}
response = self._do_post('flavors',
'flavor-swap-post-req',
subs)
subs.update(self._get_regexes())
self._verify_response('flavor-swap-post-resp', subs, response, 200)
class SecurityGroupsSampleJsonTest(ServersSampleBase):
extension_name = "nova.api.openstack.compute.contrib" + \
".security_groups.Security_groups"
@ -2563,25 +2489,6 @@ class NetworksAssociateJsonTests(ApiSampleTestBaseV2):
self.assertEqual(response.content, "")
class FlavorDisabledSampleJsonTests(ApiSampleTestBaseV2):
extension_name = ("nova.api.openstack.compute.contrib.flavor_disabled."
"Flavor_disabled")
def test_show_flavor(self):
# Get api sample to show flavor_disabled attr. of a flavor.
flavor_id = 1
response = self._do_get('flavors/%s' % flavor_id)
subs = self._get_regexes()
subs['flavor_id'] = flavor_id
self._verify_response('flavor-show-get-resp', subs, response, 200)
def test_detail_flavor(self):
# Get api sample to show details of a flavor.
response = self._do_get('flavors/detail')
subs = self._get_regexes()
self._verify_response('flavor-detail-get-resp', subs, response, 200)
class QuotaClassesSampleJsonTests(ApiSampleTestBaseV2):
ADMIN_API = True
extension_name = ("nova.api.openstack.compute.contrib.quota_classes."

View File

@ -0,0 +1,41 @@
# Copyright 2015 NEC Corporation. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
import fixtures
from oslo_config import cfg
from nova import paths
CONF = cfg.CONF
class ApiPasteFixture(fixtures.Fixture):
def setUp(self):
super(ApiPasteFixture, self).setUp()
CONF.set_default('api_paste_config',
paths.state_path_def('etc/nova/api-paste.ini'))
tmp_api_paste_dir = self.useFixture(fixtures.TempDir())
tmp_api_paste_file_name = os.path.join(tmp_api_paste_dir.path,
'fake_api_paste.ini')
with open(CONF.api_paste_config, 'r') as orig_api_paste:
with open(tmp_api_paste_file_name, 'w') as tmp_file:
for line in orig_api_paste:
tmp_file.write(line.replace(
"/v2: openstack_compute_api_v2",
"/v2: openstack_compute_api_v21"))
CONF.set_override('api_paste_config', tmp_api_paste_file_name)

View File

@ -15,25 +15,37 @@
import os
from oslo_config import cfg
import testscenarios
import testtools
from nova.api.openstack import API_V3_CORE_EXTENSIONS # noqa
from nova import test
from nova.tests.functional import api_samples_test_base
from nova.tests.functional.v3 import api_paste_fixture
from nova.tests.unit import fake_network
from nova.tests.unit import fake_utils
CONF = cfg.CONF
class ApiSampleTestBaseV3(api_samples_test_base.ApiSampleTestBase):
class ApiSampleTestBaseV3(testscenarios.WithScenarios,
api_samples_test_base.ApiSampleTestBase):
_api_version = 'v3'
sample_dir = None
extra_extensions_to_load = None
scenarios = [('v2', {'_test': 'v2'}),
('v2_1', {'_test': 'v2.1'})]
def setUp(self):
# TODO(gmann): Below condition is to skip the tests which running
# for 'v2' and have not been merged yet. Once all tests are merged
# this condition needs to be removed.
if ((self._test == 'v2') and (self._api_version == 'v3')):
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_glance_link_prefix=self._get_glance_host(),
osapi_compute_extension=[])
if not self.all_extensions:
# Set the whitelist to ensure only the extensions we are
# interested in are loaded so the api samples don't include
@ -46,7 +58,11 @@ class ApiSampleTestBaseV3(api_samples_test_base.ApiSampleTestBase):
CONF.set_override('extensions_whitelist', whitelist,
'osapi_v3')
# TODO(gmann): Currently redirecting only merged tests
# after merging all tests, second condition needs to be removed.
if ((self._test == 'v2.1') and (self._api_version == 'v2')):
# NOTE(gmann)For v2.1 API testing, override /v2 endpoint with v2.1
self.useFixture(api_paste_fixture.ApiPasteFixture())
super(ApiSampleTestBaseV3, self).setUp()
self.useFixture(test.SampleNetworks(host=self.network.host))
fake_network.stub_compute_with_ips(self.stubs)

View File

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

View File

@ -7,11 +7,11 @@
"id": "1",
"links": [
{
"href": "%(host)s/v3/flavors/1",
"href": "%(host)s/v2/openstack/flavors/1",
"rel": "self"
},
{
"href": "%(host)s/flavors/1",
"href": "%(host)s/openstack/flavors/1",
"rel": "bookmark"
}
],
@ -28,11 +28,11 @@
"id": "2",
"links": [
{
"href": "%(host)s/v3/flavors/2",
"href": "%(host)s/v2/openstack/flavors/2",
"rel": "self"
},
{
"href": "%(host)s/flavors/2",
"href": "%(host)s/openstack/flavors/2",
"rel": "bookmark"
}
],
@ -49,11 +49,11 @@
"id": "3",
"links": [
{
"href": "%(host)s/v3/flavors/3",
"href": "%(host)s/v2/openstack/flavors/3",
"rel": "self"
},
{
"href": "%(host)s/flavors/3",
"href": "%(host)s/openstack/flavors/3",
"rel": "bookmark"
}
],
@ -70,11 +70,11 @@
"id": "4",
"links": [
{
"href": "%(host)s/v3/flavors/4",
"href": "%(host)s/v2/openstack/flavors/4",
"rel": "self"
},
{
"href": "%(host)s/flavors/4",
"href": "%(host)s/openstack/flavors/4",
"rel": "bookmark"
}
],
@ -91,11 +91,11 @@
"id": "5",
"links": [
{
"href": "%(host)s/v3/flavors/5",
"href": "%(host)s/v2/openstack/flavors/5",
"rel": "self"
},
{
"href": "%(host)s/flavors/5",
"href": "%(host)s/openstack/flavors/5",
"rel": "bookmark"
}
],

View File

@ -4,11 +4,11 @@
"id": "1",
"links": [
{
"href": "%(host)s/v3/flavors/1",
"href": "%(host)s/v2/openstack/flavors/1",
"rel": "self"
},
{
"href": "%(host)s/flavors/1",
"href": "%(host)s/openstack/flavors/1",
"rel": "bookmark"
}
],
@ -18,11 +18,11 @@
"id": "2",
"links": [
{
"href": "%(host)s/v3/flavors/2",
"href": "%(host)s/v2/openstack/flavors/2",
"rel": "self"
},
{
"href": "%(host)s/flavors/2",
"href": "%(host)s/openstack/flavors/2",
"rel": "bookmark"
}
],
@ -32,11 +32,11 @@
"id": "3",
"links": [
{
"href": "%(host)s/v3/flavors/3",
"href": "%(host)s/v2/openstack/flavors/3",
"rel": "self"
},
{
"href": "%(host)s/flavors/3",
"href": "%(host)s/openstack/flavors/3",
"rel": "bookmark"
}
],
@ -46,11 +46,11 @@
"id": "4",
"links": [
{
"href": "%(host)s/v3/flavors/4",
"href": "%(host)s/v2/openstack/flavors/4",
"rel": "self"
},
{
"href": "%(host)s/flavors/4",
"href": "%(host)s/openstack/flavors/4",
"rel": "bookmark"
}
],
@ -60,11 +60,11 @@
"id": "5",
"links": [
{
"href": "%(host)s/v3/flavors/5",
"href": "%(host)s/v2/openstack/flavors/5",
"rel": "self"
},
{
"href": "%(host)s/flavors/5",
"href": "%(host)s/openstack/flavors/5",
"rel": "bookmark"
}
],

View File

@ -13,11 +13,34 @@
# 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
CONF = cfg.CONF
CONF.import_opt('osapi_compute_extension',
'nova.api.openstack.compute.extensions')
class FlavorsSampleJsonTest(api_sample_base.ApiSampleTestBaseV3):
sample_dir = 'flavors'
# 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(FlavorsSampleJsonTest, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.flavor_swap.Flavor_swap')
f['osapi_compute_extension'].append('nova.api.openstack.compute.'
'contrib.flavor_disabled.Flavor_disabled')
f['osapi_compute_extension'].append('nova.api.openstack.compute.'
'contrib.flavor_access.Flavor_access')
f['osapi_compute_extension'].append('nova.api.openstack.compute.'
'contrib.flavorextradata.Flavorextradata')
return f
def test_flavors_get(self):
response = self._do_get('flavors/1')