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
bb3340cc
Commit
bb3340cc
authored
Aug 02, 2021
by
Sarah Yasonik
Committed by
James Fargher
Aug 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gracefully exit from escalation workers on failure
parent
38c501ee
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
8 deletions
+57
-8
ee/app/workers/incident_management/pending_escalations/alert_check_worker.rb
...dent_management/pending_escalations/alert_check_worker.rb
+2
-1
ee/app/workers/incident_management/pending_escalations/alert_create_worker.rb
...ent_management/pending_escalations/alert_create_worker.rb
+2
-1
ee/spec/workers/incident_management/pending_escalations/alert_check_worker_spec.rb
...management/pending_escalations/alert_check_worker_spec.rb
+19
-6
ee/spec/workers/incident_management/pending_escalations/alert_create_worker_spec.rb
...anagement/pending_escalations/alert_create_worker_spec.rb
+34
-0
No files found.
ee/app/workers/incident_management/pending_escalations/alert_check_worker.rb
View file @
bb3340cc
...
...
@@ -13,7 +13,8 @@ module IncidentManagement
feature_category
:incident_management
def
perform
(
escalation_id
)
escalation
=
IncidentManagement
::
PendingEscalations
::
Alert
.
find
(
escalation_id
)
escalation
=
IncidentManagement
::
PendingEscalations
::
Alert
.
find_by_id
(
escalation_id
)
return
unless
escalation
IncidentManagement
::
PendingEscalations
::
ProcessService
.
new
(
escalation
).
execute
end
...
...
ee/app/workers/incident_management/pending_escalations/alert_create_worker.rb
View file @
bb3340cc
...
...
@@ -13,7 +13,8 @@ module IncidentManagement
feature_category
:incident_management
def
perform
(
alert_id
)
alert
=
::
AlertManagement
::
Alert
.
find
(
alert_id
)
alert
=
::
AlertManagement
::
Alert
.
find_by_id
(
alert_id
)
return
unless
alert
::
IncidentManagement
::
PendingEscalations
::
CreateService
.
new
(
alert
).
execute
end
...
...
ee/spec/workers/incident_management/pending_escalations/alert_check_worker_spec.rb
View file @
bb3340cc
...
...
@@ -8,14 +8,27 @@ RSpec.describe IncidentManagement::PendingEscalations::AlertCheckWorker do
let_it_be
(
:escalation
)
{
create
(
:incident_management_pending_alert_escalation
)
}
describe
'#perform'
do
subject
{
worker
.
perform
(
escalation
.
id
)
}
subject
{
worker
.
perform
(
*
args
)
}
it
'processes the
escalation'
do
process_service
=
spy
(
IncidentManagement
::
PendingEscalations
::
ProcessService
)
context
'with valid
escalation'
do
let
(
:args
)
{
[
escalation
.
id
.
to_s
]
}
expect
(
IncidentManagement
::
PendingEscalations
::
ProcessService
).
to
receive
(
:new
).
with
(
escalation
).
and_return
(
process_service
)
subject
expect
(
process_service
).
to
have_received
(
:execute
)
it
'processes the escalation'
do
expect_next_instance_of
(
IncidentManagement
::
PendingEscalations
::
ProcessService
,
escalation
)
do
|
service
|
expect
(
service
).
to
receive
(
:execute
)
end
subject
end
end
context
'without valid escalation'
do
let
(
:args
)
{
[
non_existing_record_id
]
}
it
'does nothing'
do
expect
(
IncidentManagement
::
PendingEscalations
::
CreateService
).
not_to
receive
(
:new
)
expect
{
subject
}.
not_to
raise_error
end
end
end
end
ee/spec/workers/incident_management/pending_escalations/alert_create_worker_spec.rb
0 → 100644
View file @
bb3340cc
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
IncidentManagement
::
PendingEscalations
::
AlertCreateWorker
do
let
(
:worker
)
{
described_class
.
new
}
let_it_be
(
:alert
)
{
create
(
:alert_management_alert
)
}
describe
'#perform'
do
subject
{
worker
.
perform
(
*
args
)
}
context
'with valid alert'
do
let
(
:args
)
{
[
alert
.
id
.
to_s
]
}
it
'processes the escalation'
do
expect_next_instance_of
(
IncidentManagement
::
PendingEscalations
::
CreateService
,
alert
)
do
|
service
|
expect
(
service
).
to
receive
(
:execute
)
end
subject
end
end
context
'without valid alert'
do
let
(
:args
)
{
[
non_existing_record_id
]
}
it
'does nothing'
do
expect
(
IncidentManagement
::
PendingEscalations
::
CreateService
).
not_to
receive
(
:new
)
expect
{
subject
}.
not_to
raise_error
end
end
end
end
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