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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
254134fb
Commit
254134fb
authored
Jul 05, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent WRITE opetaions if it's already archived
parent
68d57939
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
2 deletions
+27
-2
lib/gitlab/ci/trace.rb
lib/gitlab/ci/trace.rb
+4
-1
spec/support/shared_examples/ci_trace_shared_examples.rb
spec/support/shared_examples/ci_trace_shared_examples.rb
+22
-0
spec/workers/ci/archive_traces_cron_worker_spec.rb
spec/workers/ci/archive_traces_cron_worker_spec.rb
+1
-1
No files found.
lib/gitlab/ci/trace.rb
View file @
254134fb
...
...
@@ -6,6 +6,7 @@ module Gitlab
LEASE_TIMEOUT
=
1
.
hour
ArchiveError
=
Class
.
new
(
StandardError
)
WriteError
=
Class
.
new
(
StandardError
)
attr_reader
:job
...
...
@@ -81,7 +82,9 @@ module Gitlab
def
write
(
mode
)
stream
=
Gitlab
::
Ci
::
Trace
::
Stream
.
new
do
if
current_path
if
trace_artifact
raise
WriteError
,
'Already archived'
elsif
current_path
File
.
open
(
current_path
,
mode
)
elsif
Feature
.
enabled?
(
'ci_enable_live_trace'
)
Gitlab
::
Ci
::
Trace
::
ChunkedIO
.
new
(
job
)
...
...
spec/support/shared_examples/ci_trace_shared_examples.rb
View file @
254134fb
...
...
@@ -138,6 +138,28 @@ shared_examples_for 'common trace features' do
end
end
describe
'#write'
do
subject
{
trace
.
send
(
:write
,
mode
)
{
}
}
let
(
:mode
)
{
'wb'
}
context
'when arhicved trace does not exist yet'
do
it
'does not raise an error'
do
expect
{
subject
}.
not_to
raise_error
end
end
context
'when arhicved trace already exists'
do
before
do
create
(
:ci_job_artifact
,
:trace
,
job:
build
)
end
it
'raises an error'
do
expect
{
subject
}.
to
raise_error
(
'Already archived'
)
end
end
end
describe
'#set'
do
before
do
trace
.
set
(
"12"
)
...
...
spec/workers/ci/archive_traces_cron_worker_spec.rb
View file @
254134fb
...
...
@@ -31,7 +31,7 @@ describe Ci::ArchiveTracesCronWorker do
it_behaves_like
'archives trace'
context
'when a trace had already been archived'
do
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:trace_
artifact
,
:trace_live
)
}
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:trace_
live
,
:trace_artifact
)
}
let!
(
:build2
)
{
create
(
:ci_build
,
:success
,
:trace_live
)
}
it
'continues to archive live traces'
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