Commit 6caf0f74 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'use-correct-prometheus-equality-operator' into 'master'

Use the correct equality operator for Prometheus Alerts

See merge request gitlab-org/gitlab!18919
parents 69362941 5ad57722
......@@ -32,7 +32,7 @@ const SUBMIT_BUTTON_CLASS = {
const OPERATORS = {
greaterThan: '>',
equalTo: '=',
equalTo: '==',
lessThan: '<',
};
......
......@@ -5,7 +5,7 @@ class PrometheusAlert < ApplicationRecord
OPERATORS_MAP = {
lt: "<",
eq: "=",
eq: "==",
gt: ">"
}.freeze
......
---
title: Fix equality operator for Prometheus alerts
merge_request: 18919
author:
type: fixed
......@@ -81,7 +81,7 @@ describe('AlertWidget', () => {
expect(wrapper.find(GlLoadingIcon).isVisible()).toBe(true);
expect(findWidgetForm().props('disabled')).toBe(true);
resolveReadAlert({ operator: '=', threshold: 42 });
resolveReadAlert({ operator: '==', threshold: 42 });
})
.then(() => waitForPromises())
.then(() => {
......@@ -123,7 +123,7 @@ describe('AlertWidget', () => {
metricId,
},
'my/alert2.json': {
operator: '=',
operator: '==',
threshold: 900,
alert_path: 'my/alert2.json',
metricId: '6',
......@@ -163,7 +163,7 @@ describe('AlertWidget', () => {
it('updates an alert with an appropriate handler', () => {
const alertParams = { operator: '<', threshold: 4, alert_path: alertPath };
const newAlertParams = { operator: '=', threshold: 12 };
const newAlertParams = { operator: '==', threshold: 12 };
mockReadAlert.mockResolvedValue(alertParams);
mockUpdateAlert.mockResolvedValue({ ...alertParams, ...newAlertParams });
createComponent({
......@@ -171,7 +171,7 @@ describe('AlertWidget', () => {
alertsToManage: {
[alertPath]: {
alert_path: alertPath,
operator: '=',
operator: '==',
threshold: 12,
metricId: '5',
},
......
......@@ -23,6 +23,13 @@ describe PrometheusAlert do
end
end
describe 'operators' do
it 'contains the correct equality operator' do
expect(described_class::OPERATORS_MAP.values).to include('==')
expect(described_class::OPERATORS_MAP.values).not_to include('=')
end
end
describe 'associations' do
it { is_expected.to belong_to(:project).required }
it { is_expected.to belong_to(:environment).required }
......
......@@ -17,7 +17,7 @@ describe Projects::Prometheus::Alerts::UpdateService do
{
environment_id: alert.environment_id,
prometheus_metric_id: alert.prometheus_metric_id,
operator: '=',
operator: '==',
threshold: 2.0
}
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment