from osm_mon.core.config import Config
from osm_mon.core.database import AlarmRepository
from osm_mon.core.message_bus_client import MessageBusClient
+from osm_mon.evaluator.backends.prometheus import PrometheusBackend
from osm_mon.evaluator.evaluator import AlarmStatus
from osm_mon.evaluator.service import EvaluatorService
service = EvaluatorService(self.config)
service.queue = mock.Mock()
- service._evaluate_metric('test_id', 1, 'test_name', 'test_metric_name', mock_alarm)
+ service._evaluate_metric('test_id', '1', 'test_name', 'test_metric_name', mock_alarm)
service.queue.put.assert_called_with((mock_alarm, AlarmStatus.ALARM))
service.queue.reset_mock()
mock_alarm.operation = 'lt'
- service._evaluate_metric('test_id', 1, 'test_name', 'test_metric_name', mock_alarm)
+ service._evaluate_metric('test_id', '1', 'test_name', 'test_metric_name', mock_alarm)
service.queue.put.assert_called_with((mock_alarm, AlarmStatus.OK))
service.queue.reset_mock()
get_metric_value.return_value = None
- service._evaluate_metric('test_id', 1, 'test_name', 'test_metric_name', mock_alarm)
+ service._evaluate_metric('test_id', '1', 'test_name', 'test_metric_name', mock_alarm)
service.queue.put.assert_called_with((mock_alarm, AlarmStatus.INSUFFICIENT))
@mock.patch('multiprocessing.Process')
proccess.assert_called_with(target=evaluate_metric, args=(
'87776f33-b67c-417a-8119-cb08e4098951', '1', 'cirros_ns-1-cirros_vnfd-VM-1', 'average_memory_utilization',
mock_alarm))
+
+ @mock.patch.object(PrometheusBackend, "get_metric_value")
+ @mock.patch('osm_mon.core.database.db')
+ def test_get_metric_value_prometheus(self, db, get_metric_value):
+ self.config.set('evaluator', 'backend', 'prometheus')
+ evaluator = EvaluatorService(self.config)
+ evaluator._get_metric_value('test_id', 'test_vnf_member_index', 'test_vdur_name', 'test_metric_name')
+
+ get_metric_value.assert_called_with('test_metric_name', 'test_id', 'test_vdur_name', 'test_vnf_member_index')