From 3f77dec937275e124e1e9b9d555f0864a9932876 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Wed, 3 Oct 2012 10:25:55 -0400 Subject: Add Multiple Create extension to API sample tests. Change-Id: Ifa5cf31cc61e4269502ff692508866948670e46f Signed-off-by: Matthew Treinish --- .../multiple-create-no-resv-post-req.json.tpl | 18 +++++++++++ .../multiple-create-no-resv-post-req.xml.tpl | 24 ++++++++++++++ .../multiple-create-no-resv-post-resp.json.tpl | 16 ++++++++++ .../multiple-create-no-resv-post-resp.xml.tpl | 8 +++++ .../multiple-create-post-req.json.tpl | 19 +++++++++++ .../multiple-create-post-req.xml.tpl | 25 +++++++++++++++ .../multiple-create-post-resp.json.tpl | 3 ++ .../multiple-create-post-resp.xml.tpl | 4 +++ nova/tests/integrated/test_api_samples.py | 37 ++++++++++++++++++++++ 9 files changed, 154 insertions(+) create mode 100644 nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-req.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-req.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-resp.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-req.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-req.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-resp.xml.tpl (limited to 'nova') 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 @@ + + + + Apache1 + + + + ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp + dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k + IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs + c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g + QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo + ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv + dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy + c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 + b25zLiINCg0KLVJpY2hhcmQgQmFjaA== + + + 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 @@ + + + + + + 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 @@ + + + + Apache1 + + + + ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp + dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k + IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs + c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g + QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo + ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv + dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy + c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 + b25zLiINCg0KLVJpY2hhcmQgQmFjaA== + + + 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 @@ + + + + diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index 9aca460cf..bc1dcda86 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-----', @@ -1171,3 +1172,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' -- cgit