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,11 +7,19 @@ module Ci
|
||||||
end
|
end
|
||||||
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 build.project.shared_runners_enabled?
|
||||||
if runner.can_pick?(build)
|
Ci::Runner.shared.each do |runner|
|
||||||
runner.tick_runner_queue
|
if runner.can_pick?(build)
|
||||||
|
runner.tick_runner_queue
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,21 +8,19 @@ describe Ci::UpdateBuildQueueService do
|
||||||
context 'when updating specific runners' do
|
context 'when updating specific runners' do
|
||||||
let(:runner) { create(:ci_runner) }
|
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
|
before do
|
||||||
build.project.runners << runner
|
build.project.runners << runner
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'ticks runner queue value' do
|
it 'ticks runner queue value' do
|
||||||
expect { subject.execute(build) }
|
expect { subject.execute(build) }.to change { runner.ensure_runner_queue_value }
|
||||||
.to change { runner.ensure_runner_queue_value }
|
|
||||||
end
|
end
|
||||||
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
|
it 'does not tick runner queue value' do
|
||||||
expect { subject.execute(build) }
|
expect { subject.execute(build) }.not_to change { runner.ensure_runner_queue_value }
|
||||||
.not_to change { runner.ensure_runner_queue_value }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -30,21 +28,61 @@ describe Ci::UpdateBuildQueueService do
|
||||||
context 'when updating shared runners' do
|
context 'when updating shared runners' do
|
||||||
let(:runner) { create(:ci_runner, :shared) }
|
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
|
it 'ticks runner queue value' do
|
||||||
expect { subject.execute(build) }
|
expect { subject.execute(build) }.to change { runner.ensure_runner_queue_value }
|
||||||
.to change { runner.ensure_runner_queue_value }
|
|
||||||
end
|
end
|
||||||
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
|
before do
|
||||||
build.tag_list = [:docker]
|
build.tag_list = [:docker]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not tick runner queue value' do
|
it 'does not tick runner queue value' do
|
||||||
expect { subject.execute(build) }
|
expect { subject.execute(build) }.not_to change { runner.ensure_runner_queue_value }
|
||||||
.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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue