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 = { ...@@ -32,7 +32,7 @@ const SUBMIT_BUTTON_CLASS = {
const OPERATORS = { const OPERATORS = {
greaterThan: '>', greaterThan: '>',
equalTo: '=', equalTo: '==',
lessThan: '<', lessThan: '<',
}; };
......
...@@ -5,7 +5,7 @@ class PrometheusAlert < ApplicationRecord ...@@ -5,7 +5,7 @@ class PrometheusAlert < ApplicationRecord
OPERATORS_MAP = { OPERATORS_MAP = {
lt: "<", lt: "<",
eq: "=", eq: "==",
gt: ">" gt: ">"
}.freeze }.freeze
......
---
title: Fix equality operator for Prometheus alerts
merge_request: 18919
author:
type: fixed
...@@ -81,7 +81,7 @@ describe('AlertWidget', () => { ...@@ -81,7 +81,7 @@ describe('AlertWidget', () => {
expect(wrapper.find(GlLoadingIcon).isVisible()).toBe(true); expect(wrapper.find(GlLoadingIcon).isVisible()).toBe(true);
expect(findWidgetForm().props('disabled')).toBe(true); expect(findWidgetForm().props('disabled')).toBe(true);
resolveReadAlert({ operator: '=', threshold: 42 }); resolveReadAlert({ operator: '==', threshold: 42 });
}) })
.then(() => waitForPromises()) .then(() => waitForPromises())
.then(() => { .then(() => {
...@@ -123,7 +123,7 @@ describe('AlertWidget', () => { ...@@ -123,7 +123,7 @@ describe('AlertWidget', () => {
metricId, metricId,
}, },
'my/alert2.json': { 'my/alert2.json': {
operator: '=', operator: '==',
threshold: 900, threshold: 900,
alert_path: 'my/alert2.json', alert_path: 'my/alert2.json',
metricId: '6', metricId: '6',
...@@ -163,7 +163,7 @@ describe('AlertWidget', () => { ...@@ -163,7 +163,7 @@ describe('AlertWidget', () => {
it('updates an alert with an appropriate handler', () => { it('updates an alert with an appropriate handler', () => {
const alertParams = { operator: '<', threshold: 4, alert_path: alertPath }; const alertParams = { operator: '<', threshold: 4, alert_path: alertPath };
const newAlertParams = { operator: '=', threshold: 12 }; const newAlertParams = { operator: '==', threshold: 12 };
mockReadAlert.mockResolvedValue(alertParams); mockReadAlert.mockResolvedValue(alertParams);
mockUpdateAlert.mockResolvedValue({ ...alertParams, ...newAlertParams }); mockUpdateAlert.mockResolvedValue({ ...alertParams, ...newAlertParams });
createComponent({ createComponent({
...@@ -171,7 +171,7 @@ describe('AlertWidget', () => { ...@@ -171,7 +171,7 @@ describe('AlertWidget', () => {
alertsToManage: { alertsToManage: {
[alertPath]: { [alertPath]: {
alert_path: alertPath, alert_path: alertPath,
operator: '=', operator: '==',
threshold: 12, threshold: 12,
metricId: '5', metricId: '5',
}, },
......
...@@ -23,6 +23,13 @@ describe PrometheusAlert do ...@@ -23,6 +23,13 @@ describe PrometheusAlert do
end end
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 describe 'associations' do
it { is_expected.to belong_to(:project).required } it { is_expected.to belong_to(:project).required }
it { is_expected.to belong_to(:environment).required } it { is_expected.to belong_to(:environment).required }
......
...@@ -17,7 +17,7 @@ describe Projects::Prometheus::Alerts::UpdateService do ...@@ -17,7 +17,7 @@ describe Projects::Prometheus::Alerts::UpdateService do
{ {
environment_id: alert.environment_id, environment_id: alert.environment_id,
prometheus_metric_id: alert.prometheus_metric_id, prometheus_metric_id: alert.prometheus_metric_id,
operator: '=', operator: '==',
threshold: 2.0 threshold: 2.0
} }
end 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