From 940e1cfd7dc8b382453e03215aeceefbc2afa173 Mon Sep 17 00:00:00 2001 From: "Mauro S. M. Rodrigues" Date: Thu, 13 Sep 2012 02:12:31 -0400 Subject: Add api samples to Scheduler hints extension Change-Id: Ic324d796dac0cfc7b36c47a181b55e09cb1503e2 --- .../scheduler-hints-post-req.json.tpl | 11 +++++++++++ .../scheduler-hints-post-req.xml.tpl | 10 ++++++++++ .../scheduler-hints-post-resp.json.tpl | 16 ++++++++++++++++ .../scheduler-hints-post-resp.xml.tpl | 6 ++++++ nova/tests/integrated/test_api_samples.py | 22 ++++++++++++++++++++++ 5 files changed, 65 insertions(+) create mode 100644 nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-req.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-req.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-resp.xml.tpl (limited to 'nova') diff --git a/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-req.json.tpl b/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-req.json.tpl new file mode 100644 index 000000000..1a19960c2 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-req.json.tpl @@ -0,0 +1,11 @@ +{ + "server": { + "name": "new-server-test", + "imageRef": "%(image_id)s", + "flavorRef": "1" + }, + "os:scheduler_hints": { + "hypervisor": "xen", + "near": "%(image_near)s" + } +} diff --git a/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-req.xml.tpl new file mode 100644 index 000000000..66327c534 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-req.xml.tpl @@ -0,0 +1,10 @@ + + + xen + %(image_near)s + + diff --git a/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-resp.json.tpl new file mode 100644 index 000000000..d5f030c87 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-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-scheduler-hints/scheduler-hints-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-resp.xml.tpl new file mode 100644 index 000000000..5a11c73c3 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-resp.xml.tpl @@ -0,0 +1,6 @@ + + + + + + diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index ae40cc41c..a2ab51b61 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -15,6 +15,7 @@ import os import re +import uuid from lxml import etree @@ -596,3 +597,24 @@ class SecurityGroupsSampleJsonTest(ServersSampleBase): class SecurityGroupsSampleXmlTest(SecurityGroupsSampleJsonTest): ctype = 'xml' + + +class SchedulerHintsJsonTest(ApiSampleTestBase): + extension_name = ("nova.api.openstack.compute.contrib.scheduler_hints." + "Scheduler_hints") + + def test_scheduler_hints_post(self): + """Get api sample of scheduler hint post request""" + hints = {'image_id': fake.get_valid_image_id(), + 'image_near': str(uuid.uuid4()) + } + response = self._do_post('servers', 'scheduler-hints-post-req', + hints) + self.assertEqual(response.status, 202) + subs = self._get_regexes() + return self._verify_response('scheduler-hints-post-resp', subs, + response) + + +class SchedulerHintsXmlTest(SchedulerHintsJsonTest): + ctype = 'xml' -- cgit