Fix update agent return agent_id with string for os-agents v3
Currently the agent update return agent_id with integer, that is inconsistent with the response of agent create and index. It because agent update use the agent_id that passed from url as the response. This problem is fixed by converting the agent id as integer. And the API sample tests provide agent_id with string type in the fake data. This patch fix this problem for API sample files and tests. And for back-compatibility, we should add translator for v2.1 API later. Then this fix will be exposed after v3 API feature exposed by microversion in the future. DocImpact: The agent_is is changed to integer type for agents'update action. Change-Id: Ia9c1034a325b77a2057934cc80b6eab679ff1d2b Partial-Bug: #1333494
This commit is contained in:
parent
13fed34193
commit
8bc56d8bf2
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"agent": {
|
"agent": {
|
||||||
"agent_id": "1",
|
"agent_id": 1,
|
||||||
"architecture": "x86",
|
"architecture": "x86",
|
||||||
"hypervisor": "hypervisor",
|
"hypervisor": "hypervisor",
|
||||||
"md5hash": "add6bb58e139be103324d04d82d8f545",
|
"md5hash": "add6bb58e139be103324d04d82d8f545",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"agent": {
|
"agent": {
|
||||||
"agent_id": "1",
|
"agent_id": 1,
|
||||||
"md5hash": "add6bb58e139be103324d04d82d8f545",
|
"md5hash": "add6bb58e139be103324d04d82d8f545",
|
||||||
"url": "xxx://xxxx/xxx/xxx",
|
"url": "xxx://xxxx/xxx/xxx",
|
||||||
"version": "7.0"
|
"version": "7.0"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"agents": [
|
"agents": [
|
||||||
{
|
{
|
||||||
"agent_id": "1",
|
"agent_id": 1,
|
||||||
"architecture": "x86",
|
"architecture": "x86",
|
||||||
"hypervisor": "hypervisor",
|
"hypervisor": "hypervisor",
|
||||||
"md5hash": "add6bb58e139be103324d04d82d8f545",
|
"md5hash": "add6bb58e139be103324d04d82d8f545",
|
||||||
|
@ -90,7 +90,7 @@ class AgentController(object):
|
|||||||
except exception.AgentBuildNotFound as ex:
|
except exception.AgentBuildNotFound as ex:
|
||||||
raise webob.exc.HTTPNotFound(explanation=ex.format_message())
|
raise webob.exc.HTTPNotFound(explanation=ex.format_message())
|
||||||
|
|
||||||
return {"agent": {'agent_id': id, 'version': version,
|
return {"agent": {'agent_id': int(id), 'version': version,
|
||||||
'url': url, 'md5hash': md5hash}}
|
'url': url, 'md5hash': md5hash}}
|
||||||
|
|
||||||
@extensions.expected_errors(404)
|
@extensions.expected_errors(404)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"agent": {
|
"agent": {
|
||||||
"agent_id": "1",
|
"agent_id": 1,
|
||||||
"architecture": "x86",
|
"architecture": "x86",
|
||||||
"hypervisor": "hypervisor",
|
"hypervisor": "hypervisor",
|
||||||
"md5hash": "add6bb58e139be103324d04d82d8f545",
|
"md5hash": "add6bb58e139be103324d04d82d8f545",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"agent": {
|
"agent": {
|
||||||
"agent_id": "1",
|
"agent_id": 1,
|
||||||
"md5hash": "add6bb58e139be103324d04d82d8f545",
|
"md5hash": "add6bb58e139be103324d04d82d8f545",
|
||||||
"url": "xxx://xxxx/xxx/xxx",
|
"url": "xxx://xxxx/xxx/xxx",
|
||||||
"version": "7.0"
|
"version": "7.0"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"agents": [
|
"agents": [
|
||||||
{
|
{
|
||||||
"agent_id": "1",
|
"agent_id": 1,
|
||||||
"architecture": "x86",
|
"architecture": "x86",
|
||||||
"hypervisor": "hypervisor",
|
"hypervisor": "hypervisor",
|
||||||
"md5hash": "add6bb58e139be103324d04d82d8f545",
|
"md5hash": "add6bb58e139be103324d04d82d8f545",
|
||||||
|
@ -30,10 +30,10 @@ class AgentsJsonTest(api_sample_base.ApiSampleTestBaseV3):
|
|||||||
'os': 'os',
|
'os': 'os',
|
||||||
'version': '8.0',
|
'version': '8.0',
|
||||||
'md5hash': 'add6bb58e139be103324d04d82d8f545',
|
'md5hash': 'add6bb58e139be103324d04d82d8f545',
|
||||||
'id': '1'}]
|
'id': 1}]
|
||||||
|
|
||||||
def fake_agent_build_create(context, values):
|
def fake_agent_build_create(context, values):
|
||||||
values['id'] = '1'
|
values['id'] = 1
|
||||||
agent_build_ref = models.AgentBuild()
|
agent_build_ref = models.AgentBuild()
|
||||||
agent_build_ref.update(values)
|
agent_build_ref.update(values)
|
||||||
return agent_build_ref
|
return agent_build_ref
|
||||||
@ -74,22 +74,12 @@ class AgentsJsonTest(api_sample_base.ApiSampleTestBaseV3):
|
|||||||
}
|
}
|
||||||
response = self._do_post('os-agents', 'agent-post-req',
|
response = self._do_post('os-agents', 'agent-post-req',
|
||||||
project)
|
project)
|
||||||
project['agent_id'] = 1
|
|
||||||
self._verify_response('agent-post-resp', project, response, 201)
|
self._verify_response('agent-post-resp', project, response, 201)
|
||||||
return project
|
|
||||||
|
|
||||||
def test_agent_list(self):
|
def test_agent_list(self):
|
||||||
# Return a list of all agent builds.
|
# Return a list of all agent builds.
|
||||||
response = self._do_get('os-agents')
|
response = self._do_get('os-agents')
|
||||||
project = {'url': 'xxxxxxxxxxxx',
|
self._verify_response('agents-get-resp', {}, response, 200)
|
||||||
'hypervisor': 'hypervisor',
|
|
||||||
'architecture': 'x86',
|
|
||||||
'os': 'os',
|
|
||||||
'version': '8.0',
|
|
||||||
'md5hash': 'add6bb58e139be103324d04d82d8f545',
|
|
||||||
'agent_id': 1
|
|
||||||
}
|
|
||||||
self._verify_response('agents-get-resp', project, response, 200)
|
|
||||||
|
|
||||||
def test_agent_update(self):
|
def test_agent_update(self):
|
||||||
# Update an existing agent build.
|
# Update an existing agent build.
|
||||||
@ -99,7 +89,6 @@ class AgentsJsonTest(api_sample_base.ApiSampleTestBaseV3):
|
|||||||
'md5hash': 'add6bb58e139be103324d04d82d8f545'}
|
'md5hash': 'add6bb58e139be103324d04d82d8f545'}
|
||||||
response = self._do_put('os-agents/%s' % agent_id,
|
response = self._do_put('os-agents/%s' % agent_id,
|
||||||
'agent-update-put-req', subs)
|
'agent-update-put-req', subs)
|
||||||
subs['agent_id'] = 1
|
|
||||||
self._verify_response('agent-update-put-resp', subs, response, 200)
|
self._verify_response('agent-update-put-resp', subs, response, 200)
|
||||||
|
|
||||||
def test_agent_delete(self):
|
def test_agent_delete(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user