]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fixes report state failed with qpid rpc backend
authorHe Jie Xu <xuhj@linux.vnet.ibm.com>
Mon, 25 Mar 2013 08:18:21 +0000 (16:18 +0800)
committerHe Jie Xu <xuhj@linux.vnet.ibm.com>
Mon, 25 Mar 2013 09:30:48 +0000 (17:30 +0800)
Fixes bug 1159616

Change-Id: Ie63dd41169fdb2f7a1814aed38ab126b69b46fe9

quantum/agent/rpc.py
quantum/tests/unit/test_agent_rpc.py

index fad2db8665523de3a0f205daf34606c8172bf391..0b9a62a5974610527be6fdd514e915c9bf7a51bf 100644 (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)
 
 
index fdbb1194ff8e3207bc6808cccb1b9a8dd2c6d61b..ca5b714e51eae97cb82c33ff24c53a2e8f64aa6f 100644 (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()