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
Boxiang Sun
gitlab-ce
Commits
8c867052
Commit
8c867052
authored
Apr 06, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for Ci::Trace
parent
d4290995
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
2 deletions
+43
-2
spec/lib/gitlab/ci/trace_spec.rb
spec/lib/gitlab/ci/trace_spec.rb
+43
-2
No files found.
spec/lib/gitlab/ci/trace_spec.rb
View file @
8c867052
...
@@ -261,6 +261,15 @@ describe Gitlab::Ci::Trace, :clean_gitlab_redis_cache do
...
@@ -261,6 +261,15 @@ describe Gitlab::Ci::Trace, :clean_gitlab_redis_cache do
end
end
end
end
shared_examples
'read successfully with ChunkedIO'
do
it
'yields with source'
do
trace
.
read
do
|
stream
|
expect
(
stream
).
to
be_a
(
Gitlab
::
Ci
::
Trace
::
Stream
)
expect
(
stream
.
stream
).
to
be_a
(
Gitlab
::
Ci
::
Trace
::
ChunkedIO
)
end
end
end
shared_examples
'failed to read'
do
shared_examples
'failed to read'
do
it
'yields without source'
do
it
'yields without source'
do
trace
.
read
do
|
stream
|
trace
.
read
do
|
stream
|
...
@@ -302,6 +311,16 @@ describe Gitlab::Ci::Trace, :clean_gitlab_redis_cache do
...
@@ -302,6 +311,16 @@ describe Gitlab::Ci::Trace, :clean_gitlab_redis_cache do
it_behaves_like
'read successfully with StringIO'
it_behaves_like
'read successfully with StringIO'
end
end
context
'when live trace exists'
do
before
do
Gitlab
::
Ci
::
Trace
::
ChunkedIO
.
new
(
build
)
do
|
stream
|
stream
.
write
(
'abc'
)
end
end
it_behaves_like
'read successfully with ChunkedIO'
end
context
'when no sources exist'
do
context
'when no sources exist'
do
it_behaves_like
'failed to read'
it_behaves_like
'failed to read'
end
end
...
@@ -402,6 +421,28 @@ describe Gitlab::Ci::Trace, :clean_gitlab_redis_cache do
...
@@ -402,6 +421,28 @@ describe Gitlab::Ci::Trace, :clean_gitlab_redis_cache do
expect
(
trace
.
raw
).
to
eq
(
"data"
)
expect
(
trace
.
raw
).
to
eq
(
"data"
)
end
end
end
end
context
'stored in database'
do
before
do
Gitlab
::
Ci
::
Trace
::
ChunkedIO
.
new
(
build
)
do
|
stream
|
stream
.
write
(
'abc'
)
end
end
it
"trace exist"
do
expect
(
trace
.
exist?
).
to
be
(
true
)
end
it
"can be erased"
do
trace
.
erase!
expect
(
trace
.
exist?
).
to
be
(
false
)
expect
(
Ci
::
JobTraceChunk
.
where
(
job:
build
)).
not_to
be_exist
end
it
"returns live trace data"
do
expect
(
trace
.
raw
).
to
eq
(
"abc"
)
end
end
end
end
describe
'#archive!'
do
describe
'#archive!'
do
...
@@ -471,7 +512,7 @@ describe Gitlab::Ci::Trace, :clean_gitlab_redis_cache do
...
@@ -471,7 +512,7 @@ describe Gitlab::Ci::Trace, :clean_gitlab_redis_cache do
expect
(
build
.
trace
.
exist?
).
to
be_truthy
expect
(
build
.
trace
.
exist?
).
to
be_truthy
expect
(
build
.
job_artifacts_trace
.
file
.
exists?
).
to
be_truthy
expect
(
build
.
job_artifacts_trace
.
file
.
exists?
).
to
be_truthy
expect
(
build
.
job_artifacts_trace
.
file
.
filename
).
to
eq
(
'job.log'
)
expect
(
build
.
job_artifacts_trace
.
file
.
filename
).
to
eq
(
'job.log'
)
expect
(
Gitlab
::
Ci
::
Trace
::
ChunkedFile
::
LiveTrace
.
exist?
(
build
.
id
)).
to
be_falsy
expect
(
Ci
::
JobTraceChunk
.
where
(
job:
build
)).
not_to
be_exist
expect
(
src_checksum
)
expect
(
src_checksum
)
.
to
eq
(
Digest
::
SHA256
.
file
(
build
.
job_artifacts_trace
.
file
.
path
).
hexdigest
)
.
to
eq
(
Digest
::
SHA256
.
file
(
build
.
job_artifacts_trace
.
file
.
path
).
hexdigest
)
expect
(
build
.
job_artifacts_trace
.
file_sha256
).
to
eq
(
src_checksum
)
expect
(
build
.
job_artifacts_trace
.
file_sha256
).
to
eq
(
src_checksum
)
...
@@ -485,7 +526,7 @@ describe Gitlab::Ci::Trace, :clean_gitlab_redis_cache do
...
@@ -485,7 +526,7 @@ describe Gitlab::Ci::Trace, :clean_gitlab_redis_cache do
build
.
reload
build
.
reload
expect
(
build
.
trace
.
exist?
).
to
be_truthy
expect
(
build
.
trace
.
exist?
).
to
be_truthy
expect
(
build
.
job_artifacts_trace
).
to
be_nil
expect
(
build
.
job_artifacts_trace
).
to
be_nil
Gitlab
::
Ci
::
Trace
::
Chunked
File
::
LiveTrace
.
new
(
build
.
id
,
nil
,
'rb'
)
do
|
stream
|
Gitlab
::
Ci
::
Trace
::
Chunked
IO
.
new
(
build
)
do
|
stream
|
expect
(
stream
.
read
).
to
eq
(
trace_raw
)
expect
(
stream
.
read
).
to
eq
(
trace_raw
)
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