summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-09-20 01:59:20 +0000
committerGerrit Code Review <review@openstack.org>2012-09-20 01:59:20 +0000
commit70ed4ff2cba921262250065257a5002db1a7c19f (patch)
tree75b8ac8657e6928f039c31caadac035bd6632125 /nova/tests
parent20a91c4cdf8f0ce874690d88225ee93e8511f051 (diff)
parent4de976ccf8f27c152f89aecc7ded2c2cd9d0a710 (diff)
Merge "Send api.fault notification on API service faults."
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_notifications.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/nova/tests/test_notifications.py b/nova/tests/test_notifications.py
index 94922941e..d451d852c 100644
--- a/nova/tests/test_notifications.py
+++ b/nova/tests/test_notifications.py
@@ -86,6 +86,30 @@ class NotificationsTestCase(test.TestCase):
inst.update(params)
return db.instance_create(self.context, inst)
+ def test_send_api_fault_disabled(self):
+ self.flags(notify_api_faults=False)
+ notifications.send_api_fault("http://example.com/foo", 500, None)
+ self.assertEquals(0, len(test_notifier.NOTIFICATIONS))
+
+ def test_send_api_fault(self):
+ self.flags(notify_api_faults=True)
+ exception = None
+ try:
+ # Get a real exception with a call stack.
+ raise test.TestingException("junk")
+ except test.TestingException, e:
+ exception = e
+
+ notifications.send_api_fault("http://example.com/foo", 500, exception)
+
+ self.assertEquals(1, len(test_notifier.NOTIFICATIONS))
+ n = test_notifier.NOTIFICATIONS[0]
+ self.assertEquals(n['priority'], 'ERROR')
+ self.assertEquals(n['event_type'], 'api.fault')
+ self.assertEquals(n['payload']['url'], 'http://example.com/foo')
+ self.assertEquals(n['payload']['status'], 500)
+ self.assertTrue(n['payload']['exception'] is not None)
+
def test_notif_disabled(self):
# test config disable of the notifcations