Don't throw exception when missing metrics
When querying data from datasource, it's possible to miss some data. In this case if we throw an exception, Audit will failed because of the exception. We should remove the exception and give the decision to the strategy. Change-Id: I1b0e6b78b3bba4df9ba16e093b3910aab1de922e Closes-Bug: #1847434
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
|
||||
from watcher.common import exception
|
||||
from watcher.decision_engine.datasources import base as datasource
|
||||
from watcher.tests import base
|
||||
|
||||
@@ -61,9 +60,8 @@ class TestBaseDatasourceHelper(base.BaseTestCase):
|
||||
helper = datasource.DataSourceBase()
|
||||
helper.query_retry_reset = mock.Mock()
|
||||
|
||||
# Maximum number of retries exceeded query_retry should raise error
|
||||
self.assertRaises(exception.DataSourceNotAvailable,
|
||||
helper.query_retry, f=method)
|
||||
# Maximum number of retries exceeded query_retry should return None
|
||||
self.assertIsNone(helper.query_retry(f=method))
|
||||
# query_retry_reset should be called twice
|
||||
helper.query_retry_reset.assert_has_calls(
|
||||
[mock.call(exc), mock.call(exc)])
|
||||
|
||||
@@ -132,11 +132,7 @@ class TestGrafana(base.BaseTestCase):
|
||||
|
||||
t_grafana = grafana.GrafanaHelper(osc=mock.Mock())
|
||||
|
||||
self.assertRaises(
|
||||
exception.DataSourceNotAvailable,
|
||||
t_grafana.get_host_cpu_usage,
|
||||
self.m_compute_node
|
||||
)
|
||||
self.assertIsNone(t_grafana.get_host_cpu_usage(self.m_compute_node))
|
||||
|
||||
def test_no_metric_raise_error(self):
|
||||
"""Test raising error when specified meter does not exist"""
|
||||
|
||||
Reference in New Issue
Block a user