X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Ftest%2FOpenStack%2Ftest_alarming.py;h=effd9205592b930741578b93cc5a8ef93acd98c6;hb=0215787170470859168d861b666c4e92b37e3743;hp=557a93dd7d0abb0eacb14c0d8db16f656da86f72;hpb=c7397b95dbaeebd7d872779eec809daed9e487cc;p=osm%2FMON.git diff --git a/osm_mon/test/OpenStack/test_alarming.py b/osm_mon/test/OpenStack/test_alarming.py index 557a93d..effd920 100644 --- a/osm_mon/test/OpenStack/test_alarming.py +++ b/osm_mon/test/OpenStack/test_alarming.py @@ -29,10 +29,8 @@ import unittest import mock -from plugins.OpenStack.Aodh import alarming as alarm_req -from plugins.OpenStack.common import Common - -__author__ = "Helena McGough" +from osm_mon.plugins.OpenStack.Aodh import alarming as alarm_req +from osm_mon.plugins.OpenStack.common import Common log = logging.getLogger(__name__) @@ -52,6 +50,8 @@ class Response(object): class TestAlarming(unittest.TestCase): """Tests for alarming class functions.""" + maxDiff = None + def setUp(self): """Setup for tests.""" super(TestAlarming, self).setUp() @@ -204,44 +204,52 @@ class TestAlarming(unittest.TestCase): values = {"severity": "warning", "statistic": "COUNT", "threshold_value": 12, - "operation": "GT"} + "operation": "GT", + "granularity": 300, + "resource_type": "generic"} payload = self.alarming.check_payload( - values, "my_metric", "r_id", "alarm_name") + values, "disk_write_ops", "r_id", "alarm_name") - self.assertEqual( + self.assertDictEqual( json.loads(payload), {"name": "alarm_name", "gnocchi_resources_threshold_rule": {"resource_id": "r_id", - "metric": "my_metric", + "metric": "disk.disk_ops", "comparison_operator": "gt", "aggregation_method": "count", "threshold": 12, + "granularity": 300, "resource_type": "generic"}, "severity": "low", "state": "ok", - "type": "gnocchi_resources_threshold"}) + "type": "gnocchi_resources_threshold", + "alarm_actions": ["http://localhost:8662"]}) def test_check_valid_state_payload(self): """Test the check payload function for a valid payload with state.""" values = {"severity": "warning", "statistic": "COUNT", "threshold_value": 12, - "operation": "GT"} + "operation": "GT", + "granularity": 300, + "resource_type": "generic"} payload = self.alarming.check_payload( - values, "my_metric", "r_id", "alarm_name", alarm_state="alarm") + values, "disk_write_ops", "r_id", "alarm_name", alarm_state="alarm") self.assertEqual( json.loads(payload), {"name": "alarm_name", "gnocchi_resources_threshold_rule": {"resource_id": "r_id", - "metric": "my_metric", + "metric": "disk.disk_ops", "comparison_operator": "gt", "aggregation_method": "count", "threshold": 12, + "granularity": 300, "resource_type": "generic"}, "severity": "low", "state": "alarm", - "type": "gnocchi_resources_threshold"}) + "type": "gnocchi_resources_threshold", + "alarm_actions": ["http://localhost:8662"]}) def test_check_invalid_payload(self): """Test the check payload function for an invalid payload.""" @@ -268,4 +276,4 @@ class TestAlarming(unittest.TestCase): self.alarming.check_for_metric(auth_token, "metric_name", "r_id") perf_req.assert_called_with( - "gnocchi_endpoint/v1/metric/", auth_token, req_type="get") + "gnocchi_endpoint/v1/metric?sort=name:asc", auth_token, req_type="get")