Commit 7c99cd22 authored by Sean Arnold's avatar Sean Arnold Committed by Peter Leitzen

Don't use end_time when comparing payloads

- Ensures we match on two payloads with differing end_times
- Fixes where alert without explicit fingerprint could not be resolved
parent 99a7757c
......@@ -6,7 +6,7 @@ module EE
module NotificationPayloadParser
extend ::Gitlab::Utils::Override
EXCLUDED_PAYLOAD_FINGERPRINT_PARAMS = %w(start_time hosts).freeze
EXCLUDED_PAYLOAD_FINGERPRINT_PARAMS = %w(start_time end_time hosts).freeze
# Currently we use full payloads, when generating a fingerprint.
# This results in a quite strict fingerprint.
......
......@@ -51,6 +51,28 @@ RSpec.describe Projects::Alerting::NotifyService do
it 'increments the existing alert count' do
expect { subject }.to change { existing_alert.reload.events }.from(1).to(2)
end
context 'end_time provided for subsequent alert' do
before do
payload[:end_time] = Time.current.change(usec: 0).iso8601
end
let(:existing_alert) do
existing_payload = payload.except(:end_time)
described_class.new(project, nil, existing_payload).execute(token)
AlertManagement::Alert.last!
end
it 'does not create AlertManagement::Alert' do
expect { subject }.not_to change(AlertManagement::Alert, :count)
end
it 'resolves the existing alert', :aggregate_failures do
expect { subject }.to change { existing_alert.reload.resolved? }.from(false).to(true)
expect(existing_alert.ended_at).to eq(payload[:end_time])
end
end
end
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