Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
cad56d6c
Commit
cad56d6c
authored
Jun 04, 2020
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not create duplicate issues for exising alerts
parent
4c1dff36
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
11 deletions
+24
-11
app/services/projects/alerting/notify_service.rb
app/services/projects/alerting/notify_service.rb
+2
-0
spec/services/projects/alerting/notify_service_spec.rb
spec/services/projects/alerting/notify_service_spec.rb
+22
-11
No files found.
app/services/projects/alerting/notify_service.rb
View file @
cad56d6c
...
@@ -63,6 +63,8 @@ module Projects
...
@@ -63,6 +63,8 @@ module Projects
end
end
def
process_incident_issues
(
alert
)
def
process_incident_issues
(
alert
)
return
if
alert
.
issue
IncidentManagement
::
ProcessAlertWorker
IncidentManagement
::
ProcessAlertWorker
.
perform_async
(
project
.
id
,
parsed_payload
,
alert
.
id
)
.
perform_async
(
project
.
id
,
parsed_payload
,
alert
.
id
)
end
end
...
...
spec/services/projects/alerting/notify_service_spec.rb
View file @
cad56d6c
...
@@ -11,23 +11,18 @@ describe Projects::Alerting::NotifyService do
...
@@ -11,23 +11,18 @@ describe Projects::Alerting::NotifyService do
allow
(
ProjectServiceWorker
).
to
receive
(
:perform_async
)
allow
(
ProjectServiceWorker
).
to
receive
(
:perform_async
)
end
end
shared_examples
'processes incident issues'
do
|
amount
|
shared_examples
'processes incident issues'
do
let
(
:create_incident_service
)
{
spy
}
let
(
:create_incident_service
)
{
spy
}
let
(
:new_alert
)
{
instance_double
(
AlertManagement
::
Alert
,
id:
503
,
persisted?:
true
)
}
before
do
before
do
allow
(
new_a
lert
).
to
receive
(
:execute_services
)
allow
_any_instance_of
(
AlertManagement
::
A
lert
).
to
receive
(
:execute_services
)
end
end
it
'processes issues'
do
it
'processes issues'
do
expect
(
AlertManagement
::
Alert
)
.
to
receive
(
:create
)
.
and_return
(
new_alert
)
expect
(
IncidentManagement
::
ProcessAlertWorker
)
expect
(
IncidentManagement
::
ProcessAlertWorker
)
.
to
receive
(
:perform_async
)
.
to
receive
(
:perform_async
)
.
with
(
project
.
id
,
kind_of
(
Hash
),
new_alert
.
id
)
.
with
(
project
.
id
,
kind_of
(
Hash
),
kind_of
(
Integer
)
)
.
exactly
(
amount
).
times
.
once
Sidekiq
::
Testing
.
inline!
do
Sidekiq
::
Testing
.
inline!
do
expect
(
subject
).
to
be_success
expect
(
subject
).
to
be_success
...
@@ -163,7 +158,8 @@ describe Projects::Alerting::NotifyService do
...
@@ -163,7 +158,8 @@ describe Projects::Alerting::NotifyService do
end
end
context
'existing alert with same fingerprint'
do
context
'existing alert with same fingerprint'
do
let!
(
:existing_alert
)
{
create
(
:alert_management_alert
,
project:
project
,
fingerprint:
Digest
::
SHA1
.
hexdigest
(
fingerprint
))
}
let
(
:fingerprint_sha
)
{
Digest
::
SHA1
.
hexdigest
(
fingerprint
)
}
let!
(
:existing_alert
)
{
create
(
:alert_management_alert
,
project:
project
,
fingerprint:
fingerprint_sha
)
}
it
'does not create AlertManagement::Alert'
do
it
'does not create AlertManagement::Alert'
do
expect
{
subject
}.
not_to
change
(
AlertManagement
::
Alert
,
:count
)
expect
{
subject
}.
not_to
change
(
AlertManagement
::
Alert
,
:count
)
...
@@ -220,7 +216,7 @@ describe Projects::Alerting::NotifyService do
...
@@ -220,7 +216,7 @@ describe Projects::Alerting::NotifyService do
context
'issue enabled'
do
context
'issue enabled'
do
let
(
:issue_enabled
)
{
true
}
let
(
:issue_enabled
)
{
true
}
it_behaves_like
'processes incident issues'
,
1
it_behaves_like
'processes incident issues'
context
'with an invalid payload'
do
context
'with an invalid payload'
do
before
do
before
do
...
@@ -232,6 +228,21 @@ describe Projects::Alerting::NotifyService do
...
@@ -232,6 +228,21 @@ describe Projects::Alerting::NotifyService do
it_behaves_like
'does not process incident issues due to error'
,
http_status: :bad_request
it_behaves_like
'does not process incident issues due to error'
,
http_status: :bad_request
it_behaves_like
'NotifyService does not create alert'
it_behaves_like
'NotifyService does not create alert'
end
end
context
'when alert already exists'
do
let
(
:fingerprint_sha
)
{
Digest
::
SHA1
.
hexdigest
(
fingerprint
)
}
let!
(
:existing_alert
)
{
create
(
:alert_management_alert
,
project:
project
,
fingerprint:
fingerprint_sha
)
}
context
'when existing alert does not have an associated issue'
do
it_behaves_like
'processes incident issues'
end
context
'when existing alert has an associated issue'
do
let!
(
:existing_alert
)
{
create
(
:alert_management_alert
,
:with_issue
,
project:
project
,
fingerprint:
fingerprint_sha
)
}
it_behaves_like
'does not process incident issues'
end
end
end
end
context
'with emails turned on'
do
context
'with emails turned on'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment