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
af5bf568
Commit
af5bf568
authored
Nov 29, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve spec
parent
3fbd48e1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
59 deletions
+24
-59
spec/services/ci/archive_trace_service_spec.rb
spec/services/ci/archive_trace_service_spec.rb
+12
-0
spec/workers/archive_trace_worker_spec.rb
spec/workers/archive_trace_worker_spec.rb
+5
-31
spec/workers/ci/archive_traces_cron_worker_spec.rb
spec/workers/ci/archive_traces_cron_worker_spec.rb
+7
-28
No files found.
spec/services/ci/archive_trace_service_spec.rb
View file @
af5bf568
...
@@ -11,6 +11,18 @@ describe Ci::ArchiveTraceService, '#execute' do
...
@@ -11,6 +11,18 @@ describe Ci::ArchiveTraceService, '#execute' do
expect
(
job
.
reload
.
job_artifacts_trace
).
to
be_exist
expect
(
job
.
reload
.
job_artifacts_trace
).
to
be_exist
end
end
context
'when trace is already archived'
do
let!
(
:job
)
{
create
(
:ci_build
,
:success
,
:trace_artifact
)
}
it
'ignores an exception'
do
expect
{
subject
}.
not_to
raise_error
end
it
'does not create an archived trace'
do
expect
{
subject
}.
not_to
change
{
Ci
::
JobArtifact
.
trace
.
count
}
end
end
end
end
context
'when job is running'
do
context
'when job is running'
do
...
...
spec/workers/archive_trace_worker_spec.rb
View file @
af5bf568
...
@@ -5,10 +5,11 @@ describe ArchiveTraceWorker do
...
@@ -5,10 +5,11 @@ describe ArchiveTraceWorker do
subject
{
described_class
.
new
.
perform
(
job
&
.
id
)
}
subject
{
described_class
.
new
.
perform
(
job
&
.
id
)
}
context
'when job is found'
do
context
'when job is found'
do
let
(
:job
)
{
create
(
:ci_build
)
}
let
(
:job
)
{
create
(
:ci_build
,
:trace_live
)
}
it
'executes service'
do
it
'executes service'
do
expect_any_instance_of
(
Gitlab
::
Ci
::
Trace
).
to
receive
(
:archive!
)
expect_any_instance_of
(
Ci
::
ArchiveTraceService
)
.
to
receive
(
:execute
).
with
(
job
)
subject
subject
end
end
...
@@ -18,38 +19,11 @@ describe ArchiveTraceWorker do
...
@@ -18,38 +19,11 @@ describe ArchiveTraceWorker do
let
(
:job
)
{
nil
}
let
(
:job
)
{
nil
}
it
'does not execute service'
do
it
'does not execute service'
do
expect_any_instance_of
(
Gitlab
::
Ci
::
Trace
).
not_to
receive
(
:archive!
)
expect_any_instance_of
(
Ci
::
ArchiveTraceService
)
.
not_to
receive
(
:execute
)
subject
subject
end
end
end
end
context
'when an unexpected exception happened during archiving'
do
let!
(
:job
)
{
create
(
:ci_build
,
:success
,
:trace_live
)
}
before
do
allow_any_instance_of
(
Gitlab
::
Ci
::
Trace
).
to
receive
(
:archive_stream!
).
and_raise
(
'Unexpected error'
)
end
it
'increments Prometheus counter, sends crash report to Sentry and ignore an error for continuing to archive'
do
expect
(
Gitlab
::
Sentry
)
.
to
receive
(
:track_exception
)
.
with
(
RuntimeError
,
issue_url:
'https://gitlab.com/gitlab-org/gitlab-ce/issues/51502'
,
extra:
{
job_id:
job
.
id
}
).
once
expect
(
Rails
.
logger
)
.
to
receive
(
:error
)
.
with
(
"Failed to archive trace. id:
#{
job
.
id
}
message: Unexpected error"
)
.
and_call_original
expect
(
Gitlab
::
Metrics
)
.
to
receive
(
:counter
)
.
with
(
:job_trace_archive_failed_total
,
"Counter of failed attempts of trace archiving"
)
.
and_call_original
expect
{
subject
}.
not_to
raise_error
end
end
end
end
end
end
spec/workers/ci/archive_traces_cron_worker_spec.rb
View file @
af5bf568
...
@@ -30,6 +30,13 @@ describe Ci::ArchiveTracesCronWorker do
...
@@ -30,6 +30,13 @@ describe Ci::ArchiveTracesCronWorker do
it_behaves_like
'archives trace'
it_behaves_like
'archives trace'
it
'executes service'
do
expect_any_instance_of
(
Ci
::
ArchiveTraceService
)
.
to
receive
(
:execute
).
with
(
build
)
subject
end
context
'when a trace had already been archived'
do
context
'when a trace had already been archived'
do
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:trace_live
,
:trace_artifact
)
}
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:trace_live
,
:trace_artifact
)
}
let!
(
:build2
)
{
create
(
:ci_build
,
:success
,
:trace_live
)
}
let!
(
:build2
)
{
create
(
:ci_build
,
:success
,
:trace_live
)
}
...
@@ -41,34 +48,6 @@ describe Ci::ArchiveTracesCronWorker do
...
@@ -41,34 +48,6 @@ describe Ci::ArchiveTracesCronWorker do
expect
(
build2
.
job_artifacts_trace
).
to
be_exist
expect
(
build2
.
job_artifacts_trace
).
to
be_exist
end
end
end
end
context
'when an unexpected exception happened during archiving'
do
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:trace_live
)
}
before
do
allow_any_instance_of
(
Gitlab
::
Ci
::
Trace
).
to
receive
(
:archive_stream!
).
and_raise
(
'Unexpected error'
)
end
it
'increments Prometheus counter, sends crash report to Sentry and ignore an error for continuing to archive'
do
expect
(
Gitlab
::
Sentry
)
.
to
receive
(
:track_exception
)
.
with
(
RuntimeError
,
issue_url:
'https://gitlab.com/gitlab-org/gitlab-ce/issues/51502'
,
extra:
{
job_id:
build
.
id
}
).
once
expect
(
Rails
.
logger
)
.
to
receive
(
:error
)
.
with
(
"Failed to archive trace. id:
#{
build
.
id
}
message: Unexpected error"
)
.
and_call_original
expect
(
Gitlab
::
Metrics
)
.
to
receive
(
:counter
)
.
with
(
:job_trace_archive_failed_total
,
"Counter of failed attempts of trace archiving"
)
.
and_call_original
expect
{
subject
}.
not_to
raise_error
end
end
end
end
context
'when a job was cancelled'
do
context
'when a job was cancelled'
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