Skip to content

Commit

Permalink
Modified sample tests to FlavorExtraData API.
Browse files Browse the repository at this point in the history
Added subs wherever applicable.
Added checks for correct return codes after REST ops
Modified sample tests to FlavorManage API to differentiate them
from the ones in FlavorExtraData.

Partially implements blueprint nova-api-samples
Fixes bug 1070162

Change-Id: I57c6611f379bef2ff586551b5501c4f7654e4374
  • Loading branch information
Giampaolo Lauria committed Dec 11, 2012
1 parent fcedc02 commit 2d85cb2
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 75 deletions.
12 changes: 6 additions & 6 deletions doc/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-req.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"flavor": {
"OS-FLV-EXT-DATA:ephemeral": 30,
"disk": 10,
"id": "666",
"name": "flavortest",
"ram": 1024,
"vcpus": 2,
"disk": 10,
"id": "666",
"rxtx_factor": 2.0,
"swap": 5,
"vcpus": 2
"OS-FLV-EXT-DATA:ephemeral": 30,
"swap": 5
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?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="testflavor1"
name="flavortest"
ram="1024"
vcpus="2"
disk="10"
id="666"
swap="5"
rxtx_factor="2.0"
OS-FLV-EXT-DATA:ephemeral="30" />
OS-FLV-EXT-DATA:ephemeral="30" />
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<flavor xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" disk="10" vcpus="2" ram="1024" name="testflavor1" id="666" OS-FLV-EXT-DATA:ephemeral="30">
<flavor xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" 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="666" OS-FLV-EXT-DATA:ephemeral="30">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/666" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/666" rel="bookmark"/>
</flavor>
4 changes: 0 additions & 4 deletions doc/api_samples/os-flavor-manage/flavor-create-post-req.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,5 @@
"vcpus": 2,
"disk": 10,
"id": "10",
"os-flavor-access:is_public": true,
"rxtx_factor": 1,
"OS-FLV-EXT-DATA:ephemeral": 0,
"swap": 0
}
}
2 changes: 0 additions & 2 deletions doc/api_samples/os-flavor-manage/flavor-create-post-req.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@
<vcpus>2</vcpus>
<disk>10</disk>
<id>10</id>
<rxtx_factor>1</rxtx_factor>
<swap>0</swap>
</flavor>
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
"flavor": {
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 0,
"id": "1",
"id": "%(flavor_id)s",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/1",
"href": "%(host)s/v2/openstack/flavors/%(flavor_id)s",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/1",
"href": "%(host)s/openstack/flavors/%(flavor_id)s",
"rel": "bookmark"
}
],
"name": "m1.tiny",
"name": "%(flavor_name)s",
"ram": 512,
"vcpus": 1
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<flavor xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" 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" OS-FLV-EXT-DATA:ephemeral="0">
<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 xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" 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" OS-FLV-EXT-DATA:ephemeral="0">
<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>
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"id": "1",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/1",
"href": "%(host)s/v2/openstack/flavors/1",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/1",
"href": "%(host)s/openstack/flavors/1",
"rel": "bookmark"
}
],
Expand All @@ -24,11 +24,11 @@
"id": "2",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/2",
"href": "%(host)s/v2/openstack/flavors/2",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/2",
"href": "%(host)s/openstack/flavors/2",
"rel": "bookmark"
}
],
Expand All @@ -42,11 +42,11 @@
"id": "3",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/3",
"href": "%(host)s/v2/openstack/flavors/3",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/3",
"href": "%(host)s/openstack/flavors/3",
"rel": "bookmark"
}
],
Expand All @@ -60,11 +60,11 @@
"id": "4",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/4",
"href": "%(host)s/v2/openstack/flavors/4",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/4",
"href": "%(host)s/openstack/flavors/4",
"rel": "bookmark"
}
],
Expand All @@ -78,11 +78,11 @@
"id": "5",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/5",
"href": "%(host)s/v2/openstack/flavors/5",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/5",
"href": "%(host)s/openstack/flavors/5",
"rel": "bookmark"
}
],
Expand All @@ -91,4 +91,4 @@
"vcpus": 8
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<?xml version='1.0' encoding='UTF-8'?>
<flavors xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" 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" OS-FLV-EXT-DATA:ephemeral="0">
<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"/>
<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" OS-FLV-EXT-DATA:ephemeral="0">
<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"/>
<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" OS-FLV-EXT-DATA:ephemeral="0">
<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"/>
<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" OS-FLV-EXT-DATA:ephemeral="0">
<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"/>
<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" OS-FLV-EXT-DATA:ephemeral="0">
<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"/>
<atom:link href="%(host)s/v2/openstack/flavors/5" rel="self"/>
<atom:link href="%(host)s/openstack/flavors/5" rel="bookmark"/>
</flavor>
</flavors>
</flavors>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"flavor": {
"OS-FLV-EXT-DATA:ephemeral": 30,
"disk": 10,
"id": "666",
"name": "flavortest",
"name": "%(flavor_name)s",
"ram": 1024,
"vcpus": 2,
"disk": 10,
"id": "%(flavor_id)s",
"rxtx_factor": 2.0,
"swap": 5,
"vcpus": 2
"OS-FLV-EXT-DATA:ephemeral": 30,
"swap": 5
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?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="testflavor1"
name="%(flavor_name)s"
ram="1024"
vcpus="2"
disk="10"
id="666"
id="%(flavor_id)s"
swap="5"
rxtx_factor="2.0"
OS-FLV-EXT-DATA:ephemeral="30" />
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
"flavor": {
"OS-FLV-EXT-DATA:ephemeral": 30,
"disk": 10,
"id": "666",
"id": "%(flavor_id)s",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/666",
"href": "%(host)s/v2/openstack/flavors/%(flavor_id)s",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/666",
"href": "%(host)s/openstack/flavors/%(flavor_id)s",
"rel": "bookmark"
}
],
"name": "flavortest",
"name": "%(flavor_name)s",
"ram": 1024,
"vcpus": 2
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<flavor xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" disk="10" vcpus="2" ram="1024" name="testflavor1" id="666" OS-FLV-EXT-DATA:ephemeral="30">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/666" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/666" rel="bookmark"/>
</flavor>
<flavor xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" 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" OS-FLV-EXT-DATA:ephemeral="30">
<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>
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"ram": 1024,
"vcpus": 2,
"disk": 10,
"id": "%(flavor_id)s",
"os-flavor-access:is_public": true,
"rxtx_factor": 1,
"OS-FLV-EXT-DATA:ephemeral": 0,
"swap": 0
"id": "%(flavor_id)s"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@
<vcpus>2</vcpus>
<disk>10</disk>
<id>%(flavor_id)s</id>
<rxtx_factor>1</rxtx_factor>
<swap>0</swap>
</flavor>
21 changes: 16 additions & 5 deletions nova/tests/integrated/test_api_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,23 +774,34 @@ def _get_flags(self):
return f

def test_flavors_extra_data_get(self):
response = self._do_get('flavors/1')
subs = self._get_regexes()
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('flavors-extra-data-get-resp', subs,
response)

def test_flavors_extra_data_list(self):
response = self._do_get('flavors/detail')
self.assertEqual(response.status, 200)
subs = self._get_regexes()
return self._verify_response('flavors-extra-data-list-resp', subs,
response)

def test_flavors_extra_data_post(self):
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)
self.assertEqual(response.status, 200)
subs = self._get_regexes()
subs.update(self._get_regexes())
return self._verify_response('flavors-extra-data-post-resp',
subs, response)

Expand Down

0 comments on commit 2d85cb2

Please sign in to comment.