Merge "Added sample tests to FlavorSwap API."

This commit is contained in:
Jenkins 2013-01-12 09:54:30 +00:00 committed by Gerrit Code Review
commit 92f390672a
17 changed files with 421 additions and 1 deletions

View 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
}
}

View 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>

View 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
}
]
}

View 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>

View File

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

View 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" />

View 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
}
}

View 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>

View File

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

View 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="%(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>

View File

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

View 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="%(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>

View File

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

View 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="%(flavor_name)s"
ram="1024"
vcpus="2"
disk="10"
id="%(flavor_id)s"
swap="5" />

View File

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

View 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="%(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>

View File

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