Fixes report state failed with qpid rpc backend

Fixes bug 1159616

Change-Id: Ie63dd41169fdb2f7a1814aed38ab126b69b46fe9
This commit is contained in:
He Jie Xu 2013-03-25 16:18:21 +08:00
parent 7ef4d88805
commit 5308111909
2 changed files with 19 additions and 1 deletions

View File

@ -62,7 +62,7 @@ class PluginReportStateAPI(proxy.RpcProxy):
self.make_msg('report_state',
agent_state={'agent_state':
agent_state},
time=timeutils.utcnow()),
time=timeutils.strtime()),
topic=self.topic)

View File

@ -47,6 +47,24 @@ class AgentRPCPluginApi(base.BaseTestCase):
self._test_rpc_call('tunnel_sync')
class AgentPluginReportState(base.BaseTestCase):
def test_plugin_report_state(self):
topic = 'test'
reportStateAPI = rpc.PluginReportStateAPI(topic)
expected_agent_state = {'agent': 'test'}
with mock.patch.object(reportStateAPI, 'call') as call:
ctxt = context.RequestContext('fake_user', 'fake_project')
reportStateAPI.report_state(ctxt, expected_agent_state)
self.assertEqual(call.call_args[0][0], ctxt)
self.assertEqual(call.call_args[0][1]['method'],
'report_state')
self.assertEqual(call.call_args[0][1]['args']['agent_state'],
{'agent_state': expected_agent_state})
self.assertIsInstance(call.call_args[0][1]['args']['time'],
str)
self.assertEqual(call.call_args[1]['topic'], topic)
class AgentRPCMethods(base.BaseTestCase):
def test_create_consumers(self):
dispatcher = mock.Mock()