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
d457f3d3
Commit
d457f3d3
authored
May 06, 2019
by
Grzegorz Bizon
Committed by
Filipa Lacerda
May 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable counting Gitaly requests in jobs show tests
parent
a12b6184
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
19 deletions
+59
-19
spec/controllers/projects/jobs_controller_spec.rb
spec/controllers/projects/jobs_controller_spec.rb
+59
-19
No files found.
spec/controllers/projects/jobs_controller_spec.rb
View file @
d457f3d3
...
...
@@ -101,7 +101,7 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
end
describe
'GET show'
do
describe
'GET show'
,
:request_store
do
let!
(
:job
)
{
create
(
:ci_build
,
:failed
,
pipeline:
pipeline
)
}
let!
(
:second_job
)
{
create
(
:ci_build
,
:failed
,
pipeline:
pipeline
)
}
let!
(
:third_job
)
{
create
(
:ci_build
,
:failed
)
}
...
...
@@ -143,19 +143,24 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
project
.
add_developer
(
user
)
sign_in
(
user
)
allow_any_instance_of
(
Ci
::
Build
)
.
to
receive
(
:merge_request
).
and_return
(
merge_request
)
get_show
(
id:
job
.
id
,
format: :json
)
allow_any_instance_of
(
Ci
::
Build
)
.
to
receive
(
:merge_request
)
.
and_return
(
merge_request
)
end
it
'does not serialize builds in exposed stages'
do
get_show_json
json_response
.
dig
(
'pipeline'
,
'details'
,
'stages'
).
tap
do
|
stages
|
expect
(
stages
.
map
(
&
:keys
).
flatten
).
to
eq
%w[name title status path dropdown_path]
expect
(
stages
.
map
(
&
:keys
).
flatten
)
.
to
eq
%w[name title status path dropdown_path]
end
end
context
'when job failed'
do
it
'exposes needed information'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'raw_path'
]).
to
match
(
%r{jobs/
\d
+/raw
\z
}
)
...
...
@@ -165,6 +170,10 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
context
'when job is running'
do
before
do
get_show_json
end
context
'job is cancelable'
do
let
(
:job
)
{
create
(
:ci_build
,
:running
,
pipeline:
pipeline
)
}
...
...
@@ -187,6 +196,10 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
context
'when job has artifacts'
do
before
do
get_show_json
end
context
'with not expiry date'
do
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
)
}
...
...
@@ -218,6 +231,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
)
}
it
'exposes empty state illustrations'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'status'
][
'illustration'
]).
to
have_key
(
'image'
)
...
...
@@ -230,6 +245,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
let
(
:job
)
{
create
(
:ci_build
,
:success
,
pipeline:
pipeline
)
}
it
'does not exposes the deployment information'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'deployment_status'
]).
to
be_nil
end
...
...
@@ -241,6 +258,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
let
(
:job
)
{
create
(
:ci_build
,
:running
,
environment:
environment
.
name
,
pipeline:
pipeline
)
}
it
'exposes the deployment information'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
match_schema
(
'job/job_details'
)
expect
(
json_response
[
'deployment_status'
][
"status"
]).
to
eq
'creating'
...
...
@@ -256,11 +275,11 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
before
do
project
.
add_maintainer
(
user
)
sign_in
(
user
)
get_show
(
id:
job
.
id
,
format: :json
)
end
it
'user can edit runner'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'runner'
]).
to
have_key
(
'edit_path'
)
...
...
@@ -276,11 +295,11 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
before
do
project
.
add_maintainer
(
user
)
sign_in
(
user
)
get_show
(
id:
job
.
id
,
format: :json
)
end
it
'user can not edit runner'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'runner'
]).
not_to
have_key
(
'edit_path'
)
...
...
@@ -295,11 +314,11 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
before
do
project
.
add_maintainer
(
user
)
sign_in
(
user
)
get_show
(
id:
job
.
id
,
format: :json
)
end
it
'user can not edit runner'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'runner'
]).
not_to
have_key
(
'edit_path'
)
...
...
@@ -312,6 +331,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
let
(
:job
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
,
runner:
runner
)
}
it
'exposes needed information'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'runners'
][
'online'
]).
to
be
false
...
...
@@ -325,6 +346,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
let
(
:job
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
,
runner:
runner
)
}
it
'exposes needed information'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'runners'
][
'online'
]).
to
be
false
...
...
@@ -334,6 +357,10 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
context
'settings_path'
do
before
do
get_show_json
end
context
'when user is developer'
do
it
'settings_path is not available'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
...
...
@@ -360,6 +387,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
context
'when no trace is available'
do
it
'has_trace is false'
do
get_show_json
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'has_trace'
]).
to
be
false
end
...
...
@@ -369,17 +398,21 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
let
(
:job
)
{
create
(
:ci_build
,
:running
,
:trace_live
,
pipeline:
pipeline
)
}
it
"has_trace is true"
do
get_show_json
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'has_trace'
]).
to
be
true
end
end
it
'exposes the stage the job belongs to'
do
get_show_json
expect
(
json_response
[
'stage'
]).
to
eq
(
'test'
)
end
end
context
'when requesting
JSON job is triggered
'
do
context
'when requesting
triggered job JSON
'
do
let!
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
let
(
:trigger
)
{
create
(
:ci_trigger
,
project:
project
)
}
let
(
:trigger_request
)
{
create
(
:ci_trigger_request
,
pipeline:
pipeline
,
trigger:
trigger
)
}
...
...
@@ -389,15 +422,15 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
project
.
add_developer
(
user
)
sign_in
(
user
)
allow_any_instance_of
(
Ci
::
Build
).
to
receive
(
:merge_request
).
and_return
(
merge_request
)
allow_any_instance_of
(
Ci
::
Build
)
.
to
receive
(
:merge_request
)
.
and_return
(
merge_request
)
end
context
'with no variables'
do
before
do
get_show
(
id:
job
.
id
,
format: :json
)
end
it
'exposes trigger information'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'trigger'
][
'short_token'
]).
to
eq
'toke'
...
...
@@ -414,7 +447,7 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
before
do
project
.
add_maintainer
(
user
)
get_show
(
id:
job
.
id
,
format: :json
)
get_show
_json
end
it
'returns a job_detail'
do
...
...
@@ -438,7 +471,7 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
context
'user is not a mantainer'
do
before
do
get_show
(
id:
job
.
id
,
format: :json
)
get_show
_json
end
it
'returns a job_detail'
do
...
...
@@ -462,6 +495,13 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
end
def
get_show_json
get_show
(
id:
job
.
id
,
format: :json
)
puts
'X'
*
50
puts
Gitlab
::
GitalyClient
.
get_request_count
end
def
get_show
(
**
extra_params
)
params
=
{
namespace_id:
project
.
namespace
.
to_param
,
...
...
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