summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorBrian Elliott <brian.elliott@rackspace.com>2012-05-30 21:14:31 +0000
committerBrian Elliott <brian.elliott@rackspace.com>2012-05-30 21:18:01 +0000
commitabea7d8f797675135b4419ff07491df4ecaed829 (patch)
tree64dd27b41726dfe63cb3d35b3885ada0629730ee /nova/tests
parentb04cd354f9c28403536593169b3fcfd828dba389 (diff)
Fix instance update notification publisher id
Fixes instance update notifications to follow the nova convention for publisher ids. The notification publisher id will now be of the format service.host (e.g. compute.somehostname). Change-Id: Ib5c4c962b9ac3e0bac90703b20465f99dfd047c0
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_notifications.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/nova/tests/test_notifications.py b/nova/tests/test_notifications.py
index a9d4f3f3b..daf96df47 100644
--- a/nova/tests/test_notifications.py
+++ b/nova/tests/test_notifications.py
@@ -54,7 +54,8 @@ class NotificationsTestCase(test.TestCase):
stub_network=True,
notification_driver='nova.notifier.test_notifier',
network_manager='nova.network.manager.FlatManager',
- notify_on_state_change="vm_and_task_state")
+ notify_on_state_change="vm_and_task_state",
+ host='testhost')
self.user_id = 'fake'
self.project_id = 'fake'
@@ -167,3 +168,33 @@ class NotificationsTestCase(test.TestCase):
self.assertEquals(vm_states.BUILDING, payload["state"])
self.assertEquals(task_states.SPAWNING, payload["old_task_state"])
self.assertEquals(None, payload["new_task_state"])
+
+ def test_update_no_service_name(self):
+ notifications.send_update_with_states(self.context, self.instance,
+ vm_states.BUILDING, vm_states.BUILDING, task_states.SPAWNING,
+ None)
+ self.assertEquals(1, len(test_notifier.NOTIFICATIONS))
+
+ # service name should default to 'compute'
+ notif = test_notifier.NOTIFICATIONS[0]
+ self.assertEquals('compute.testhost', notif['publisher_id'])
+
+ def test_update_with_service_name(self):
+ notifications.send_update_with_states(self.context, self.instance,
+ vm_states.BUILDING, vm_states.BUILDING, task_states.SPAWNING,
+ None, service="testservice")
+ self.assertEquals(1, len(test_notifier.NOTIFICATIONS))
+
+ # service name should default to 'compute'
+ notif = test_notifier.NOTIFICATIONS[0]
+ self.assertEquals('testservice.testhost', notif['publisher_id'])
+
+ def test_update_with_host_name(self):
+ notifications.send_update_with_states(self.context, self.instance,
+ vm_states.BUILDING, vm_states.BUILDING, task_states.SPAWNING,
+ None, host="someotherhost")
+ self.assertEquals(1, len(test_notifier.NOTIFICATIONS))
+
+ # service name should default to 'compute'
+ notif = test_notifier.NOTIFICATIONS[0]
+ self.assertEquals('compute.someotherhost', notif['publisher_id'])