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
c9355dd0
Commit
c9355dd0
authored
Apr 21, 2021
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test the Job and Pipeline duration fields
parent
dbae65fc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
2 deletions
+57
-2
spec/graphql/types/ci/pipeline_type_spec.rb
spec/graphql/types/ci/pipeline_type_spec.rb
+2
-1
spec/requests/api/graphql/ci/job_spec.rb
spec/requests/api/graphql/ci/job_spec.rb
+12
-1
spec/requests/api/graphql/ci/pipelines_spec.rb
spec/requests/api/graphql/ci/pipelines_spec.rb
+43
-0
No files found.
spec/graphql/types/ci/pipeline_type_spec.rb
View file @
c9355dd0
...
...
@@ -9,7 +9,8 @@ RSpec.describe Types::Ci::PipelineType do
it
'contains attributes related to a pipeline'
do
expected_fields
=
%w[
id iid sha before_sha status detailed_status config_source duration
id iid sha before_sha status detailed_status config_source
duration queued_duration
coverage created_at updated_at started_at finished_at committed_at
stages user retryable cancelable jobs source_job job downstream
upstream path project active user_permissions warnings commit_path uses_needs
...
...
spec/requests/api/graphql/ci/job_spec.rb
View file @
c9355dd0
...
...
@@ -5,6 +5,10 @@ require 'spec_helper'
RSpec
.
describe
'Query.project(fullPath).pipelines.job(id)'
do
include
GraphqlHelpers
around
do
|
example
|
travel_to
(
Time
.
current
)
{
example
.
run
}
end
let_it_be
(
:user
)
{
create_default
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
:public
)
}
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
...
...
@@ -35,13 +39,20 @@ RSpec.describe 'Query.project(fullPath).pipelines.job(id)' do
let
(
:terminal_type
)
{
'CiJob'
}
it
'retrieves scalar fields'
do
job_2
.
update!
(
created_at:
40
.
seconds
.
ago
,
queued_at:
32
.
seconds
.
ago
,
started_at:
30
.
seconds
.
ago
,
finished_at:
5
.
seconds
.
ago
)
post_graphql
(
query
,
current_user:
user
)
expect
(
graphql_data_at
(
*
path
)).
to
match
a_hash_including
(
'id'
=>
global_id_of
(
job_2
),
'name'
=>
job_2
.
name
,
'allowFailure'
=>
job_2
.
allow_failure
,
'duration'
=>
job_2
.
duration
,
'duration'
=>
25
,
'queuedDuration'
=>
2.0
,
'status'
=>
job_2
.
status
.
upcase
)
end
...
...
spec/requests/api/graphql/ci/pipelines_spec.rb
View file @
c9355dd0
...
...
@@ -8,6 +8,49 @@ RSpec.describe 'Query.project(fullPath).pipelines' do
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
:public
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
around
do
|
example
|
travel_to
(
Time
.
current
)
{
example
.
run
}
end
describe
'duration fields'
do
let_it_be
(
:pipeline
)
do
create
(
:ci_pipeline
,
project:
project
)
end
let
(
:query_path
)
do
[
[
:project
,
{
full_path:
project
.
full_path
}],
[
:pipelines
],
[
:nodes
]
]
end
let
(
:query
)
do
wrap_fields
(
query_graphql_path
(
query_path
,
'queuedDuration duration'
))
end
before
do
pipeline
.
update!
(
created_at:
1
.
minute
.
ago
,
started_at:
55
.
seconds
.
ago
)
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
started_at:
55
.
seconds
.
ago
,
finished_at:
10
.
seconds
.
ago
)
pipeline
.
update_duration
pipeline
.
save!
post_graphql
(
query
,
current_user:
user
)
end
it
'includes the duration fields'
do
path
=
query_path
.
map
(
&
:first
)
expect
(
graphql_data_at
(
*
path
,
:queued_duration
)).
to
eq
[
5.0
]
expect
(
graphql_data_at
(
*
path
,
:duration
)).
to
eq
[
45
]
end
end
describe
'.jobs'
do
let
(
:first_n
)
{
var
(
'Int'
)
}
let
(
:query_path
)
do
...
...
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