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
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
Show 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
...
@@ -101,7 +101,7 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
end
end
end
describe
'GET show'
do
describe
'GET show'
,
:request_store
do
let!
(
:job
)
{
create
(
:ci_build
,
:failed
,
pipeline:
pipeline
)
}
let!
(
:job
)
{
create
(
:ci_build
,
:failed
,
pipeline:
pipeline
)
}
let!
(
:second_job
)
{
create
(
:ci_build
,
:failed
,
pipeline:
pipeline
)
}
let!
(
:second_job
)
{
create
(
:ci_build
,
:failed
,
pipeline:
pipeline
)
}
let!
(
:third_job
)
{
create
(
:ci_build
,
:failed
)
}
let!
(
:third_job
)
{
create
(
:ci_build
,
:failed
)
}
...
@@ -143,19 +143,24 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -143,19 +143,24 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
project
.
add_developer
(
user
)
project
.
add_developer
(
user
)
sign_in
(
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
)
get_show
(
id:
job
.
id
,
format: :json
)
.
and_return
(
merge_request
)
end
end
it
'does not serialize builds in exposed stages'
do
it
'does not serialize builds in exposed stages'
do
get_show_json
json_response
.
dig
(
'pipeline'
,
'details'
,
'stages'
).
tap
do
|
stages
|
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
end
end
context
'when job failed'
do
context
'when job failed'
do
it
'exposes needed information'
do
it
'exposes needed information'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'raw_path'
]).
to
match
(
%r{jobs/
\d
+/raw
\z
}
)
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
...
@@ -165,6 +170,10 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
end
context
'when job is running'
do
context
'when job is running'
do
before
do
get_show_json
end
context
'job is cancelable'
do
context
'job is cancelable'
do
let
(
:job
)
{
create
(
:ci_build
,
:running
,
pipeline:
pipeline
)
}
let
(
:job
)
{
create
(
:ci_build
,
:running
,
pipeline:
pipeline
)
}
...
@@ -187,6 +196,10 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -187,6 +196,10 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
end
context
'when job has artifacts'
do
context
'when job has artifacts'
do
before
do
get_show_json
end
context
'with not expiry date'
do
context
'with not expiry date'
do
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
)
}
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
)
}
...
@@ -218,6 +231,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -218,6 +231,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
)
}
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
)
}
it
'exposes empty state illustrations'
do
it
'exposes empty state illustrations'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'status'
][
'illustration'
]).
to
have_key
(
'image'
)
expect
(
json_response
[
'status'
][
'illustration'
]).
to
have_key
(
'image'
)
...
@@ -230,6 +245,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -230,6 +245,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
let
(
:job
)
{
create
(
:ci_build
,
:success
,
pipeline:
pipeline
)
}
let
(
:job
)
{
create
(
:ci_build
,
:success
,
pipeline:
pipeline
)
}
it
'does not exposes the deployment information'
do
it
'does not exposes the deployment information'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'deployment_status'
]).
to
be_nil
expect
(
json_response
[
'deployment_status'
]).
to
be_nil
end
end
...
@@ -241,6 +258,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -241,6 +258,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
let
(
:job
)
{
create
(
:ci_build
,
:running
,
environment:
environment
.
name
,
pipeline:
pipeline
)
}
let
(
:job
)
{
create
(
:ci_build
,
:running
,
environment:
environment
.
name
,
pipeline:
pipeline
)
}
it
'exposes the deployment information'
do
it
'exposes the deployment information'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
match_schema
(
'job/job_details'
)
expect
(
json_response
).
to
match_schema
(
'job/job_details'
)
expect
(
json_response
[
'deployment_status'
][
"status"
]).
to
eq
'creating'
expect
(
json_response
[
'deployment_status'
][
"status"
]).
to
eq
'creating'
...
@@ -256,11 +275,11 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -256,11 +275,11 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
before
do
before
do
project
.
add_maintainer
(
user
)
project
.
add_maintainer
(
user
)
sign_in
(
user
)
sign_in
(
user
)
get_show
(
id:
job
.
id
,
format: :json
)
end
end
it
'user can edit runner'
do
it
'user can edit runner'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'runner'
]).
to
have_key
(
'edit_path'
)
expect
(
json_response
[
'runner'
]).
to
have_key
(
'edit_path'
)
...
@@ -276,11 +295,11 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -276,11 +295,11 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
before
do
before
do
project
.
add_maintainer
(
user
)
project
.
add_maintainer
(
user
)
sign_in
(
user
)
sign_in
(
user
)
get_show
(
id:
job
.
id
,
format: :json
)
end
end
it
'user can not edit runner'
do
it
'user can not edit runner'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'runner'
]).
not_to
have_key
(
'edit_path'
)
expect
(
json_response
[
'runner'
]).
not_to
have_key
(
'edit_path'
)
...
@@ -295,11 +314,11 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -295,11 +314,11 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
before
do
before
do
project
.
add_maintainer
(
user
)
project
.
add_maintainer
(
user
)
sign_in
(
user
)
sign_in
(
user
)
get_show
(
id:
job
.
id
,
format: :json
)
end
end
it
'user can not edit runner'
do
it
'user can not edit runner'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'runner'
]).
not_to
have_key
(
'edit_path'
)
expect
(
json_response
[
'runner'
]).
not_to
have_key
(
'edit_path'
)
...
@@ -312,6 +331,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -312,6 +331,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
let
(
:job
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
,
runner:
runner
)
}
let
(
:job
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
,
runner:
runner
)
}
it
'exposes needed information'
do
it
'exposes needed information'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'runners'
][
'online'
]).
to
be
false
expect
(
json_response
[
'runners'
][
'online'
]).
to
be
false
...
@@ -325,6 +346,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -325,6 +346,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
let
(
:job
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
,
runner:
runner
)
}
let
(
:job
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
,
runner:
runner
)
}
it
'exposes needed information'
do
it
'exposes needed information'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'runners'
][
'online'
]).
to
be
false
expect
(
json_response
[
'runners'
][
'online'
]).
to
be
false
...
@@ -334,6 +357,10 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -334,6 +357,10 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
end
context
'settings_path'
do
context
'settings_path'
do
before
do
get_show_json
end
context
'when user is developer'
do
context
'when user is developer'
do
it
'settings_path is not available'
do
it
'settings_path is not available'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
...
@@ -360,6 +387,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -360,6 +387,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
context
'when no trace is available'
do
context
'when no trace is available'
do
it
'has_trace is false'
do
it
'has_trace is false'
do
get_show_json
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'has_trace'
]).
to
be
false
expect
(
json_response
[
'has_trace'
]).
to
be
false
end
end
...
@@ -369,17 +398,21 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -369,17 +398,21 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
let
(
:job
)
{
create
(
:ci_build
,
:running
,
:trace_live
,
pipeline:
pipeline
)
}
let
(
:job
)
{
create
(
:ci_build
,
:running
,
:trace_live
,
pipeline:
pipeline
)
}
it
"has_trace is true"
do
it
"has_trace is true"
do
get_show_json
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'has_trace'
]).
to
be
true
expect
(
json_response
[
'has_trace'
]).
to
be
true
end
end
end
end
it
'exposes the stage the job belongs to'
do
it
'exposes the stage the job belongs to'
do
get_show_json
expect
(
json_response
[
'stage'
]).
to
eq
(
'test'
)
expect
(
json_response
[
'stage'
]).
to
eq
(
'test'
)
end
end
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!
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
let
(
:trigger
)
{
create
(
:ci_trigger
,
project:
project
)
}
let
(
:trigger
)
{
create
(
:ci_trigger
,
project:
project
)
}
let
(
:trigger_request
)
{
create
(
:ci_trigger_request
,
pipeline:
pipeline
,
trigger:
trigger
)
}
let
(
:trigger_request
)
{
create
(
:ci_trigger_request
,
pipeline:
pipeline
,
trigger:
trigger
)
}
...
@@ -389,15 +422,15 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -389,15 +422,15 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
project
.
add_developer
(
user
)
project
.
add_developer
(
user
)
sign_in
(
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
end
context
'with no variables'
do
context
'with no variables'
do
before
do
get_show
(
id:
job
.
id
,
format: :json
)
end
it
'exposes trigger information'
do
it
'exposes trigger information'
do
get_show_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'trigger'
][
'short_token'
]).
to
eq
'toke'
expect
(
json_response
[
'trigger'
][
'short_token'
]).
to
eq
'toke'
...
@@ -414,7 +447,7 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -414,7 +447,7 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
before
do
before
do
project
.
add_maintainer
(
user
)
project
.
add_maintainer
(
user
)
get_show
(
id:
job
.
id
,
format: :json
)
get_show
_json
end
end
it
'returns a job_detail'
do
it
'returns a job_detail'
do
...
@@ -438,7 +471,7 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -438,7 +471,7 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
context
'user is not a mantainer'
do
context
'user is not a mantainer'
do
before
do
before
do
get_show
(
id:
job
.
id
,
format: :json
)
get_show
_json
end
end
it
'returns a job_detail'
do
it
'returns a job_detail'
do
...
@@ -462,6 +495,13 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -462,6 +495,13 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
end
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
)
def
get_show
(
**
extra_params
)
params
=
{
params
=
{
namespace_id:
project
.
namespace
.
to_param
,
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