select group runners also in build queue service
This commit is contained in:
parent
8d61d33d37
commit
d8675bd45f
2 changed files with 62 additions and 16 deletions
|
@ -7,8 +7,15 @@ module Ci
|
|||
end
|
||||
end
|
||||
|
||||
return unless build.project.shared_runners_enabled?
|
||||
if build.project.group_runners_enabled?
|
||||
Ci::Runner.belonging_to_group(build.project_id).each do |runner|
|
||||
if runner.can_pick?(build)
|
||||
runner.tick_runner_queue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if build.project.shared_runners_enabled?
|
||||
Ci::Runner.shared.each do |runner|
|
||||
if runner.can_pick?(build)
|
||||
runner.tick_runner_queue
|
||||
|
@ -16,4 +23,5 @@ module Ci
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,21 +8,19 @@ describe Ci::UpdateBuildQueueService do
|
|||
context 'when updating specific runners' do
|
||||
let(:runner) { create(:ci_runner) }
|
||||
|
||||
context 'when there are runner that can pick build' do
|
||||
context 'when there is a runner that can pick build' do
|
||||
before do
|
||||
build.project.runners << runner
|
||||
end
|
||||
|
||||
it 'ticks runner queue value' do
|
||||
expect { subject.execute(build) }
|
||||
.to change { runner.ensure_runner_queue_value }
|
||||
expect { subject.execute(build) }.to change { runner.ensure_runner_queue_value }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there are no runners that can pick build' do
|
||||
context 'when there is no runner that can pick build' do
|
||||
it 'does not tick runner queue value' do
|
||||
expect { subject.execute(build) }
|
||||
.not_to change { runner.ensure_runner_queue_value }
|
||||
expect { subject.execute(build) }.not_to change { runner.ensure_runner_queue_value }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -30,21 +28,61 @@ describe Ci::UpdateBuildQueueService do
|
|||
context 'when updating shared runners' do
|
||||
let(:runner) { create(:ci_runner, :shared) }
|
||||
|
||||
context 'when there are runner that can pick build' do
|
||||
context 'when there is no runner that can pick build' do
|
||||
it 'ticks runner queue value' do
|
||||
expect { subject.execute(build) }
|
||||
.to change { runner.ensure_runner_queue_value }
|
||||
expect { subject.execute(build) }.to change { runner.ensure_runner_queue_value }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there are no runners that can pick build' do
|
||||
context 'when there is no runner that can pick build due to tag mismatch' do
|
||||
before do
|
||||
build.tag_list = [:docker]
|
||||
end
|
||||
|
||||
it 'does not tick runner queue value' do
|
||||
expect { subject.execute(build) }
|
||||
.not_to change { runner.ensure_runner_queue_value }
|
||||
expect { subject.execute(build) }.not_to change { runner.ensure_runner_queue_value }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there is no runner that can pick build due to being disabled on project' do
|
||||
before do
|
||||
build.project.shared_runners_enabled = false
|
||||
end
|
||||
|
||||
it 'does not tick runner queue value' do
|
||||
expect { subject.execute(build) }.not_to change { runner.ensure_runner_queue_value }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when updating group runners' do
|
||||
let(:group) { create :group }
|
||||
let(:project) { create :project, group: group }
|
||||
let(:runner) { create :ci_runner, groups: [group] }
|
||||
|
||||
context 'when there is a runner that can pick build' do
|
||||
it 'ticks runner queue value' do
|
||||
expect { subject.execute(build) }.to change { runner.ensure_runner_queue_value }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there is no runner that can pick build due to tag mismatch' do
|
||||
before do
|
||||
build.tag_list = [:docker]
|
||||
end
|
||||
|
||||
it 'does not tick runner queue value' do
|
||||
expect { subject.execute(build) }.not_to change { runner.ensure_runner_queue_value }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there is no runner that can pick build due to being disabled on project' do
|
||||
before do
|
||||
build.project.group_runners_enabled = false
|
||||
end
|
||||
|
||||
it 'does not tick runner queue value' do
|
||||
expect { subject.execute(build) }.not_to change { runner.ensure_runner_queue_value }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue