Merge flavor_rxtx 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 flavor_rxtx functional tests.

Change-Id: I82b183f95cd5a8e9981d2969b96204f11ab48c8f
This commit is contained in:
parklong 2015-04-07 10:07:05 +08:00
parent bf70df295b
commit 2ca2236b83
16 changed files with 62 additions and 356 deletions

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,
"rxtx_factor": 1.0,
"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,
"rxtx_factor": 1.0,
"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,
"rxtx_factor": 1.0,
"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,
"rxtx_factor": 1.0,
"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,
"rxtx_factor": 1.0,
"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,
"rxtx_factor": 1.0,
"vcpus": 8
}
]
}

View File

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

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,
"rxtx_factor": 2.0,
"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"
}
],
@ -30,11 +30,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"
}
],
@ -52,11 +52,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"
}
],
@ -74,11 +74,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"
}
],
@ -96,11 +96,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

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

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,
"rxtx_factor": 1.0,
"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,
"rxtx_factor": 1.0,
"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,
"rxtx_factor": 1.0,
"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,
"rxtx_factor": 1.0,
"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,
"rxtx_factor": 1.0,
"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,
"rxtx_factor": 1.0,
"vcpus": 8
}
]
}

View File

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

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,
"rxtx_factor": 2.0,
"vcpus": 2
}
}

View File

@ -558,46 +558,6 @@ class UserDataJsonTest(ApiSampleTestBaseV2):
self._verify_response('userdata-post-resp', subs, response, 202)
class FlavorRxtxJsonTest(ApiSampleTestBaseV2):
ADMIN_API = True
extension_name = ('nova.api.openstack.compute.contrib.flavor_rxtx.'
'Flavor_rxtx')
def _get_flags(self):
f = super(FlavorRxtxJsonTest, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
# FlavorRxtx extension also needs Flavormanage to be loaded.
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.flavormanage.Flavormanage')
return f
def test_flavor_rxtx_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-rxtx-get-resp', subs, response, 200)
def test_flavors_rxtx_list(self):
response = self._do_get('flavors/detail')
subs = self._get_regexes()
self._verify_response('flavor-rxtx-list-resp', subs, response, 200)
def test_flavors_rxtx_create(self):
subs = {
'flavor_id': 100,
'flavor_name': 'flavortest'
}
response = self._do_post('flavors',
'flavor-rxtx-post-req',
subs)
subs.update(self._get_regexes())
self._verify_response('flavor-rxtx-post-resp', subs, response, 200)
class SecurityGroupsSampleJsonTest(ServersSampleBase):
extension_name = "nova.api.openstack.compute.contrib" + \
".security_groups.Security_groups"

View File

@ -6,11 +6,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

@ -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"
}
],
@ -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"
}
],
@ -51,11 +51,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"
}
],
@ -73,11 +73,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"
}
],
@ -95,11 +95,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": "%(flavor_id)s",
"links": [
{
"href": "%(host)s/v3/flavors/%(flavor_id)s",
"href": "%(host)s/v2/openstack/flavors/%(flavor_id)s",
"rel": "self"
},
{
"href": "%(host)s/flavors/%(flavor_id)s",
"href": "%(host)s/openstack/flavors/%(flavor_id)s",
"rel": "bookmark"
}
],

View File

@ -13,11 +13,45 @@
# 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 FlavorRxtxJsonTest(api_sample_base.ApiSampleTestBaseV3):
ADMIN_API = True
extension_name = 'os-flavor-rxtx'
# 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(FlavorRxtxJsonTest, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.flavor_rxtx.'
'Flavor_rxtx')
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.flavormanage.'
'Flavormanage')
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')
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.flavor_swap.'
'Flavor_swap')
return f
def test_flavor_rxtx_get(self):
flavor_id = 1