2017-01-20 08:32:32 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 10:24:02 -04:00
|
|
|
describe Ci::UpdateBuildQueueService do
|
2017-03-27 17:14:01 -04:00
|
|
|
let(:project) { create(:project, :repository) }
|
2017-01-20 08:32:32 -05:00
|
|
|
let(:build) { create(:ci_build, pipeline: pipeline) }
|
|
|
|
let(:pipeline) { create(:ci_pipeline, project: project) }
|
|
|
|
|
|
|
|
context 'when updating specific runners' do
|
2018-05-23 07:23:49 -04:00
|
|
|
let(:runner) { create(:ci_runner, :project, projects: [project]) }
|
2017-01-20 08:32:32 -05:00
|
|
|
|
2017-10-04 11:37:05 -04:00
|
|
|
context 'when there is a runner that can pick build' do
|
2017-01-20 08:32:32 -05:00
|
|
|
it 'ticks runner queue value' do
|
2017-10-04 11:37:05 -04:00
|
|
|
expect { subject.execute(build) }.to change { runner.ensure_runner_queue_value }
|
2017-01-20 08:32:32 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-04 11:37:05 -04:00
|
|
|
context 'when there is no runner that can pick build' do
|
2018-05-27 07:43:05 -04:00
|
|
|
let(:another_project) { create(:project) }
|
|
|
|
let(:runner) { create(:ci_runner, :project, projects: [another_project]) }
|
|
|
|
|
2017-01-20 08:32:32 -05:00
|
|
|
it 'does not tick runner queue value' do
|
2017-10-04 11:37:05 -04:00
|
|
|
expect { subject.execute(build) }.not_to change { runner.ensure_runner_queue_value }
|
2017-01-20 08:32:32 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when updating shared runners' do
|
2018-05-11 06:03:40 -04:00
|
|
|
let(:runner) { create(:ci_runner, :instance) }
|
2017-01-20 08:32:32 -05:00
|
|
|
|
2017-10-04 11:37:05 -04:00
|
|
|
context 'when there is no runner that can pick build' do
|
2017-01-20 08:32:32 -05:00
|
|
|
it 'ticks runner queue value' do
|
2017-10-04 11:37:05 -04:00
|
|
|
expect { subject.execute(build) }.to change { runner.ensure_runner_queue_value }
|
2017-01-20 08:32:32 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-04 11:37:05 -04:00
|
|
|
context 'when there is no runner that can pick build due to tag mismatch' do
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
|
|
|
build.tag_list = [:docker]
|
|
|
|
end
|
2017-01-20 08:32:32 -05:00
|
|
|
|
|
|
|
it 'does not tick runner queue value' do
|
2017-10-04 11:37:05 -04:00
|
|
|
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
|
2018-05-11 06:03:40 -04:00
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:project) { create(:project, group: group) }
|
|
|
|
let(:runner) { create(:ci_runner, :group, groups: [group]) }
|
2017-10-04 11:37:05 -04:00
|
|
|
|
|
|
|
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 }
|
2017-01-20 08:32:32 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|