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
8a1c2bc4
Commit
8a1c2bc4
authored
Mar 30, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for ChunkStore::Database too
parent
1a05c60e
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
499 additions
and
467 deletions
+499
-467
lib/gitlab/ci/trace/chunked_file/chunk_store/base.rb
lib/gitlab/ci/trace/chunked_file/chunk_store/base.rb
+4
-0
lib/gitlab/ci/trace/chunked_file/chunked_io.rb
lib/gitlab/ci/trace/chunked_file/chunked_io.rb
+8
-1
spec/lib/gitlab/ci/trace/chunked_file/chunked_io_spec.rb
spec/lib/gitlab/ci/trace/chunked_file/chunked_io_spec.rb
+12
-462
spec/support/chunked_io/chunked_io_helpers.rb
spec/support/chunked_io/chunked_io_helpers.rb
+7
-4
spec/support/shared_examples/lib/gitlab/ci/trace/chunked_file/chunked_io_shared_examples.rb
...itlab/ci/trace/chunked_file/chunked_io_shared_examples.rb
+468
-0
No files found.
lib/gitlab/ci/trace/chunked_file/chunk_store/base.rb
View file @
8a1c2bc4
...
...
@@ -30,6 +30,10 @@ module Gitlab
raise
NotImplementedError
end
def
append!
(
data
)
raise
NotImplementedError
end
def
truncate!
(
offset
)
raise
NotImplementedError
end
...
...
lib/gitlab/ci/trace/chunked_file/chunked_io.rb
View file @
8a1c2bc4
...
...
@@ -15,6 +15,7 @@ module Gitlab
end
end
BUFFER_SIZE
=
128
.
kilobytes
WriteError
=
Class
.
new
(
StandardError
)
FailedToGetChunkError
=
Class
.
new
(
StandardError
)
...
...
@@ -134,6 +135,8 @@ module Gitlab
writable_space
=
BUFFER_SIZE
-
chunk_offset
writing_size
=
[
writable_space
,
data
.
length
].
min
break
unless
writing_size
>
0
if
store
.
size
>
0
written_size
=
store
.
append!
(
data
.
slice!
(
0
...
writing_size
))
else
...
...
@@ -228,7 +231,11 @@ module Gitlab
end
def
chunks_count
(
size
/
BUFFER_SIZE
)
+
1
(
size
/
BUFFER_SIZE
)
+
(
has_extra?
?
1
:
0
)
end
def
has_extra?
(
size
%
BUFFER_SIZE
)
>
0
end
def
last_chunk?
...
...
spec/lib/gitlab/ci/trace/chunked_file/chunked_io_spec.rb
View file @
8a1c2bc4
This diff is collapsed.
Click to expand it.
spec/support/chunked_io/chunked_io_helpers.rb
View file @
8a1c2bc4
...
...
@@ -6,16 +6,19 @@ module ChunkedIOHelpers
end
def
sample_trace_raw
@sample_trace_raw
||=
File
.
read
(
expand_fixture_path
(
'trace/sample_trace'
))
if
chunk_store
==
Gitlab
::
Ci
::
Trace
::
ChunkedFile
::
ChunkStore
::
Redis
File
.
read
(
expand_fixture_path
(
'trace/sample_trace'
))
else
'01234567'
*
32
end
end
def
sample_trace_size
sample_trace_raw
.
length
end
def
stub_chunk_store_redis_get_failed
allow_any_instance_of
(
Gitlab
::
Ci
::
Trace
::
ChunkedFile
::
ChunkStore
::
Redis
)
.
to
receive
(
:get
).
and_return
(
nil
)
def
stub_chunk_store_get_failed
allow_any_instance_of
(
chunk_store
).
to
receive
(
:get
).
and_return
(
nil
)
end
def
set_smaller_buffer_size_than
(
file_size
)
...
...
spec/support/shared_examples/lib/gitlab/ci/trace/chunked_file/chunked_io_shared_examples.rb
0 → 100644
View file @
8a1c2bc4
This diff is collapsed.
Click to expand it.
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