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
9004b29d
Commit
9004b29d
authored
Jun 18, 2021
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move builds queue builder into a service class
parent
ea40cf76
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
262 additions
and
270 deletions
+262
-270
app/services/ci/build_queue_service.rb
app/services/ci/build_queue_service.rb
+187
-0
app/services/ci/register_job_service.rb
app/services/ci/register_job_service.rb
+2
-2
ee/app/services/ee/ci/build_queue_service.rb
ee/app/services/ee/ci/build_queue_service.rb
+64
-0
ee/lib/ee/gitlab/ci/queue/builder.rb
ee/lib/ee/gitlab/ci/queue/builder.rb
+0
-68
lib/gitlab/ci/queue/builder.rb
lib/gitlab/ci/queue/builder.rb
+0
-191
spec/services/ci/register_job_service_spec.rb
spec/services/ci/register_job_service_spec.rb
+9
-9
No files found.
app/services/ci/build_queue_service.rb
0 → 100644
View file @
9004b29d
# frozen_string_literal: true
module
Ci
class
BuildQueueService
<
SimpleDelegator
attr_reader
:runner
def
initialize
(
runner
)
@runner
=
runner
@strategy
=
begin
if
::
Feature
.
enabled?
(
:ci_pending_builds_queue_source
,
runner
,
default_enabled: :yaml
)
PendingBuildsTableStrategy
.
new
(
runner
)
else
BuildsTableStrategy
.
new
(
runner
)
end
end
super
(
@strategy
)
end
##
# This is overridden in EE
#
def
builds_for_shared_runner
@strategy
.
builds_for_shared_runner
end
# rubocop:disable CodeReuse/ActiveRecord
def
builds_for_group_runner
# Workaround for weird Rails bug, that makes `runner.groups.to_sql` to return `runner_id = NULL`
groups
=
::
Group
.
joins
(
:runner_namespaces
).
merge
(
runner
.
runner_namespaces
)
hierarchy_groups
=
Gitlab
::
ObjectHierarchy
.
new
(
groups
,
options:
{
use_distinct:
::
Feature
.
enabled?
(
:use_distinct_in_register_job_object_hierarchy
)
})
.
base_and_descendants
projects
=
Project
.
where
(
namespace_id:
hierarchy_groups
)
.
with_group_runners_enabled
.
with_builds_enabled
.
without_deleted
relation
=
@strategy
.
new_builds
.
where
(
project:
projects
)
@strategy
.
order
(
relation
)
end
def
builds_for_project_runner
relation
=
@strategy
.
new_builds
.
where
(
project:
runner
.
projects
.
without_deleted
.
with_builds_enabled
)
@strategy
.
order
(
relation
)
end
def
builds_queued_before
(
relation
,
time
)
relation
.
queued_before
(
time
)
end
def
builds_for_protected_runner
(
relation
)
relation
.
ref_protected
end
class
BuildsTableStrategy
attr_reader
:runner
,
:common
def
initialize
(
runner
)
@runner
=
runner
end
def
builds_for_shared_runner
relation
=
new_builds
# don't run projects which have not enabled shared runners and builds
.
joins
(
'INNER JOIN projects ON ci_builds.project_id = projects.id'
)
.
where
(
projects:
{
shared_runners_enabled:
true
,
pending_delete:
false
})
.
joins
(
'LEFT JOIN project_features ON ci_builds.project_id = project_features.project_id'
)
.
where
(
'project_features.builds_access_level IS NULL or project_features.builds_access_level > 0'
)
if
Feature
.
enabled?
(
:ci_queueing_disaster_recovery
,
runner
,
type: :ops
,
default_enabled: :yaml
)
# if disaster recovery is enabled, we fallback to FIFO scheduling
relation
.
order
(
'ci_builds.id ASC'
)
else
# Implement fair scheduling
# this returns builds that are ordered by number of running builds
# we prefer projects that don't use shared runners at all
relation
.
joins
(
"LEFT JOIN (
#{
running_builds_for_shared_runners
.
to_sql
}
) AS project_builds ON ci_builds.project_id = project_builds.project_id"
)
.
order
(
Arel
.
sql
(
'COALESCE(project_builds.running_builds, 0) ASC'
),
'ci_builds.id ASC'
)
end
end
def
builds_matching_tag_ids
(
relation
,
ids
)
# pick builds that does not have other tags than runner's one
relation
.
matches_tag_ids
(
ids
)
end
def
builds_with_any_tags
(
relation
)
# pick builds that have at least one tag
relation
.
with_any_tags
end
def
order
(
relation
)
relation
.
order
(
'id ASC'
)
end
def
new_builds
::
Ci
::
Build
.
pending
.
unstarted
end
def
execute
(
relation
)
relation
.
pluck
(
:id
)
end
private
def
running_builds_for_shared_runners
::
Ci
::
Build
.
running
.
where
(
runner:
::
Ci
::
Runner
.
instance_type
)
.
group
(
:project_id
)
.
select
(
:project_id
,
'COUNT(*) AS running_builds'
)
end
end
class
PendingBuildsTableStrategy
attr_reader
:runner
def
initialize
(
runner
)
@runner
=
runner
end
def
builds_for_shared_runner
relation
=
new_builds
# don't run projects which have not enabled shared runners and builds
.
joins
(
'INNER JOIN projects ON ci_pending_builds.project_id = projects.id'
)
.
where
(
projects:
{
shared_runners_enabled:
true
,
pending_delete:
false
})
.
joins
(
'LEFT JOIN project_features ON ci_pending_builds.project_id = project_features.project_id'
)
.
where
(
'project_features.builds_access_level IS NULL or project_features.builds_access_level > 0'
)
if
Feature
.
enabled?
(
:ci_queueing_disaster_recovery
,
runner
,
type: :ops
,
default_enabled: :yaml
)
# if disaster recovery is enabled, we fallback to FIFO scheduling
relation
.
order
(
'ci_pending_builds.build_id ASC'
)
else
# Implement fair scheduling
# this returns builds that are ordered by number of running builds
# we prefer projects that don't use shared runners at all
relation
.
joins
(
"LEFT JOIN (
#{
running_builds_for_shared_runners
.
to_sql
}
) AS project_builds ON ci_pending_builds.project_id=project_builds.project_id"
)
.
order
(
Arel
.
sql
(
'COALESCE(project_builds.running_builds, 0) ASC'
),
'ci_pending_builds.build_id ASC'
)
end
end
def
builds_matching_tag_ids
(
relation
,
ids
)
relation
.
merge
(
CommitStatus
.
matches_tag_ids
(
ids
,
on:
'ci_pending_builds.build_id'
))
end
def
builds_with_any_tags
(
relation
)
relation
.
merge
(
CommitStatus
.
with_any_tags
(
on:
'ci_pending_builds.build_id'
))
end
def
builds_queued_before
(
relation
,
time
)
relation
.
queued_before
(
time
)
end
def
order
(
relation
)
relation
.
order
(
'build_id ASC'
)
end
def
new_builds
::
Ci
::
PendingBuild
.
all
end
def
execute
(
relation
)
relation
.
pluck
(
:build_id
)
end
private
def
running_builds_for_shared_runners
::
Ci
::
RunningBuild
.
instance_type
.
group
(
:project_id
)
.
select
(
:project_id
,
'COUNT(*) AS running_builds'
)
end
# rubocop:enable CodeReuse/ActiveRecord
end
end
end
Ci
::
BuildQueueService
.
prepend_mod_with
(
'Ci::BuildQueueService'
)
app/services/ci/register_job_service.rb
View file @
9004b29d
...
@@ -103,7 +103,7 @@ module Ci
...
@@ -103,7 +103,7 @@ module Ci
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
each_build
(
params
,
&
blk
)
def
each_build
(
params
,
&
blk
)
queue
=
::
Gitlab
::
Ci
::
Queue
::
Builder
.
new
(
runner
)
queue
=
::
Ci
::
BuildQueueService
.
new
(
runner
)
builds
=
begin
builds
=
begin
if
runner
.
instance_type?
if
runner
.
instance_type?
...
@@ -132,7 +132,7 @@ module Ci
...
@@ -132,7 +132,7 @@ module Ci
builds
=
queue
.
builds_queued_before
(
builds
,
params
[
:job_age
].
seconds
.
ago
)
builds
=
queue
.
builds_queued_before
(
builds
,
params
[
:job_age
].
seconds
.
ago
)
end
end
build_ids
=
retrieve_queue
(
->
{
queue
.
build_ids
(
builds
)
})
build_ids
=
retrieve_queue
(
->
{
queue
.
execute
(
builds
)
})
@metrics
.
observe_queue_size
(
->
{
build_ids
.
size
},
@runner
.
runner_type
)
@metrics
.
observe_queue_size
(
->
{
build_ids
.
size
},
@runner
.
runner_type
)
...
...
ee/app/services/ee/ci/build_queue_service.rb
0 → 100644
View file @
9004b29d
# frozen_string_literal: true
module
EE
module
Ci
module
BuildQueueService
extend
ActiveSupport
::
Concern
extend
::
Gitlab
::
Utils
::
Override
override
:builds_for_shared_runner
def
builds_for_shared_runner
# if disaster recovery is enabled, we disable quota
if
::
Feature
.
enabled?
(
:ci_queueing_disaster_recovery
,
runner
,
type: :ops
,
default_enabled: :yaml
)
super
else
enforce_minutes_based_on_cost_factors
(
super
)
end
end
# rubocop: disable CodeReuse/ActiveRecord
def
enforce_minutes_based_on_cost_factors
(
relation
)
visibility_relation
=
::
CommitStatus
.
where
(
projects:
{
visibility_level:
runner
.
visibility_levels_without_minutes_quota
})
enforce_limits_relation
=
::
CommitStatus
.
where
(
'EXISTS (?)'
,
builds_check_limit
)
relation
.
merge
(
visibility_relation
.
or
(
enforce_limits_relation
))
end
def
builds_check_limit
all_namespaces
.
joins
(
'LEFT JOIN namespace_statistics ON namespace_statistics.namespace_id = namespaces.id'
)
.
where
(
'COALESCE(namespaces.shared_runners_minutes_limit, ?, 0) = 0 OR '
\
'COALESCE(namespace_statistics.shared_runners_seconds, 0) < '
\
'COALESCE('
\
'(namespaces.shared_runners_minutes_limit + COALESCE(namespaces.extra_shared_runners_minutes_limit, 0)), '
\
'(? + COALESCE(namespaces.extra_shared_runners_minutes_limit, 0)), '
\
'0) * 60'
,
application_shared_runners_minutes
,
application_shared_runners_minutes
)
.
select
(
'1'
)
end
def
all_namespaces
if
traversal_ids_enabled?
::
Namespace
.
where
(
'namespaces.id = project_namespaces.traversal_ids[1]'
)
.
joins
(
'INNER JOIN namespaces as project_namespaces ON project_namespaces.id = projects.namespace_id'
)
else
namespaces
=
::
Namespace
.
reorder
(
nil
).
where
(
'namespaces.id = projects.namespace_id'
)
::
Gitlab
::
ObjectHierarchy
.
new
(
namespaces
,
options:
{
skip_ordering:
true
}).
roots
end
end
# rubocop: enable CodeReuse/ActiveRecord
def
application_shared_runners_minutes
::
Gitlab
::
CurrentSettings
.
shared_runners_minutes
end
def
traversal_ids_enabled?
::
Feature
.
enabled?
(
:sync_traversal_ids
,
default_enabled: :yaml
)
&&
::
Feature
.
enabled?
(
:traversal_ids_for_quota_calculation
,
type: :development
,
default_enabled: :yaml
)
end
end
end
end
ee/lib/ee/gitlab/ci/queue/builder.rb
deleted
100644 → 0
View file @
ea40cf76
# frozen_string_literal: true
module
EE
module
Gitlab
module
Ci
module
Queue
module
Builder
extend
ActiveSupport
::
Concern
extend
::
Gitlab
::
Utils
::
Override
override
:builds_for_shared_runner
def
builds_for_shared_runner
# if disaster recovery is enabled, we disable quota
if
::
Feature
.
enabled?
(
:ci_queueing_disaster_recovery
,
runner
,
type: :ops
,
default_enabled: :yaml
)
super
else
enforce_minutes_based_on_cost_factors
(
super
)
end
end
# rubocop: disable CodeReuse/ActiveRecord
def
enforce_minutes_based_on_cost_factors
(
relation
)
visibility_relation
=
::
CommitStatus
.
where
(
projects:
{
visibility_level:
runner
.
visibility_levels_without_minutes_quota
})
enforce_limits_relation
=
::
CommitStatus
.
where
(
'EXISTS (?)'
,
builds_check_limit
)
relation
.
merge
(
visibility_relation
.
or
(
enforce_limits_relation
))
end
def
builds_check_limit
all_namespaces
.
joins
(
'LEFT JOIN namespace_statistics ON namespace_statistics.namespace_id = namespaces.id'
)
.
where
(
'COALESCE(namespaces.shared_runners_minutes_limit, ?, 0) = 0 OR '
\
'COALESCE(namespace_statistics.shared_runners_seconds, 0) < '
\
'COALESCE('
\
'(namespaces.shared_runners_minutes_limit + COALESCE(namespaces.extra_shared_runners_minutes_limit, 0)), '
\
'(? + COALESCE(namespaces.extra_shared_runners_minutes_limit, 0)), '
\
'0) * 60'
,
application_shared_runners_minutes
,
application_shared_runners_minutes
)
.
select
(
'1'
)
end
def
all_namespaces
if
traversal_ids_enabled?
::
Namespace
.
where
(
'namespaces.id = project_namespaces.traversal_ids[1]'
)
.
joins
(
'INNER JOIN namespaces as project_namespaces ON project_namespaces.id = projects.namespace_id'
)
else
namespaces
=
::
Namespace
.
reorder
(
nil
).
where
(
'namespaces.id = projects.namespace_id'
)
::
Gitlab
::
ObjectHierarchy
.
new
(
namespaces
,
options:
{
skip_ordering:
true
}).
roots
end
end
# rubocop: enable CodeReuse/ActiveRecord
def
application_shared_runners_minutes
::
Gitlab
::
CurrentSettings
.
shared_runners_minutes
end
def
traversal_ids_enabled?
::
Feature
.
enabled?
(
:sync_traversal_ids
,
default_enabled: :yaml
)
&&
::
Feature
.
enabled?
(
:traversal_ids_for_quota_calculation
,
type: :development
,
default_enabled: :yaml
)
end
end
end
end
end
end
lib/gitlab/ci/queue/builder.rb
deleted
100644 → 0
View file @
ea40cf76
# frozen_string_literal: true
module
Gitlab
module
Ci
module
Queue
class
Builder
<
SimpleDelegator
attr_reader
:runner
def
initialize
(
runner
)
@runner
=
runner
@strategy
=
begin
if
::
Feature
.
enabled?
(
:ci_pending_builds_queue_source
,
runner
,
default_enabled: :yaml
)
PendingBuildsTableStrategy
.
new
(
runner
)
else
BuildsTableStrategy
.
new
(
runner
)
end
end
super
(
@strategy
)
end
##
# This is overridden in EE
#
def
builds_for_shared_runner
@strategy
.
builds_for_shared_runner
end
# rubocop:disable CodeReuse/ActiveRecord
def
builds_for_group_runner
# Workaround for weird Rails bug, that makes `runner.groups.to_sql` to return `runner_id = NULL`
groups
=
::
Group
.
joins
(
:runner_namespaces
).
merge
(
runner
.
runner_namespaces
)
hierarchy_groups
=
Gitlab
::
ObjectHierarchy
.
new
(
groups
,
options:
{
use_distinct:
::
Feature
.
enabled?
(
:use_distinct_in_register_job_object_hierarchy
)
})
.
base_and_descendants
projects
=
Project
.
where
(
namespace_id:
hierarchy_groups
)
.
with_group_runners_enabled
.
with_builds_enabled
.
without_deleted
relation
=
@strategy
.
new_builds
.
where
(
project:
projects
)
@strategy
.
order
(
relation
)
end
def
builds_for_project_runner
relation
=
@strategy
.
new_builds
.
where
(
project:
runner
.
projects
.
without_deleted
.
with_builds_enabled
)
@strategy
.
order
(
relation
)
end
def
builds_queued_before
(
relation
,
time
)
relation
.
queued_before
(
time
)
end
def
builds_for_protected_runner
(
relation
)
relation
.
ref_protected
end
class
BuildsTableStrategy
attr_reader
:runner
,
:common
def
initialize
(
runner
)
@runner
=
runner
end
def
builds_for_shared_runner
relation
=
new_builds
# don't run projects which have not enabled shared runners and builds
.
joins
(
'INNER JOIN projects ON ci_builds.project_id = projects.id'
)
.
where
(
projects:
{
shared_runners_enabled:
true
,
pending_delete:
false
})
.
joins
(
'LEFT JOIN project_features ON ci_builds.project_id = project_features.project_id'
)
.
where
(
'project_features.builds_access_level IS NULL or project_features.builds_access_level > 0'
)
if
Feature
.
enabled?
(
:ci_queueing_disaster_recovery
,
runner
,
type: :ops
,
default_enabled: :yaml
)
# if disaster recovery is enabled, we fallback to FIFO scheduling
relation
.
order
(
'ci_builds.id ASC'
)
else
# Implement fair scheduling
# this returns builds that are ordered by number of running builds
# we prefer projects that don't use shared runners at all
relation
.
joins
(
"LEFT JOIN (
#{
running_builds_for_shared_runners
.
to_sql
}
) AS project_builds ON ci_builds.project_id = project_builds.project_id"
)
.
order
(
Arel
.
sql
(
'COALESCE(project_builds.running_builds, 0) ASC'
),
'ci_builds.id ASC'
)
end
end
def
builds_matching_tag_ids
(
relation
,
ids
)
# pick builds that does not have other tags than runner's one
relation
.
matches_tag_ids
(
ids
)
end
def
builds_with_any_tags
(
relation
)
# pick builds that have at least one tag
relation
.
with_any_tags
end
def
order
(
relation
)
relation
.
order
(
'id ASC'
)
end
def
build_ids
(
relation
)
relation
.
pluck
(
:id
)
end
def
new_builds
::
Ci
::
Build
.
pending
.
unstarted
end
private
def
running_builds_for_shared_runners
::
Ci
::
Build
.
running
.
where
(
runner:
::
Ci
::
Runner
.
instance_type
)
.
group
(
:project_id
)
.
select
(
:project_id
,
'COUNT(*) AS running_builds'
)
end
end
class
PendingBuildsTableStrategy
attr_reader
:runner
def
initialize
(
runner
)
@runner
=
runner
end
def
builds_for_shared_runner
relation
=
new_builds
# don't run projects which have not enabled shared runners and builds
.
joins
(
'INNER JOIN projects ON ci_pending_builds.project_id = projects.id'
)
.
where
(
projects:
{
shared_runners_enabled:
true
,
pending_delete:
false
})
.
joins
(
'LEFT JOIN project_features ON ci_pending_builds.project_id = project_features.project_id'
)
.
where
(
'project_features.builds_access_level IS NULL or project_features.builds_access_level > 0'
)
if
Feature
.
enabled?
(
:ci_queueing_disaster_recovery
,
runner
,
type: :ops
,
default_enabled: :yaml
)
# if disaster recovery is enabled, we fallback to FIFO scheduling
relation
.
order
(
'ci_pending_builds.build_id ASC'
)
else
# Implement fair scheduling
# this returns builds that are ordered by number of running builds
# we prefer projects that don't use shared runners at all
relation
.
joins
(
"LEFT JOIN (
#{
running_builds_for_shared_runners
.
to_sql
}
) AS project_builds ON ci_pending_builds.project_id=project_builds.project_id"
)
.
order
(
Arel
.
sql
(
'COALESCE(project_builds.running_builds, 0) ASC'
),
'ci_pending_builds.build_id ASC'
)
end
end
def
builds_matching_tag_ids
(
relation
,
ids
)
relation
.
merge
(
CommitStatus
.
matches_tag_ids
(
ids
,
on:
'ci_pending_builds.build_id'
))
end
def
builds_with_any_tags
(
relation
)
relation
.
merge
(
CommitStatus
.
with_any_tags
(
on:
'ci_pending_builds.build_id'
))
end
def
builds_queued_before
(
relation
,
time
)
relation
.
queued_before
(
time
)
end
def
order
(
relation
)
relation
.
order
(
'build_id ASC'
)
end
def
build_ids
(
relation
)
relation
.
pluck
(
:build_id
)
end
def
new_builds
::
Ci
::
PendingBuild
.
all
end
private
def
running_builds_for_shared_runners
::
Ci
::
RunningBuild
.
instance_type
.
group
(
:project_id
)
.
select
(
:project_id
,
'COUNT(*) AS running_builds'
)
end
# rubocop:enable CodeReuse/ActiveRecord
end
end
end
end
end
Gitlab
::
Ci
::
Queue
::
Builder
.
prepend_mod_with
(
'Gitlab::Ci::Queue::Builder'
)
spec/services/ci/register_job_service_spec.rb
View file @
9004b29d
...
@@ -269,7 +269,7 @@ module Ci
...
@@ -269,7 +269,7 @@ module Ci
let!
(
:unrelated_group_runner
)
{
create
(
:ci_runner
,
:group
,
groups:
[
unrelated_group
])
}
let!
(
:unrelated_group_runner
)
{
create
(
:ci_runner
,
:group
,
groups:
[
unrelated_group
])
}
it
'does not consider builds from other group runners'
do
it
'does not consider builds from other group runners'
do
queue
=
::
Gitlab
::
Ci
::
Queue
::
Builder
.
new
(
group_runner
)
queue
=
::
Ci
::
BuildQueueService
.
new
(
group_runner
)
expect
(
queue
.
builds_for_group_runner
.
size
).
to
eq
6
expect
(
queue
.
builds_for_group_runner
.
size
).
to
eq
6
execute
(
group_runner
)
execute
(
group_runner
)
...
@@ -301,7 +301,7 @@ module Ci
...
@@ -301,7 +301,7 @@ module Ci
end
end
it
'calls DISTINCT'
do
it
'calls DISTINCT'
do
queue
=
::
Gitlab
::
Ci
::
Queue
::
Builder
.
new
(
group_runner
)
queue
=
::
Ci
::
BuildQueueService
.
new
(
group_runner
)
expect
(
queue
.
builds_for_group_runner
.
to_sql
).
to
include
(
"DISTINCT"
)
expect
(
queue
.
builds_for_group_runner
.
to_sql
).
to
include
(
"DISTINCT"
)
end
end
...
@@ -314,7 +314,7 @@ module Ci
...
@@ -314,7 +314,7 @@ module Ci
end
end
it
'does not call DISTINCT'
do
it
'does not call DISTINCT'
do
queue
=
::
Gitlab
::
Ci
::
Queue
::
Builder
.
new
(
group_runner
)
queue
=
::
Ci
::
BuildQueueService
.
new
(
group_runner
)
expect
(
queue
.
builds_for_group_runner
.
to_sql
).
not_to
include
(
"DISTINCT"
)
expect
(
queue
.
builds_for_group_runner
.
to_sql
).
not_to
include
(
"DISTINCT"
)
end
end
...
@@ -355,8 +355,8 @@ module Ci
...
@@ -355,8 +355,8 @@ module Ci
let!
(
:other_build
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
)
}
let!
(
:other_build
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
)
}
before
do
before
do
allow_any_instance_of
(
::
Gitlab
::
Ci
::
Queue
::
Builder
)
allow_any_instance_of
(
::
Ci
::
BuildQueueService
)
.
to
receive
(
:
build_ids
)
.
to
receive
(
:
execute
)
.
and_return
(
Ci
::
Build
.
where
(
id:
[
pending_job
,
other_build
]).
pluck
(
:id
))
.
and_return
(
Ci
::
Build
.
where
(
id:
[
pending_job
,
other_build
]).
pluck
(
:id
))
end
end
...
@@ -368,8 +368,8 @@ module Ci
...
@@ -368,8 +368,8 @@ module Ci
context
'when single build is in queue'
do
context
'when single build is in queue'
do
before
do
before
do
allow_any_instance_of
(
::
Gitlab
::
Ci
::
Queue
::
Builder
)
allow_any_instance_of
(
::
Ci
::
BuildQueueService
)
.
to
receive
(
:
build_ids
)
.
to
receive
(
:
execute
)
.
and_return
(
Ci
::
Build
.
where
(
id:
pending_job
).
pluck
(
:id
))
.
and_return
(
Ci
::
Build
.
where
(
id:
pending_job
).
pluck
(
:id
))
end
end
...
@@ -380,8 +380,8 @@ module Ci
...
@@ -380,8 +380,8 @@ module Ci
context
'when there is no build in queue'
do
context
'when there is no build in queue'
do
before
do
before
do
allow_any_instance_of
(
::
Gitlab
::
Ci
::
Queue
::
Builder
)
allow_any_instance_of
(
::
Ci
::
BuildQueueService
)
.
to
receive
(
:
build_ids
)
.
to
receive
(
:
execute
)
.
and_return
([])
.
and_return
([])
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