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()