Merge "Don't throw exception when missing metrics"

This commit is contained in:
Zuul
2019-10-17 12:59:18 +00:00
committed by Gerrit Code Review
7 changed files with 27 additions and 33 deletions

View File

@@ -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)])

View File

@@ -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"""