def test_init_service(self): dummy_service = service.Service(DummyManager) self.assertIsInstance(dummy_service.serializer, rpc.RequestContextSerializer) self.assertIsInstance( dummy_service.conductor_topic_handler, om.rpc.server.RPCServer)
def test_build_topic_handler(self): topic_name = "mytopic" dummy_service = service.Service(DummyManager) handler = dummy_service.build_topic_handler(topic_name) self.assertIsNotNone(handler) self.assertIsInstance(handler, om.rpc.server.RPCServer) self.assertEqual("mytopic", handler._target.topic)
def test_init_service(self): dummy_service = service.Service(DummyManager) self.assertIsInstance(dummy_service.serializer, rpc.RequestContextSerializer) self.assertIsInstance(dummy_service.conductor_topic_handler, messaging_handler.MessagingHandler) self.assertIsInstance(dummy_service.status_topic_handler, messaging_handler.MessagingHandler)
def main(): watcher_service.prepare_service(sys.argv) LOG.info(_LI('Starting Watcher Applier service in PID %s'), os.getpid()) applier_service = watcher_service.Service(manager.ApplierManager) # Only 1 process launcher = watcher_service.launch(CONF, applier_service) launcher.wait()
def test_publish_status_event(self, m_handler_cls): m_handler = mock.Mock() m_handler_cls.return_value = m_handler payload = { "name": "value", } event = "myevent" dummy_service = service.Service(DummyManager) dummy_service.publish_status_event(event, payload) m_handler.publish_event.assert_called_once_with(event, payload, None)
def test_messaging_build_topic_handler(self): dummy_service = service.Service(DummyManager) topic = dummy_service.build_topic_handler("conductor_topic") self.assertIsInstance(topic, messaging_handler.MessagingHandler) self.assertEqual("pub_id", dummy_service.publisher_id) self.assertEqual("pub_id", topic.publisher_id) self.assertEqual("conductor_topic", dummy_service.conductor_topic_handler.topic_name) self.assertEqual("conductor_topic", topic.topic_name)
def test_nova_receive_instance_update(self, m_info): message = self.load_message('instance-update.json') expected_message = message['payload'] de_service = watcher_service.Service(fake_managers.FakeManager) incoming = mock.Mock(ctxt=self.context.to_dict(), message=message) de_service.notification_handler.dispatcher.dispatch(incoming) m_info.assert_called_once_with(self.context, 'nova-compute:compute', 'instance.update', expected_message, self.FAKE_METADATA)
def test_cinder_receive_volume_create_end(self, m_info): message = self.load_message('scenario_1_volume-create.json') expected_message = message['payload'] de_service = watcher_service.Service(fake_managers.FakeStorageManager) incoming = mock.Mock(ctxt=self.context.to_dict(), message=message) de_service.notification_handler.dispatcher.dispatch(incoming) m_info.assert_called_once_with(self.context, 'volume.host_0@backend_0#pool_0', 'volume.create.end', expected_message, self.FAKE_METADATA)
def test_cinder_receive_capacity(self, m_info): message = self.load_message('capacity.json') expected_message = message['payload'] de_service = watcher_service.Service(fake_managers.FakeStorageManager) incoming = mock.Mock(ctxt=self.context.to_dict(), message=message) de_service.notification_handler.dispatcher.dispatch(incoming) m_info.assert_called_once_with(self.context, 'capacity.host1@backend1#pool1', 'capacity.pool', expected_message, self.FAKE_METADATA)
def test_response(self, mock_call): event = "My event" context = {'request_id': 12} message = "My Message" dummy_service = service.Service(DummyManager) dummy_service.response(event, context, message) expected_payload = { 'request_id': context['request_id'], 'msg': message } mock_call.assert_called_once_with(event, expected_payload)
def main(): watcher_service.prepare_service(sys.argv, CONF) LOG.info('Starting Watcher Applier service in PID %s', os.getpid()) applier_service = watcher_service.Service(manager.ApplierManager) syncer = sync.Syncer() syncer.sync() # Only 1 process launcher = watcher_service.launch(CONF, applier_service) launcher.wait()
def test_receive_nova_notifications(self, m_info): de_service = watcher_service.Service(fake_managers.FakeManager) n_dicts = novanotification.VersionedNotification.notification_mapping for n_type in n_dicts.keys(): n_json = self.FAKE_NOTIFICATIONS[n_type] message = self.load_message(n_json) expected_message = message['payload'] publisher_id = message['publisher_id'] incoming = mock.Mock(ctxt=self.context.to_dict(), message=message) de_service.notification_handler.dispatcher.dispatch(incoming) m_info.assert_called_with(self.context, publisher_id, n_type, expected_message, self.FAKE_METADATA)
def test_skip_unwanted_notification(self, m_info): message = { 'publisher_id': 'nova-compute', 'event_type': 'compute.dummy', 'payload': { 'data': { 'nested': 'unwanted' } }, 'priority': 'INFO', } de_service = watcher_service.Service(DummyManager) incoming = mock.Mock(ctxt=self.context.to_dict(), message=message) de_service.notification_handler.dispatcher.dispatch(incoming) self.assertEqual(0, m_info.call_count)
def main(): watcher_service.prepare_service(sys.argv, CONF) gmr.register_gmr_plugins() LOG.info('Starting Watcher Decision Engine service in PID %s', os.getpid()) syncer = sync.Syncer() syncer.sync() de_service = watcher_service.Service(manager.DecisionEngineManager) bg_scheduler_service = scheduling.DecisionEngineSchedulingService() # Only 1 process launcher = watcher_service.launch(CONF, de_service) launcher.launch_service(bg_scheduler_service) launcher.wait()
def test_receive_dummy_notification(self, m_info): message = { 'publisher_id': 'nova-compute', 'event_type': 'compute.dummy', 'payload': { 'data': { 'nested': 'TEST' } }, 'priority': 'INFO', } de_service = watcher_service.Service(DummyManager) incoming = mock.Mock(ctxt=self.context.to_dict(), message=message) de_service.notification_handler.dispatcher.dispatch(incoming) m_info.assert_called_once_with(self.context, 'nova-compute', 'compute.dummy', {'data': { 'nested': 'TEST' }}, { 'message_id': None, 'timestamp': None })
def setUp(self): super(TestApplierManager, self).setUp() self.applier = service.Service(applier_manager.ApplierManager)
def test_build_topic_handler(self): topic_name = "mytopic" dummy_service = service.Service(DummyManager) handler = dummy_service.build_topic_handler(topic_name) self.assertIsNotNone(handler)
def test_stop(self, m_handler): dummy_service = service.Service(DummyManager) dummy_service.stop() self.assertEqual(2, m_handler.call_count)
def setUp(self): super(TestApplierManager, self).setUp() p_heartbeat = mock.patch.object(service.ServiceHeartbeat, "send_beat") self.m_heartbeat = p_heartbeat.start() self.addCleanup(p_heartbeat.stop) self.applier = service.Service(applier_manager.ApplierManager)