diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-10-10 21:08:54 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-10-10 21:08:54 +0000 |
| commit | 93d2a2cdbc86e541ee50e295a602639e7e572817 (patch) | |
| tree | d6276693b41152b2426244ecded03d201ddbec11 /nova | |
| parent | 3ace5b1cfb586ecbfd5f3dbe86f25d9064dd6bcd (diff) | |
| parent | 3f77dec937275e124e1e9b9d555f0864a9932876 (diff) | |
Merge "Add Multiple Create extension to API sample tests."
Diffstat (limited to 'nova')
9 files changed, 154 insertions, 0 deletions
diff --git a/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-req.json.tpl b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-req.json.tpl new file mode 100644 index 000000000..a7690d7b6 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-req.json.tpl @@ -0,0 +1,18 @@ +{ + "server" : { + "name" : "new-server-test", + "imageRef" : "%(host)s/openstack/images/%(image_id)s", + "flavorRef" : "%(host)s/openstack/flavors/1", + "metadata" : { + "My Server Name" : "Apache1" + }, + "min_count": "%(min_count)s", + "max_count": "%(max_count)s", + "personality" : [ + { + "path" : "/etc/banner.txt", + "contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==" + } + ] + } +} diff --git a/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-req.xml.tpl new file mode 100644 index 000000000..1548974da --- /dev/null +++ b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-req.xml.tpl @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<server xmlns="http://docs.openstack.org/compute/api/v1.1" + imageRef="%(host)s/openstack/images/%(image_id)s" + flavorRef="%(host)s/openstack/flavors/1" + name="new-server-test" + min_count="%(min_count)s" + max_count="%(max_count)s"> + <metadata> + <meta key="My Server Name">Apache1</meta> + </metadata> + <personality> + <file path="/etc/banner.txt"> + ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp + dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k + IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs + c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g + QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo + ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv + dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy + c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 + b25zLiINCg0KLVJpY2hhcmQgQmFjaA== + </file> + </personality> +</server> diff --git a/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-resp.json.tpl new file mode 100644 index 000000000..d5f030c87 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-resp.json.tpl @@ -0,0 +1,16 @@ +{ + "server": { + "adminPass": "%(password)s", + "id": "%(id)s", + "links": [ + { + "href": "%(host)s/v2/openstack/servers/%(uuid)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/servers/%(uuid)s", + "rel": "bookmark" + } + ] + } +} diff --git a/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-resp.xml.tpl new file mode 100644 index 000000000..2ad5c102b --- /dev/null +++ b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-resp.xml.tpl @@ -0,0 +1,8 @@ +<?xml version='1.0' encoding='UTF-8'?> +<server xmlns:atom="http://www.w3.org/2005/Atom" + xmlns="http://docs.openstack.org/compute/api/v1.1" + id="%(id)s" adminPass="%(password)s"> + <metadata/> + <atom:link href="%(host)s/v2/openstack/servers/%(uuid)s" rel="self"/> + <atom:link href="%(host)s/openstack/servers/%(uuid)s" rel="bookmark"/> +</server> diff --git a/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-req.json.tpl b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-req.json.tpl new file mode 100644 index 000000000..9984c0588 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-req.json.tpl @@ -0,0 +1,19 @@ +{ + "server" : { + "name" : "new-server-test", + "imageRef" : "%(host)s/openstack/images/%(image_id)s", + "flavorRef" : "%(host)s/openstack/flavors/1", + "metadata" : { + "My Server Name" : "Apache1" + }, + "return_reservation_id": "True", + "min_count": "%(min_count)s", + "max_count": "%(max_count)s", + "personality" : [ + { + "path" : "/etc/banner.txt", + "contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==" + } + ] + } +} diff --git a/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-req.xml.tpl new file mode 100644 index 000000000..7ac9b23d6 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-req.xml.tpl @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<server xmlns="http://docs.openstack.org/compute/api/v1.1" + imageRef="%(host)s/openstack/images/%(image_id)s" + flavorRef="%(host)s/openstack/flavors/1" + name="new-server-test" + min_count="%(min_count)s" + max_count="%(max_count)s" + return_reservation_id="True"> + <metadata> + <meta key="My Server Name">Apache1</meta> + </metadata> + <personality> + <file path="/etc/banner.txt"> + ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp + dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k + IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs + c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g + QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo + ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv + dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy + c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 + b25zLiINCg0KLVJpY2hhcmQgQmFjaA== + </file> + </personality> +</server> diff --git a/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-resp.json.tpl new file mode 100644 index 000000000..22d2880fe --- /dev/null +++ b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-resp.json.tpl @@ -0,0 +1,3 @@ +{ + "reservation_id": "%(reservation_id)s" +} diff --git a/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-resp.xml.tpl new file mode 100644 index 000000000..a361612b2 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-resp.xml.tpl @@ -0,0 +1,4 @@ +<?xml version='1.0' encoding='UTF-8'?> +<server xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" reservation_id="%(reservation_id)s"> + <metadata/> +</server> diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index e61a3c0b8..95294cdbc 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -224,6 +224,7 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase): '-[0-9a-f]{4}-[0-9a-f]{12})', 'uuid': '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}' '-[0-9a-f]{4}-[0-9a-f]{12}', + 'reservation_id': 'r-[0-9a-zA-Z]{8}', 'private_key': '-----BEGIN RSA PRIVATE KEY-----' '[a-zA-Z0-9\n/+=]*' '-----END RSA PRIVATE KEY-----', @@ -1169,3 +1170,39 @@ class CertificatesSamplesJsonTest(ApiSampleTestBase): class CertificatesSamplesXmlTest(CertificatesSamplesJsonTest): ctype = "xml" + + +class MultipleCreateJsonTest(ServersSampleBase): + extension_name = ("nova.api.openstack.compute.contrib.multiple_create." + "Multiple_create") + + def test_multiple_create(self): + subs = { + 'image_id': fake.get_valid_image_id(), + 'host': self._get_host(), + 'min_count': "2", + 'max_count': "3" + } + response = self._do_post('servers', 'multiple-create-post-req', subs) + self.assertEqual(response.status, 202) + subs.update(self._get_regexes()) + return self._verify_response('multiple-create-post-resp', + subs, response) + + def test_multiple_create_without_reservation_id(self): + subs = { + 'image_id': fake.get_valid_image_id(), + 'host': self._get_host(), + 'min_count': "2", + 'max_count': "3" + } + response = self._do_post('servers', 'multiple-create-no-resv-post-req', + subs) + self.assertEqual(response.status, 202) + subs.update(self._get_regexes()) + return self._verify_response('multiple-create-no-resv-post-resp', + subs, response) + + +class MultipleCreateXmlTest(MultipleCreateJsonTest): + ctype = 'xml' |
