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
d971a728
Commit
d971a728
authored
Aug 03, 2021
by
Gary Holtz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add structured logging to MergeRequestMergeabilityCheckWorker
Changelog: added
parent
2afa9308
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
+22
-2
app/workers/merge_request_mergeability_check_worker.rb
app/workers/merge_request_mergeability_check_worker.rb
+2
-2
spec/workers/merge_request_mergeability_check_worker_spec.rb
spec/workers/merge_request_mergeability_check_worker_spec.rb
+20
-0
No files found.
app/workers/merge_request_mergeability_check_worker.rb
View file @
d971a728
...
...
@@ -14,7 +14,7 @@ class MergeRequestMergeabilityCheckWorker
merge_request
=
MergeRequest
.
find_by_id
(
merge_request_id
)
unless
merge_request
logger
.
error
(
"Failed to find merge request with ID:
#{
merge_request_id
}
"
)
Sidekiq
.
logger
.
error
(
worker:
self
.
class
.
name
,
message:
"Failed to find merge request"
,
merge_request_id:
merge_request_id
)
return
end
...
...
@@ -23,6 +23,6 @@ class MergeRequestMergeabilityCheckWorker
.
new
(
merge_request
)
.
execute
(
recheck:
false
,
retry_lease:
false
)
logger
.
error
(
"Failed to check mergeability of merge request (
#{
merge_request_id
}
):
#{
result
.
message
}
"
)
if
result
.
error?
Sidekiq
.
logger
.
error
(
worker:
self
.
class
.
name
,
message:
"Failed to check mergeability of merge request:
#{
result
.
message
}
"
,
merge_request_id:
merge_request_id
)
if
result
.
error?
end
end
spec/workers/merge_request_mergeability_check_worker_spec.rb
View file @
d971a728
...
...
@@ -10,6 +10,12 @@ RSpec.describe MergeRequestMergeabilityCheckWorker do
it
'does not execute MergeabilityCheckService'
do
expect
(
MergeRequests
::
MergeabilityCheckService
).
not_to
receive
(
:new
)
expect
(
Sidekiq
.
logger
).
to
receive
(
:error
).
once
.
with
(
merge_request_id:
1
,
worker:
"MergeRequestMergeabilityCheckWorker"
,
message:
'Failed to find merge request'
)
subject
.
perform
(
1
)
end
end
...
...
@@ -24,6 +30,20 @@ RSpec.describe MergeRequestMergeabilityCheckWorker do
subject
.
perform
(
merge_request
.
id
)
end
it
'structurally logs a failed mergeability check'
do
expect_next_instance_of
(
MergeRequests
::
MergeabilityCheckService
,
merge_request
)
do
|
service
|
expect
(
service
).
to
receive
(
:execute
).
and_return
(
double
(
error?:
true
,
message:
"solar flares"
))
end
expect
(
Sidekiq
.
logger
).
to
receive
(
:error
).
once
.
with
(
merge_request_id:
merge_request
.
id
,
worker:
"MergeRequestMergeabilityCheckWorker"
,
message:
'Failed to check mergeability of merge request: solar flares'
)
subject
.
perform
(
merge_request
.
id
)
end
end
it_behaves_like
'an idempotent worker'
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