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
94f27b5a
Commit
94f27b5a
authored
Feb 02, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add integration specs for EE version. Raise an error when htto request fails.
parent
d40e8a95
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
4 deletions
+66
-4
ee/lib/gitlab/ci/trace/http_io.rb
ee/lib/gitlab/ci/trace/http_io.rb
+3
-4
spec/ee/spec/controllers/ee/projects/jobs_controller_spec.rb
spec/ee/spec/controllers/ee/projects/jobs_controller_spec.rb
+45
-0
spec/requests/api/jobs_spec.rb
spec/requests/api/jobs_spec.rb
+18
-0
No files found.
ee/lib/gitlab/ci/trace/http_io.rb
View file @
94f27b5a
...
...
@@ -7,6 +7,7 @@ module Gitlab
class
HttpIO
BUFFER_SIZE
=
128
.
kilobytes
InvalidURLError
=
Class
.
new
(
StandardError
)
FailedToGetChunkError
=
Class
.
new
(
StandardError
)
attr_reader
:uri
,
:size
...
...
@@ -16,6 +17,8 @@ module Gitlab
alias_method
:pos
,
:tell
def
initialize
(
url
,
size
)
raise
InvalidURLError
unless
::
Gitlab
::
UrlSanitizer
.
valid?
(
url
)
@uri
=
URI
(
url
)
@size
=
size
@tell
=
0
...
...
@@ -82,8 +85,6 @@ module Gitlab
out
=
out
[
0
,
length
]
if
length
&&
out
.
length
>
length
out
rescue
FailedToGetChunkError
nil
end
def
readline
...
...
@@ -104,8 +105,6 @@ module Gitlab
end
out
rescue
FailedToGetChunkError
nil
end
def
write
(
data
)
...
...
spec/ee/spec/controllers/ee/projects/jobs_controller_spec.rb
View file @
94f27b5a
...
...
@@ -2,10 +2,55 @@ require 'spec_helper'
describe
Projects
::
JobsController
do
include
ApiHelpers
include
HttpIOHelpers
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
describe
'GET trace.json'
do
context
'when trace artifact is in ObjectStorage'
do
let!
(
:job
)
{
create
(
:ci_build
,
:success
,
:trace_artifact
,
pipeline:
pipeline
)
}
before
do
allow_any_instance_of
(
JobArtifactUploader
).
to
receive
(
:file_storage?
)
{
false
}
allow_any_instance_of
(
JobArtifactUploader
).
to
receive
(
:url
)
{
remote_trace_url
}
allow_any_instance_of
(
JobArtifactUploader
).
to
receive
(
:size
)
{
remote_trace_size
}
end
context
'when there are no network issues'
do
before
do
stub_remote_trace_ok
get_trace
end
it
'returns a trace'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'id'
]).
to
eq
job
.
id
expect
(
json_response
[
'status'
]).
to
eq
job
.
status
expect
(
json_response
[
'html'
]).
to
eq
(
job
.
trace
.
html
)
end
end
context
'when there is a network issue'
do
before
do
stub_remote_trace_ng
end
it
'returns a trace'
do
expect
{
get_trace
}.
to
raise_error
(
Gitlab
::
Ci
::
Trace
::
HttpIO
::
FailedToGetChunkError
)
end
end
end
def
get_trace
get
:trace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
job
.
id
,
format: :json
end
end
describe
'GET raw'
do
subject
do
post
:raw
,
namespace_id:
project
.
namespace
,
...
...
spec/requests/api/jobs_spec.rb
View file @
94f27b5a
require
'spec_helper'
describe
API
::
Jobs
do
include
HttpIOHelpers
set
(
:project
)
do
create
(
:project
,
:repository
,
public_builds:
false
)
end
...
...
@@ -451,6 +453,22 @@ describe API::Jobs do
end
context
'authorized user'
do
context
'when trace is in ObjectStorage'
do
let!
(
:job
)
{
create
(
:ci_build
,
:trace_artifact
,
pipeline:
pipeline
)
}
before
do
stub_remote_trace_ok
allow_any_instance_of
(
JobArtifactUploader
).
to
receive
(
:file_storage?
)
{
false
}
allow_any_instance_of
(
JobArtifactUploader
).
to
receive
(
:url
)
{
remote_trace_url
}
allow_any_instance_of
(
JobArtifactUploader
).
to
receive
(
:size
)
{
remote_trace_size
}
end
it
'returns specific job trace'
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
.
body
).
to
eq
(
job
.
trace
.
raw
)
end
end
context
'when trace is artifact'
do
let
(
:job
)
{
create
(
:ci_build
,
:trace_artifact
,
pipeline:
pipeline
)
}
...
...
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