From: He Jie Xu Date: Mon, 25 Mar 2013 08:18:21 +0000 (+0800) Subject: Fixes report state failed with qpid rpc backend X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=530811190961c6759dfc72aacd99fc1a4deb93ee;p=openstack-build%2Fneutron-build.git Fixes report state failed with qpid rpc backend Fixes bug 1159616 Change-Id: Ie63dd41169fdb2f7a1814aed38ab126b69b46fe9 --- diff --git a/quantum/agent/rpc.py b/quantum/agent/rpc.py index fad2db866..0b9a62a59 100644 --- a/quantum/agent/rpc.py +++ b/quantum/agent/rpc.py @@ -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) diff --git a/quantum/tests/unit/test_agent_rpc.py b/quantum/tests/unit/test_agent_rpc.py index fdbb1194f..ca5b714e5 100644 --- a/quantum/tests/unit/test_agent_rpc.py +++ b/quantum/tests/unit/test_agent_rpc.py @@ -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()