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
c3eb0319
Commit
c3eb0319
authored
Sep 16, 2021
by
Matija Čupić
Committed by
Markus Koller
Sep 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use configurable page size for jobs in stages
Changelog: fixed
parent
0c4ab31a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
63 additions
and
12 deletions
+63
-12
app/graphql/types/ci/stage_type.rb
app/graphql/types/ci/stage_type.rb
+9
-4
app/models/application_setting.rb
app/models/application_setting.rb
+4
-0
db/migrate/20210908100810_add_jobs_per_stage_page_size_to_application_settings.rb
...0_add_jobs_per_stage_page_size_to_application_settings.rb
+7
-0
db/schema_migrations/20210908100810
db/schema_migrations/20210908100810
+1
-0
db/structure.sql
db/structure.sql
+1
-0
spec/models/application_setting_spec.rb
spec/models/application_setting_spec.rb
+3
-0
spec/requests/api/graphql/ci/stages_spec.rb
spec/requests/api/graphql/ci/stages_spec.rb
+38
-8
No files found.
app/graphql/types/ci/stage_type.rb
View file @
c3eb0319
...
...
@@ -15,10 +15,8 @@ module Types
description:
'Group of jobs for the stage.'
field
:detailed_status
,
Types
::
Ci
::
DetailedStatusType
,
null:
true
,
description:
'Detailed status of the stage.'
field
:jobs
,
Ci
::
JobType
.
connection_type
,
null:
true
,
description:
'Jobs for the stage.'
,
method:
'latest_statuses'
,
max_page_size:
200
field
:jobs
,
Types
::
Ci
::
JobType
.
connection_type
,
null:
true
,
description:
'Jobs for the stage.'
field
:status
,
GraphQL
::
Types
::
String
,
null:
true
,
description:
'Status of the pipeline stage.'
...
...
@@ -49,6 +47,13 @@ module Types
end
end
def
jobs
GraphQL
::
Pagination
::
ActiveRecordRelationConnection
.
new
(
object
.
latest_statuses
,
max_page_size:
Gitlab
::
CurrentSettings
.
current_application_settings
.
jobs_per_stage_page_size
)
end
private
# rubocop: disable CodeReuse/ActiveRecord
...
...
app/models/application_setting.rb
View file @
c3eb0319
...
...
@@ -207,6 +207,10 @@ class ApplicationSetting < ApplicationRecord
numericality:
{
only_integer:
true
,
greater_than_or_equal_to:
0
,
less_than:
::
Gitlab
::
Pages
::
MAX_SIZE
/
1
.
megabyte
}
validates
:jobs_per_stage_page_size
,
presence:
true
,
numericality:
{
only_integer:
true
,
greater_than_or_equal_to:
0
}
validates
:default_artifacts_expire_in
,
presence:
true
,
duration:
true
validates
:container_expiration_policies_enable_historic_entries
,
...
...
db/migrate/20210908100810_add_jobs_per_stage_page_size_to_application_settings.rb
0 → 100644
View file @
c3eb0319
# frozen_string_literal: true
class
AddJobsPerStagePageSizeToApplicationSettings
<
Gitlab
::
Database
::
Migration
[
1.0
]
def
change
add_column
:application_settings
,
:jobs_per_stage_page_size
,
:integer
,
default:
200
,
null:
false
end
end
db/schema_migrations/20210908100810
0 → 100644
View file @
c3eb0319
06e45cf159cf1182b34e83f893bcff65e4722dded2bf4cbcf61fafd652158823
\ No newline at end of file
db/structure.sql
View file @
c3eb0319
...
...
@@ -10371,6 +10371,7 @@ CREATE TABLE application_settings (
throttle_unauthenticated_api_enabled boolean DEFAULT false NOT NULL,
throttle_unauthenticated_api_requests_per_period integer DEFAULT 3600 NOT NULL,
throttle_unauthenticated_api_period_in_seconds integer DEFAULT 3600 NOT NULL,
jobs_per_stage_page_size integer DEFAULT 200 NOT NULL,
sidekiq_job_limiter_mode smallint DEFAULT 1 NOT NULL,
sidekiq_job_limiter_compression_threshold_bytes integer DEFAULT 100000 NOT NULL,
sidekiq_job_limiter_limit_bytes integer DEFAULT 0 NOT NULL,
spec/models/application_setting_spec.rb
View file @
c3eb0319
...
...
@@ -91,6 +91,9 @@ RSpec.describe ApplicationSetting do
.
is_less_than
(
::
Gitlab
::
Pages
::
MAX_SIZE
/
1
.
megabyte
)
end
it
{
is_expected
.
to
validate_presence_of
(
:jobs_per_stage_page_size
)
}
it
{
is_expected
.
to
validate_numericality_of
(
:jobs_per_stage_page_size
).
only_integer
.
is_greater_than_or_equal_to
(
0
)
}
it
{
is_expected
.
not_to
allow_value
(
7
).
for
(
:minimum_password_length
)
}
it
{
is_expected
.
not_to
allow_value
(
129
).
for
(
:minimum_password_length
)
}
it
{
is_expected
.
not_to
allow_value
(
nil
).
for
(
:minimum_password_length
)
}
...
...
spec/requests/api/graphql/ci/stages_spec.rb
View file @
c3eb0319
...
...
@@ -4,11 +4,13 @@ require 'spec_helper'
RSpec
.
describe
'Query.project.pipeline.stages'
do
include
GraphqlHelpers
let
(
:project
)
{
create
(
:project
,
:repository
,
:public
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
user:
user
)
}
let
(
:stage_graphql_data
)
{
graphql_data
[
'project'
][
'pipeline'
][
'stages'
]
}
subject
(
:post_query
)
{
post_graphql
(
query
,
current_user:
user
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
:public
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
user:
user
)
}
let
(
:stage_nodes
)
{
graphql_data_at
(
:project
,
:pipeline
,
:stages
,
:nodes
)
}
let
(
:params
)
{
{}
}
let
(
:fields
)
do
...
...
@@ -33,14 +35,42 @@ RSpec.describe 'Query.project.pipeline.stages' do
)
end
before
do
before
_all
do
create
(
:ci_stage_entity
,
pipeline:
pipeline
,
name:
'deploy'
)
post_graphql
(
query
,
current_user:
user
)
create_list
(
:ci_build
,
2
,
pipeline:
pipeline
,
stage:
'deploy'
)
end
it_behaves_like
'a working graphql query'
it_behaves_like
'a working graphql query'
do
before
do
post_query
end
end
it
'returns the stage of a pipeline'
do
expect
(
stage_graphql_data
[
'nodes'
].
first
[
'name'
]).
to
eq
(
'deploy'
)
post_query
expect
(
stage_nodes
.
first
[
'name'
]).
to
eq
(
'deploy'
)
end
describe
'job pagination'
do
let
(
:job_nodes
)
{
graphql_dig_at
(
stage_nodes
,
:jobs
,
:nodes
)
}
it
'returns up to default limit jobs per stage'
do
post_query
expect
(
job_nodes
.
count
).
to
eq
(
2
)
end
context
'when the limit is manually set'
do
before
do
stub_application_setting
(
jobs_per_stage_page_size:
1
)
end
it
'returns up to custom limit jobs per stage'
do
post_query
expect
(
job_nodes
.
count
).
to
eq
(
1
)
end
end
end
end
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