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
2c6b90f0
Commit
2c6b90f0
authored
Apr 06, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix HttpIO and spec
parent
e1d318be
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
8 deletions
+20
-8
lib/gitlab/ci/trace/http_io.rb
lib/gitlab/ci/trace/http_io.rb
+16
-6
spec/controllers/projects/jobs_controller_spec.rb
spec/controllers/projects/jobs_controller_spec.rb
+2
-1
spec/support/http_io/http_io_helpers.rb
spec/support/http_io/http_io_helpers.rb
+2
-1
No files found.
lib/gitlab/ci/trace/http_io.rb
View file @
2c6b90f0
...
...
@@ -75,18 +75,28 @@ module Gitlab
end
end
def
read
(
length
=
nil
)
def
read
(
length
=
nil
,
outbuf
=
""
)
out
=
""
until
eof?
||
(
length
&&
out
.
length
>=
length
)
length
||=
size
-
tell
until
length
<=
0
||
eof?
data
=
get_chunk
break
if
data
.
empty?
out
<<
data
@tell
+=
data
.
bytesize
chunk_bytes
=
[
BUFFER_SIZE
-
chunk_offset
,
length
].
min
chunk_data
=
data
.
byteslice
(
0
,
chunk_bytes
)
out
<<
chunk_data
@tell
+=
chunk_data
.
bytesize
length
-=
chunk_data
.
bytesize
end
out
=
out
[
0
,
length
]
if
length
&&
out
.
length
>
length
# If outbuf is passed, we put the output into the buffer. This supports IO.copy_stream functionality
if
outbuf
outbuf
.
slice!
(
0
,
outbuf
.
bytesize
)
outbuf
<<
out
end
out
end
...
...
@@ -158,7 +168,7 @@ module Gitlab
# Provider: GCS
# - When the file size is larger than requested Content-range, the Content-range is included in responces with Net::HTTPPartialContent 206
# - When the file size is smaller than requested Content-range, the Content-range is included in responces with Net::HTTPOK 200
@chunk_range
||=
(
chunk_start
...
(
chunk_start
+
@chunk
.
length
))
@chunk_range
||=
(
chunk_start
...
(
chunk_start
+
@chunk
.
bytesize
))
end
@chunk
[
chunk_offset
..
BUFFER_SIZE
]
...
...
spec/controllers/projects/jobs_controller_spec.rb
View file @
2c6b90f0
# coding: utf-8
require
'spec_helper'
describe
Projects
::
JobsController
do
describe
Projects
::
JobsController
,
:clean_gitlab_redis_shared_state
do
include
ApiHelpers
include
HttpIOHelpers
...
...
@@ -10,6 +10,7 @@ describe Projects::JobsController do
let
(
:user
)
{
create
(
:user
)
}
before
do
stub_feature_flags
(
ci_enable_live_trace:
true
)
stub_not_protect_default_branch
end
...
...
spec/support/http_io/http_io_helpers.rb
View file @
2c6b90f0
...
...
@@ -44,10 +44,11 @@ module HttpIOHelpers
def
remote_trace_body
@remote_trace_body
||=
File
.
read
(
expand_fixture_path
(
'trace/sample_trace'
))
.
force_encoding
(
Encoding
::
BINARY
)
end
def
remote_trace_size
remote_trace_body
.
length
remote_trace_body
.
bytesize
end
def
set_smaller_buffer_size_than
(
file_size
)
...
...
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