summaryrefslogtreecommitdiff
path: root/osprofiler/tests
diff options
context:
space:
mode:
authorIlya Shakhat <shakhat@gmail.com>2019-04-08 16:43:45 +0200
committerIlya Shakhat <shakhat@gmail.com>2019-07-24 17:02:28 +0200
commit34ca7ab4b5f5c04986bc97e13cf411a1e8d7334e (patch)
treeb4d9fc5c46cb179f825d4cafcf96db0cbef3f1e3 /osprofiler/tests
parentdcc4f472df59aa62f1cd6a0442b8e5507b294bf1 (diff)
downloadosprofiler-34ca7ab4b5f5c04986bc97e13cf411a1e8d7334e.tar.gz
Handle driver initialization errors to avoid service crash
This patch fixes the issue when failed osprofiler driver brings the whole service down. With this patch the default no-op behaviour is used in case of initialization failure. Change-Id: I6ebc393576f4fc3f8b4134164bafc2e09f102ebd
Diffstat (limited to 'osprofiler/tests')
-rw-r--r--osprofiler/tests/unit/test_notifier.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/osprofiler/tests/unit/test_notifier.py b/osprofiler/tests/unit/test_notifier.py
index 7cccdad..8e658fe 100644
--- a/osprofiler/tests/unit/test_notifier.py
+++ b/osprofiler/tests/unit/test_notifier.py
@@ -23,6 +23,7 @@ class NotifierTestCase(test.TestCase):
def tearDown(self):
notifier.set(notifier._noop_notifier) # restore defaults
+ notifier.clear_notifier_cache()
super(NotifierTestCase, self).tearDown()
def test_set(self):
@@ -49,3 +50,11 @@ class NotifierTestCase(test.TestCase):
result = notifier.create("test", 10, b=20)
mock_factory.assert_called_once_with("test", 10, b=20)
self.assertEqual(mock_factory.return_value.notify, result)
+
+ @mock.patch("osprofiler.notifier.base.get_driver")
+ def test_create_driver_init_failure(self, mock_get_driver):
+ mock_get_driver.side_effect = Exception()
+
+ result = notifier.create("test", 10, b=20)
+ mock_get_driver.assert_called_once_with("test", 10, b=20)
+ self.assertEqual(notifier._noop_notifier, result)