Fix args for get_notification_listener()

Change-Id: I11b416e88fbf9f9e22829f30257a3733091d9af3
This commit is contained in:
Ryota MIBU 2015-08-26 12:40:08 +09:00
parent 37d7d79d69
commit 358b9312ed
2 changed files with 11 additions and 4 deletions

View File

@ -53,9 +53,9 @@ class EventAlarmEvaluationService(service.Service):
def start(self): def start(self):
super(EventAlarmEvaluationService, self).start() super(EventAlarmEvaluationService, self).start()
self.listener = messaging.get_notification_listener( self.listener = messaging.get_notification_listener(
messaging.get_transport(), messaging.get_transport(self.conf),
oslo_messaging.Target(topic=self.conf.event_alarm_topic), [oslo_messaging.Target(topic=self.conf.event_alarm_topic)],
EventAlarmEndpoint(self.evaluator)) [EventAlarmEndpoint(self.evaluator)])
self.listener.start() self.listener.start()
# Add a dummy thread to have wait() working # Add a dummy thread to have wait() working
self.tg.add_timer(604800, lambda: None) self.tg.add_timer(604800, lambda: None)

View File

@ -16,6 +16,7 @@
import mock import mock
from oslo_config import fixture as fixture_config from oslo_config import fixture as fixture_config
from oslo_messaging import server
from aodh import event from aodh import event
from aodh import service from aodh import service
@ -35,7 +36,13 @@ class TestEventAlarmEvaluationService(tests_base.BaseTestCase):
return_value=self.storage_conn): return_value=self.storage_conn):
self.service = event.EventAlarmEvaluationService(self.CONF) self.service = event.EventAlarmEvaluationService(self.CONF)
def test_start_service(self): def test_start_and_stop_service(self):
self.service.start()
self.assertIsInstance(self.service.listener,
server.MessageHandlingServer)
self.service.stop()
def test_listener_start_called(self):
listener = mock.Mock() listener = mock.Mock()
with mock.patch('aodh.messaging.get_notification_listener', with mock.patch('aodh.messaging.get_notification_listener',
return_value=listener): return_value=listener):