Added sample tests to FlavorSwap API.
Partially implements blueprint nova-api-samples Fixes bug 1096653 Change-Id: I9a6ca8a023bf0f3404b3a9af635dd29a7a584aa3
This commit is contained in:
parent
664ea40ebb
commit
35328ddd8f
20
doc/api_samples/os-flavor-swap/flavor-swap-get-resp.json
Normal file
20
doc/api_samples/os-flavor-swap/flavor-swap-get-resp.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"flavor": {
|
||||
"disk": 0,
|
||||
"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
|
||||
}
|
||||
}
|
5
doc/api_samples/os-flavor-swap/flavor-swap-get-resp.xml
Normal file
5
doc/api_samples/os-flavor-swap/flavor-swap-get-resp.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<flavor xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" disk="0" vcpus="1" ram="512" name="m1.tiny" id="1" swap="">
|
||||
<atom:link href="http://openstack.example.com/v2/openstack/flavors/1" rel="self"/>
|
||||
<atom:link href="http://openstack.example.com/openstack/flavors/1" rel="bookmark"/>
|
||||
</flavor>
|
94
doc/api_samples/os-flavor-swap/flavor-swap-list-resp.json
Normal file
94
doc/api_samples/os-flavor-swap/flavor-swap-list-resp.json
Normal file
@ -0,0 +1,94 @@
|
||||
{
|
||||
"flavors": [
|
||||
{
|
||||
"disk": 0,
|
||||
"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
|
||||
}
|
||||
]
|
||||
}
|
23
doc/api_samples/os-flavor-swap/flavor-swap-list-resp.xml
Normal file
23
doc/api_samples/os-flavor-swap/flavor-swap-list-resp.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<flavors xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1">
|
||||
<flavor disk="0" vcpus="1" ram="512" name="m1.tiny" id="1" swap="">
|
||||
<atom:link href="http://openstack.example.com/v2/openstack/flavors/1" rel="self"/>
|
||||
<atom:link href="http://openstack.example.com/openstack/flavors/1" rel="bookmark"/>
|
||||
</flavor>
|
||||
<flavor disk="20" vcpus="1" ram="2048" name="m1.small" id="2" swap="">
|
||||
<atom:link href="http://openstack.example.com/v2/openstack/flavors/2" rel="self"/>
|
||||
<atom:link href="http://openstack.example.com/openstack/flavors/2" rel="bookmark"/>
|
||||
</flavor>
|
||||
<flavor disk="40" vcpus="2" ram="4096" name="m1.medium" id="3" swap="">
|
||||
<atom:link href="http://openstack.example.com/v2/openstack/flavors/3" rel="self"/>
|
||||
<atom:link href="http://openstack.example.com/openstack/flavors/3" rel="bookmark"/>
|
||||
</flavor>
|
||||
<flavor disk="80" vcpus="4" ram="8192" name="m1.large" id="4" swap="">
|
||||
<atom:link href="http://openstack.example.com/v2/openstack/flavors/4" rel="self"/>
|
||||
<atom:link href="http://openstack.example.com/openstack/flavors/4" rel="bookmark"/>
|
||||
</flavor>
|
||||
<flavor disk="160" vcpus="8" ram="16384" name="m1.xlarge" id="5" swap="">
|
||||
<atom:link href="http://openstack.example.com/v2/openstack/flavors/5" rel="self"/>
|
||||
<atom:link href="http://openstack.example.com/openstack/flavors/5" rel="bookmark"/>
|
||||
</flavor>
|
||||
</flavors>
|
10
doc/api_samples/os-flavor-swap/flavor-swap-post-req.json
Normal file
10
doc/api_samples/os-flavor-swap/flavor-swap-post-req.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"flavor": {
|
||||
"name": "flavortest",
|
||||
"ram": 1024,
|
||||
"vcpus": 2,
|
||||
"disk": 10,
|
||||
"id": "100",
|
||||
"swap": 5
|
||||
}
|
||||
}
|
9
doc/api_samples/os-flavor-swap/flavor-swap-post-req.xml
Normal file
9
doc/api_samples/os-flavor-swap/flavor-swap-post-req.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flavor xmlns="http://docs.openstack.org/compute/api/v1.1"
|
||||
xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1"
|
||||
name="flavortest"
|
||||
ram="1024"
|
||||
vcpus="2"
|
||||
disk="10"
|
||||
id="100"
|
||||
swap="5" />
|
20
doc/api_samples/os-flavor-swap/flavor-swap-post-resp.json
Normal file
20
doc/api_samples/os-flavor-swap/flavor-swap-post-resp.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
}
|
5
doc/api_samples/os-flavor-swap/flavor-swap-post-resp.xml
Normal file
5
doc/api_samples/os-flavor-swap/flavor-swap-post-resp.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<flavor xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" disk="10" vcpus="2" ram="1024" name="flavortest" id="100" swap="5">
|
||||
<atom:link href="http://openstack.example.com/v2/openstack/flavors/100" rel="self"/>
|
||||
<atom:link href="http://openstack.example.com/openstack/flavors/100" rel="bookmark"/>
|
||||
</flavor>
|
@ -0,0 +1,20 @@
|
||||
{
|
||||
"flavor": {
|
||||
"disk": 0,
|
||||
"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
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<flavor xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" disk="0" vcpus="1" ram="512" name="%(flavor_name)s" id="%(flavor_id)s" swap="">
|
||||
<atom:link href="%(host)s/v2/openstack/flavors/%(flavor_id)s" rel="self"/>
|
||||
<atom:link href="%(host)s/openstack/flavors/%(flavor_id)s" rel="bookmark"/>
|
||||
</flavor>
|
@ -0,0 +1,94 @@
|
||||
{
|
||||
"flavors": [
|
||||
{
|
||||
"disk": 0,
|
||||
"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
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<flavors xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1">
|
||||
<flavor disk="0" vcpus="1" ram="512" name="m1.tiny" id="1" swap="">
|
||||
<atom:link href="%(host)s/v2/openstack/flavors/1" rel="self"/>
|
||||
<atom:link href="%(host)s/openstack/flavors/1" rel="bookmark"/>
|
||||
</flavor>
|
||||
<flavor disk="20" vcpus="1" ram="2048" name="m1.small" id="2" swap="">
|
||||
<atom:link href="%(host)s/v2/openstack/flavors/2" rel="self"/>
|
||||
<atom:link href="%(host)s/openstack/flavors/2" rel="bookmark"/>
|
||||
</flavor>
|
||||
<flavor disk="40" vcpus="2" ram="4096" name="m1.medium" id="3" swap="">
|
||||
<atom:link href="%(host)s/v2/openstack/flavors/3" rel="self"/>
|
||||
<atom:link href="%(host)s/openstack/flavors/3" rel="bookmark"/>
|
||||
</flavor>
|
||||
<flavor disk="80" vcpus="4" ram="8192" name="m1.large" id="4" swap="">
|
||||
<atom:link href="%(host)s/v2/openstack/flavors/4" rel="self"/>
|
||||
<atom:link href="%(host)s/openstack/flavors/4" rel="bookmark"/>
|
||||
</flavor>
|
||||
<flavor disk="160" vcpus="8" ram="16384" name="m1.xlarge" id="5" swap="">
|
||||
<atom:link href="%(host)s/v2/openstack/flavors/5" rel="self"/>
|
||||
<atom:link href="%(host)s/openstack/flavors/5" rel="bookmark"/>
|
||||
</flavor>
|
||||
</flavors>
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"flavor": {
|
||||
"name": "%(flavor_name)s",
|
||||
"ram": 1024,
|
||||
"vcpus": 2,
|
||||
"disk": 10,
|
||||
"id": "%(flavor_id)s",
|
||||
"swap": 5
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flavor xmlns="http://docs.openstack.org/compute/api/v1.1"
|
||||
xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1"
|
||||
name="%(flavor_name)s"
|
||||
ram="1024"
|
||||
vcpus="2"
|
||||
disk="10"
|
||||
id="%(flavor_id)s"
|
||||
swap="5" />
|
@ -0,0 +1,20 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<flavor xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" disk="10" vcpus="2" ram="1024" name="%(flavor_name)s" id="%(flavor_id)s" swap="5">
|
||||
<atom:link href="%(host)s/v2/openstack/flavors/%(flavor_id)s" rel="self"/>
|
||||
<atom:link href="%(host)s/openstack/flavors/%(flavor_id)s" rel="bookmark"/>
|
||||
</flavor>
|
@ -367,7 +367,6 @@ class ApiSamplesTrap(ApiSampleTestBase):
|
||||
do_not_approve_additions.append('os-create-server-ext')
|
||||
do_not_approve_additions.append('os-flavor-access')
|
||||
do_not_approve_additions.append('os-flavor-extra-specs')
|
||||
do_not_approve_additions.append('os-flavor-swap')
|
||||
do_not_approve_additions.append('os-floating-ip-dns')
|
||||
do_not_approve_additions.append('os-floating-ip-pools')
|
||||
do_not_approve_additions.append('os-fping')
|
||||
@ -1030,6 +1029,55 @@ class FlavorRxtxXmlTest(FlavorRxtxJsonTest):
|
||||
ctype = 'xml'
|
||||
|
||||
|
||||
class FlavorSwapJsonTest(ApiSampleTestBase):
|
||||
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)
|
||||
self.assertEqual(response.status, 200)
|
||||
subs = {
|
||||
'flavor_id': flavor_id,
|
||||
'flavor_name': 'm1.tiny'
|
||||
}
|
||||
subs.update(self._get_regexes())
|
||||
return self._verify_response('flavor-swap-get-resp', subs,
|
||||
response)
|
||||
|
||||
def test_flavor_swap_list(self):
|
||||
response = self._do_get('flavors/detail')
|
||||
self.assertEqual(response.status, 200)
|
||||
subs = self._get_regexes()
|
||||
return self._verify_response('flavor-swap-list-resp', subs,
|
||||
response)
|
||||
|
||||
def test_flavor_swap_create(self):
|
||||
subs = {
|
||||
'flavor_id': 100,
|
||||
'flavor_name': 'flavortest'
|
||||
}
|
||||
response = self._do_post('flavors',
|
||||
'flavor-swap-post-req',
|
||||
subs)
|
||||
self.assertEqual(response.status, 200)
|
||||
subs.update(self._get_regexes())
|
||||
return self._verify_response('flavor-swap-post-resp',
|
||||
subs, response)
|
||||
|
||||
|
||||
class FlavorSwapXmlTest(FlavorSwapJsonTest):
|
||||
ctype = 'xml'
|
||||
|
||||
|
||||
class SecurityGroupsSampleJsonTest(ServersSampleBase):
|
||||
extension_name = "nova.api.openstack.compute.contrib" + \
|
||||
".security_groups.Security_groups"
|
||||
|
Loading…
x
Reference in New Issue
Block a user