diff options
| author | SandyWalsh <sandy.walsh@rackspace.com> | 2012-09-19 11:19:37 -0300 |
|---|---|---|
| committer | SandyWalsh <sandy.walsh@rackspace.com> | 2012-09-19 16:10:04 -0300 |
| commit | 4de976ccf8f27c152f89aecc7ded2c2cd9d0a710 (patch) | |
| tree | ad36bcfc1df9204bd73b600d17941f1bc2a20a29 /nova/tests | |
| parent | a484bfea8ff3f274bb71be11ff387aa671c1e798 (diff) | |
Send api.fault notification on API service faults.
Exceptions caught by the API middleware will now send "api.fault"
notifications indicating the offending URL and the underlying exception.
The allows the billing/usage systems to track requests end-to-end without
having to monitor log files. Disabled by default.
Enable with --notify_api_faults
Change-Id: Ied2783259413ba12d686b44b33e0707645e51afb
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/test_notifications.py | 24 |
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 |
