From 830816cdef6765c14b2111ccc2932b8e48b3ad04 Mon Sep 17 00:00:00 2001 From: Ken'ichi Ohmichi Date: Fri, 22 Aug 2014 13:40:21 +0000 Subject: [PATCH] Change v3 agents API to v2.1 This patch changes v3 agents API to v2.1 and makes v2 unit tests share between v2 and v2.1. The differences between v2 and v3 are described on the wiki page https://wiki.openstack.org/wiki/NovaAPIv2tov3 . Partially implements blueprint v2-on-v3-api Change-Id: I96dd9cd3672c6d584bd0019c385544c08f687e7f --- .../os-agents/agent-update-put-req.json | 2 +- .../os-agents/agent-update-put-resp.json | 2 +- .../openstack/compute/plugins/v3/agents.py | 24 +- .../openstack/compute/schemas/v3/agents.py | 4 +- .../openstack/compute/contrib/test_agents.py | 55 +-- .../compute/plugins/v3/test_agents.py | 351 ------------------ .../os-agents/agent-update-put-req.json.tpl | 2 +- .../os-agents/agent-update-put-resp.json.tpl | 2 +- nova/tests/integrated/v3/test_agents.py | 4 +- 9 files changed, 59 insertions(+), 387 deletions(-) delete mode 100644 nova/tests/api/openstack/compute/plugins/v3/test_agents.py diff --git a/doc/v3/api_samples/os-agents/agent-update-put-req.json b/doc/v3/api_samples/os-agents/agent-update-put-req.json index 89cbcaba39a3..f7398504d62f 100644 --- a/doc/v3/api_samples/os-agents/agent-update-put-req.json +++ b/doc/v3/api_samples/os-agents/agent-update-put-req.json @@ -1,5 +1,5 @@ { - "agent": { + "para": { "url": "http://example.com/path/to/resource", "md5hash": "add6bb58e139be103324d04d82d8f545", "version": "7.0" diff --git a/doc/v3/api_samples/os-agents/agent-update-put-resp.json b/doc/v3/api_samples/os-agents/agent-update-put-resp.json index 2964c0f8948f..2919d2138818 100644 --- a/doc/v3/api_samples/os-agents/agent-update-put-resp.json +++ b/doc/v3/api_samples/os-agents/agent-update-put-resp.json @@ -1,6 +1,6 @@ { "agent": { - "agent_id": 1, + "agent_id": "1", "md5hash": "add6bb58e139be103324d04d82d8f545", "url": "http://example.com/path/to/resource", "version": "7.0" diff --git a/nova/api/openstack/compute/plugins/v3/agents.py b/nova/api/openstack/compute/plugins/v3/agents.py index 563e49998f1e..e198849c3ddc 100644 --- a/nova/api/openstack/compute/plugins/v3/agents.py +++ b/nova/api/openstack/compute/plugins/v3/agents.py @@ -78,7 +78,12 @@ class AgentController(object): context = req.environ['nova.context'] authorize(context) - para = body['agent'] + # TODO(oomichi): This parameter name "para" is different from the ones + # of the other APIs. Most other names are resource names like "server" + # etc. This name should be changed to "agent" for consistent naming + # with v2.1+microversions. + para = body['para'] + url = para['url'] md5hash = para['md5hash'] version = para['version'] @@ -93,11 +98,19 @@ class AgentController(object): except exception.AgentBuildNotFound as ex: raise webob.exc.HTTPNotFound(explanation=ex.format_message()) - return {"agent": {'agent_id': int(id), 'version': version, + # TODO(alex_xu): The agent_id should be integer that consistent with + # create/index actions. But parameter 'id' is string type that parsed + # from url. This is a bug, but because back-compatibility, it can't be + # fixed for v2 API. This will be fixed after v3 API feature exposed by + # v2.1+microversions in the future. lp bug #1333494 + return {"agent": {'agent_id': id, 'version': version, 'url': url, 'md5hash': md5hash}} + # TODO(oomichi): Here should be 204(No Content) instead of 200 by v2.1 + # +microversions because the resource agent has been deleted completely + # when returning a response. @extensions.expected_errors(404) - @wsgi.response(204) + @wsgi.response(200) def delete(self, req, id): """Deletes an existing agent build.""" context = req.environ['nova.context'] @@ -109,8 +122,11 @@ class AgentController(object): except exception.AgentBuildNotFound as ex: raise webob.exc.HTTPNotFound(explanation=ex.format_message()) + # TODO(oomichi): Here should be 201(Created) instead of 200 by v2.1 + # +microversions because the creation of a resource agent finishes + # when returning a response. @extensions.expected_errors((400, 409)) - @wsgi.response(201) + @wsgi.response(200) @validation.schema(schema.create) def create(self, req, body): """Creates a new agent build.""" diff --git a/nova/api/openstack/compute/schemas/v3/agents.py b/nova/api/openstack/compute/schemas/v3/agents.py index f54392f22f1b..0d30efcf078d 100644 --- a/nova/api/openstack/compute/schemas/v3/agents.py +++ b/nova/api/openstack/compute/schemas/v3/agents.py @@ -56,7 +56,7 @@ create = { update = { 'type': 'object', 'properties': { - 'agent': { + 'para': { 'type': 'object', 'properties': { 'version': { @@ -76,6 +76,6 @@ update = { 'additionalProperties': False, }, }, - 'required': ['agent'], + 'required': ['para'], 'additionalProperties': False, } diff --git a/nova/tests/api/openstack/compute/contrib/test_agents.py b/nova/tests/api/openstack/compute/contrib/test_agents.py index 0a3aae31044b..41e2400b8722 100644 --- a/nova/tests/api/openstack/compute/contrib/test_agents.py +++ b/nova/tests/api/openstack/compute/contrib/test_agents.py @@ -14,7 +14,8 @@ import webob.exc -from nova.api.openstack.compute.contrib import agents +from nova.api.openstack.compute.contrib import agents as agents_v2 +from nova.api.openstack.compute.plugins.v3 import agents as agents_v21 from nova import context from nova import db from nova.db.sqlalchemy import models @@ -84,10 +85,12 @@ class FakeRequestWithHypervisor(object): GET = {'hypervisor': 'kvm'} -class AgentsTest(test.NoDBTestCase): +class AgentsTestV21(test.NoDBTestCase): + controller = agents_v21.AgentController() + validation_error = exception.ValidationError def setUp(self): - super(AgentsTest, self).setUp() + super(AgentsTestV21, self).setUp() self.stubs.Set(db, "agent_build_get_all", fake_agent_build_get_all) @@ -98,7 +101,6 @@ class AgentsTest(test.NoDBTestCase): self.stubs.Set(db, "agent_build_create", fake_agent_build_create) self.context = context.get_admin_context() - self.controller = agents.AgentController() def test_agents_create(self): req = FakeRequest() @@ -115,7 +117,7 @@ class AgentsTest(test.NoDBTestCase): 'url': 'http://example.com/path/to/resource', 'md5hash': 'add6bb58e139be103324d04d82d8f545', 'agent_id': 1}} - res_dict = self.controller.create(req, body) + res_dict = self.controller.create(req, body=body) self.assertEqual(res_dict, response) def _test_agents_create_key_error(self, key): @@ -127,8 +129,8 @@ class AgentsTest(test.NoDBTestCase): 'url': 'xxx://xxxx/xxx/xxx', 'md5hash': 'add6bb58e139be103324d04d82d8f545'}} body['agent'].pop(key) - self.assertRaises(webob.exc.HTTPBadRequest, - self.controller.create, req, body) + self.assertRaises(self.validation_error, + self.controller.create, req, body=body) def test_agents_create_without_hypervisor(self): self._test_agents_create_key_error('hypervisor') @@ -151,14 +153,14 @@ class AgentsTest(test.NoDBTestCase): def test_agents_create_with_wrong_type(self): req = FakeRequest() body = {'agent': None} - self.assertRaises(webob.exc.HTTPBadRequest, - self.controller.create, req, body) + self.assertRaises(self.validation_error, + self.controller.create, req, body=body) def test_agents_create_with_empty_type(self): req = FakeRequest() body = {} - self.assertRaises(webob.exc.HTTPBadRequest, - self.controller.create, req, body) + self.assertRaises(self.validation_error, + self.controller.create, req, body=body) def test_agents_create_with_existed_agent(self): def fake_agent_build_create_with_exited_agent(context, values): @@ -185,8 +187,8 @@ class AgentsTest(test.NoDBTestCase): 'url': 'http://example.com/path/to/resource', 'md5hash': 'add6bb58e139be103324d04d82d8f545'}} body['agent'][key] = 'x' * 256 - self.assertRaises(webob.exc.HTTPBadRequest, - self.controller.create, req, body) + self.assertRaises(self.validation_error, + self.controller.create, req, body=body) def test_agents_create_with_invalid_length_hypervisor(self): self._test_agents_create_with_invalid_length('hypervisor') @@ -267,7 +269,7 @@ class AgentsTest(test.NoDBTestCase): 'version': '7.0', 'url': 'http://example.com/path/to/resource', 'md5hash': 'add6bb58e139be103324d04d82d8f545'}} - res_dict = self.controller.update(req, 1, body) + res_dict = self.controller.update(req, 1, body=body) self.assertEqual(res_dict, response) def _test_agents_update_key_error(self, key): @@ -276,8 +278,8 @@ class AgentsTest(test.NoDBTestCase): 'url': 'xxx://xxxx/xxx/xxx', 'md5hash': 'add6bb58e139be103324d04d82d8f545'}} body['para'].pop(key) - self.assertRaises(webob.exc.HTTPBadRequest, - self.controller.update, req, 1, body) + self.assertRaises(self.validation_error, + self.controller.update, req, 1, body=body) def test_agents_update_without_version(self): self._test_agents_update_key_error('version') @@ -291,22 +293,22 @@ class AgentsTest(test.NoDBTestCase): def test_agents_update_with_wrong_type(self): req = FakeRequest() body = {'agent': None} - self.assertRaises(webob.exc.HTTPBadRequest, - self.controller.update, req, 1, body) + self.assertRaises(self.validation_error, + self.controller.update, req, 1, body=body) def test_agents_update_with_empty(self): req = FakeRequest() body = {} - self.assertRaises(webob.exc.HTTPBadRequest, - self.controller.update, req, 1, body) + self.assertRaises(self.validation_error, + self.controller.update, req, 1, body=body) def test_agents_update_value_error(self): req = FakeRequest() body = {'para': {'version': '7.0', 'url': 1111, 'md5hash': 'add6bb58e139be103324d04d82d8f545'}} - self.assertRaises(webob.exc.HTTPBadRequest, - self.controller.update, req, 1, body) + self.assertRaises(self.validation_error, + self.controller.update, req, 1, body=body) def _test_agents_update_with_invalid_length(self, key): req = FakeRequest() @@ -314,8 +316,8 @@ class AgentsTest(test.NoDBTestCase): 'url': 'http://example.com/path/to/resource', 'md5hash': 'add6bb58e139be103324d04d82d8f545'}} body['para'][key] = 'x' * 256 - self.assertRaises(webob.exc.HTTPBadRequest, - self.controller.update, req, 1, body) + self.assertRaises(self.validation_error, + self.controller.update, req, 1, body=body) def test_agents_update_with_invalid_length_version(self): self._test_agents_update_with_invalid_length('version') @@ -325,3 +327,8 @@ class AgentsTest(test.NoDBTestCase): def test_agents_update_with_invalid_length_md5hash(self): self._test_agents_update_with_invalid_length('md5hash') + + +class AgentsTestV2(AgentsTestV21): + controller = agents_v2.AgentController() + validation_error = webob.exc.HTTPBadRequest diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_agents.py b/nova/tests/api/openstack/compute/plugins/v3/test_agents.py deleted file mode 100644 index a4b140214dc7..000000000000 --- a/nova/tests/api/openstack/compute/plugins/v3/test_agents.py +++ /dev/null @@ -1,351 +0,0 @@ -# Copyright 2012 IBM Corp. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -from webob import exc - -from nova.api.openstack.compute.plugins.v3 import agents -from nova import context -from nova import db -from nova.db.sqlalchemy import models -from nova import exception -from nova import test - -fake_agents_list = [{'hypervisor': 'kvm', 'os': 'win', - 'architecture': 'x86', - 'version': '7.0', - 'url': 'http://example.com/path/to/resource', - 'md5hash': 'add6bb58e139be103324d04d82d8f545', - 'id': 1}, - {'hypervisor': 'kvm', 'os': 'linux', - 'architecture': 'x86', - 'version': '16.0', - 'url': 'http://example.com/path/to/resource1', - 'md5hash': 'add6bb58e139be103324d04d82d8f546', - 'id': 2}, - {'hypervisor': 'xen', 'os': 'linux', - 'architecture': 'x86', - 'version': '16.0', - 'url': 'http://example.com/path/to/resource2', - 'md5hash': 'add6bb58e139be103324d04d82d8f547', - 'id': 3}, - {'hypervisor': 'xen', 'os': 'win', - 'architecture': 'power', - 'version': '7.0', - 'url': 'http://example.com/path/to/resource3', - 'md5hash': 'add6bb58e139be103324d04d82d8f548', - 'id': 4}, - ] - - -def fake_agent_build_get_all(context, hypervisor): - agent_build_all = [] - for agent in fake_agents_list: - if hypervisor and hypervisor != agent['hypervisor']: - continue - agent_build_ref = models.AgentBuild() - agent_build_ref.update(agent) - agent_build_all.append(agent_build_ref) - return agent_build_all - - -def fake_agent_build_update(context, agent_build_id, values): - pass - - -def fake_agent_build_destroy(context, agent_update_id): - pass - - -def fake_agent_build_create(context, values): - values['id'] = 1 - agent_build_ref = models.AgentBuild() - agent_build_ref.update(values) - return agent_build_ref - - -class FakeRequest(object): - environ = {"nova.context": context.get_admin_context()} - GET = {} - - -class FakeRequestWithHypervisor(object): - environ = {"nova.context": context.get_admin_context()} - GET = {'hypervisor': 'kvm'} - - -def fake_agent_build_create_with_exited_agent(context, values): - raise exception.AgentBuildExists(**values) - - -class AgentsTest(test.NoDBTestCase): - - def setUp(self): - super(AgentsTest, self).setUp() - - self.stubs.Set(db, "agent_build_get_all", - fake_agent_build_get_all) - self.stubs.Set(db, "agent_build_update", - fake_agent_build_update) - self.stubs.Set(db, "agent_build_destroy", - fake_agent_build_destroy) - self.stubs.Set(db, "agent_build_create", - fake_agent_build_create) - self.context = context.get_admin_context() - self.controller = agents.AgentController() - - def test_agents_create(self): - req = FakeRequest() - body = {'agent': {'hypervisor': 'kvm', - 'os': 'win', - 'architecture': 'x86', - 'version': '7.0', - 'url': 'http://example.com/path/to/resource', - 'md5hash': 'add6bb58e139be103324d04d82d8f545'}} - response = {'agent': {'hypervisor': 'kvm', - 'os': 'win', - 'architecture': 'x86', - 'version': '7.0', - 'url': 'http://example.com/path/to/resource', - 'md5hash': 'add6bb58e139be103324d04d82d8f545', - 'agent_id': 1}} - res_dict = self.controller.create(req, body=body) - self.assertEqual(res_dict, response) - self.assertEqual(self.controller.create.wsgi_code, 201) - - def test_agents_create_with_existed_agent(self): - self.stubs.Set(db, 'agent_build_create', - fake_agent_build_create_with_exited_agent) - req = FakeRequest() - body = {'agent': {'hypervisor': 'kvm', - 'os': 'win', - 'architecture': 'x86', - 'version': '7.0', - 'url': 'http://example.com/path/to/resource', - 'md5hash': 'add6bb58e139be103324d04d82d8f545'}} - self.assertRaises(exc.HTTPConflict, self.controller.create, req, - body=body) - - def test_agents_create_without_md5hash(self): - req = FakeRequest() - body = {'agent': {'hypervisor': 'kvm', - 'os': 'win', - 'architecture': 'x86', - 'version': '7.0', - 'url': 'http://example.com/path/to/resource'}} - self.assertRaises(exception.ValidationError, self.controller.create, - req, body=body) - - def test_agents_create_without_url(self): - req = FakeRequest() - body = {'agent': {'hypervisor': 'kvm', - 'os': 'win', - 'architecture': 'x86', - 'version': '7.0', - 'md5hash': 'add6bb58e139be103324d04d82d8f545'}} - self.assertRaises(exception.ValidationError, self.controller.create, - req, body=body) - - def test_agents_create_without_version(self): - req = FakeRequest() - body = {'agent': {'hypervisor': 'kvm', - 'os': 'win', - 'architecture': 'x86', - 'url': 'http://example.com/path/to/resource', - 'md5hash': 'add6bb58e139be103324d04d82d8f545'}} - self.assertRaises(exception.ValidationError, self.controller.create, - req, body=body) - - def test_agents_create_without_architecture(self): - req = FakeRequest() - body = {'agent': {'hypervisor': 'kvm', - 'os': 'win', - 'version': '7.0', - 'url': 'http://example.com/path/to/resource', - 'md5hash': 'add6bb58e139be103324d04d82d8f545'}} - self.assertRaises(exception.ValidationError, self.controller.create, - req, body=body) - - def test_agents_create_without_os(self): - req = FakeRequest() - body = {'agent': {'hypervisor': 'kvm', - 'architecture': 'x86', - 'version': '7.0', - 'url': 'http://example.com/path/to/resource', - 'md5hash': 'add6bb58e139be103324d04d82d8f545'}} - self.assertRaises(exception.ValidationError, self.controller.create, - req, body=body) - - def test_agents_create_without_hypervisor(self): - req = FakeRequest() - body = {'agent': {'os': 'win', - 'architecture': 'x86', - 'version': '7.0', - 'url': 'http://example.com/path/to/resource', - 'md5hash': 'add6bb58e139be103324d04d82d8f545'}} - self.assertRaises(exception.ValidationError, self.controller.create, - req, body=body) - - def test_agents_create_with_wrong_type(self): - req = FakeRequest() - body = {'agent': None} - self.assertRaises(exception.ValidationError, self.controller.create, - req, body=body) - - def test_agents_create_with_empty_type(self): - req = FakeRequest() - body = {} - self.assertRaises(exception.ValidationError, self.controller.create, - req, body=body) - - def _test_agents_create_with_invalid_length(self, key): - req = FakeRequest() - body = {'agent': {'hypervisor': 'kvm', - 'os': 'win', - 'architecture': 'x86', - 'version': '7.0', - 'url': 'http://example.com/path/to/resource', - 'md5hash': 'add6bb58e139be103324d04d82d8f545'}} - body['agent'][key] = 'x' * 256 - self.assertRaises(exception.ValidationError, self.controller.create, - req, body=body) - - def test_agents_create_with_invalid_length_hypervisor(self): - self._test_agents_create_with_invalid_length('hypervisor') - - def test_agents_create_with_invalid_length_os(self): - self._test_agents_create_with_invalid_length('os') - - def test_agents_create_with_invalid_length_architecture(self): - self._test_agents_create_with_invalid_length('architecture') - - def test_agents_create_with_invalid_length_version(self): - self._test_agents_create_with_invalid_length('version') - - def test_agents_create_with_invalid_length_url(self): - self._test_agents_create_with_invalid_length('url') - - def test_agents_create_with_invalid_length_md5hash(self): - self._test_agents_create_with_invalid_length('md5hash') - - def test_agents_delete(self): - req = FakeRequest() - self.controller.delete(req, 1) - - def test_agents_list(self): - req = FakeRequest() - res_dict = self.controller.index(req) - agents_list = [{'hypervisor': 'kvm', 'os': 'win', - 'architecture': 'x86', - 'version': '7.0', - 'url': 'http://example.com/path/to/resource', - 'md5hash': 'add6bb58e139be103324d04d82d8f545', - 'agent_id': 1}, - {'hypervisor': 'kvm', 'os': 'linux', - 'architecture': 'x86', - 'version': '16.0', - 'url': 'http://example.com/path/to/resource1', - 'md5hash': 'add6bb58e139be103324d04d82d8f546', - 'agent_id': 2}, - {'hypervisor': 'xen', 'os': 'linux', - 'architecture': 'x86', - 'version': '16.0', - 'url': 'http://example.com/path/to/resource2', - 'md5hash': 'add6bb58e139be103324d04d82d8f547', - 'agent_id': 3}, - {'hypervisor': 'xen', 'os': 'win', - 'architecture': 'power', - 'version': '7.0', - 'url': 'http://example.com/path/to/resource3', - 'md5hash': 'add6bb58e139be103324d04d82d8f548', - 'agent_id': 4}, - ] - self.assertEqual(res_dict, {'agents': agents_list}) - - def test_agents_list_with_hypervisor(self): - req = FakeRequestWithHypervisor() - res_dict = self.controller.index(req) - response = [{'hypervisor': 'kvm', 'os': 'win', - 'architecture': 'x86', - 'version': '7.0', - 'url': 'http://example.com/path/to/resource', - 'md5hash': 'add6bb58e139be103324d04d82d8f545', - 'agent_id': 1}, - {'hypervisor': 'kvm', 'os': 'linux', - 'architecture': 'x86', - 'version': '16.0', - 'url': 'http://example.com/path/to/resource1', - 'md5hash': 'add6bb58e139be103324d04d82d8f546', - 'agent_id': 2}, - ] - self.assertEqual(res_dict, {'agents': response}) - - def test_agents_update(self): - req = FakeRequest() - body = {'agent': {'version': '7.0', - 'url': 'http://example.com/path/to/resource', - 'md5hash': 'add6bb58e139be103324d04d82d8f545'}} - response = {'agent': {'agent_id': 1, - 'version': '7.0', - 'url': 'http://example.com/path/to/resource', - 'md5hash': 'add6bb58e139be103324d04d82d8f545'}} - res_dict = self.controller.update(req, 1, body=body) - self.assertEqual(res_dict, response) - - def test_agents_update_without_md5hash(self): - req = FakeRequest() - body = {'agent': {'version': '7.0', - 'url': 'http://example.com/path/to/resource'}} - self.assertRaises(exception.ValidationError, self.controller.update, - req, 1, body=body) - - def test_agents_update_without_url(self): - req = FakeRequest() - body = {'agent': {'version': '7.0'}} - self.assertRaises(exception.ValidationError, self.controller.update, - req, 1, body=body) - - def test_agents_update_without_version(self): - req = FakeRequest() - body = {'agent': {}} - self.assertRaises(exception.ValidationError, self.controller.update, - req, 1, body=body) - - def test_agents_update_with_wrong_type(self): - req = FakeRequest() - body = {'agent': None} - self.assertRaises(exception.ValidationError, self.controller.update, - req, 1, body=body) - - def test_agents_update_with_empty(self): - req = FakeRequest() - body = {} - self.assertRaises(exception.ValidationError, self.controller.update, - req, 1, body=body) - - def _test_agents_update_with_invalid_length(self, key): - req = FakeRequest() - body = {'agent': {'version': '7.0', - 'url': 'http://example.com/path/to/resource', - 'md5hash': 'add6bb58e139be103324d04d82d8f545'}} - body['agent'][key] = 'x' * 256 - self.assertRaises(exception.ValidationError, self.controller.update, - req, 1, body=body) - - def test_agents_update_with_invalid_length_version(self): - self._test_agents_update_with_invalid_length('version') - - def test_agents_update_with_invalid_length_url(self): - self._test_agents_update_with_invalid_length('url') - - def test_agents_update_with_invalid_length_md5hash(self): - self._test_agents_update_with_invalid_length('md5hash') diff --git a/nova/tests/integrated/v3/api_samples/os-agents/agent-update-put-req.json.tpl b/nova/tests/integrated/v3/api_samples/os-agents/agent-update-put-req.json.tpl index f660b35e0a09..d447350e0dfb 100644 --- a/nova/tests/integrated/v3/api_samples/os-agents/agent-update-put-req.json.tpl +++ b/nova/tests/integrated/v3/api_samples/os-agents/agent-update-put-req.json.tpl @@ -1,5 +1,5 @@ { - "agent": { + "para": { "url": "%(url)s", "md5hash": "%(md5hash)s", "version": "%(version)s" diff --git a/nova/tests/integrated/v3/api_samples/os-agents/agent-update-put-resp.json.tpl b/nova/tests/integrated/v3/api_samples/os-agents/agent-update-put-resp.json.tpl index 2964c0f8948f..2919d2138818 100644 --- a/nova/tests/integrated/v3/api_samples/os-agents/agent-update-put-resp.json.tpl +++ b/nova/tests/integrated/v3/api_samples/os-agents/agent-update-put-resp.json.tpl @@ -1,6 +1,6 @@ { "agent": { - "agent_id": 1, + "agent_id": "1", "md5hash": "add6bb58e139be103324d04d82d8f545", "url": "http://example.com/path/to/resource", "version": "7.0" diff --git a/nova/tests/integrated/v3/test_agents.py b/nova/tests/integrated/v3/test_agents.py index bdb3b4e22093..9a562ea2ad6d 100644 --- a/nova/tests/integrated/v3/test_agents.py +++ b/nova/tests/integrated/v3/test_agents.py @@ -74,7 +74,7 @@ class AgentsJsonTest(api_sample_base.ApiSampleTestBaseV3): } response = self._do_post('os-agents', 'agent-post-req', project) - self._verify_response('agent-post-resp', project, response, 201) + self._verify_response('agent-post-resp', project, response, 200) def test_agent_list(self): # Return a list of all agent builds. @@ -95,4 +95,4 @@ class AgentsJsonTest(api_sample_base.ApiSampleTestBaseV3): # Deletes an existing agent build. agent_id = 1 response = self._do_delete('os-agents/%s' % agent_id) - self.assertEqual(response.status, 204) + self.assertEqual(response.status, 200)