select group runners also in build queue service

This commit is contained in:
Alexis Reigel 2017-10-04 17:37:05 +02:00
parent 8d61d33d37
commit d8675bd45f
No known key found for this signature in database
GPG key ID: 55ADA7C7B683B329
2 changed files with 62 additions and 16 deletions

View file

@ -7,11 +7,19 @@ 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
Ci::Runner.shared.each do |runner|
if runner.can_pick?(build)
runner.tick_runner_queue
if build.project.shared_runners_enabled?
Ci::Runner.shared.each do |runner|
if runner.can_pick?(build)
runner.tick_runner_queue
end
end
end
end

View file

@ -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