Commit 5c48b88c authored by Marius Bobin's avatar Marius Bobin

Look for active and online runners when loading the matchers

Look for active and online runners when loading the matchers
parent 3168331b
...@@ -30,6 +30,8 @@ module Ci ...@@ -30,6 +30,8 @@ module Ci
def load_runners def load_runners
@instance_runners, @private_runners = project @instance_runners, @private_runners = project
.all_runners .all_runners
.active
.online
.runner_matchers .runner_matchers
.partition(&:instance_type?) .partition(&:instance_type?)
end end
......
...@@ -8,7 +8,7 @@ RSpec.describe 'Two merge requests on a merge train' do ...@@ -8,7 +8,7 @@ RSpec.describe 'Two merge requests on a merge train' do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let_it_be(:maintainer_1) { create(:user) } let_it_be(:maintainer_1) { create(:user) }
let_it_be(:maintainer_2) { create(:user) } let_it_be(:maintainer_2) { create(:user) }
let_it_be(:runner) { create(:ci_runner) } let_it_be(:runner) { create(:ci_runner, :online) }
let(:merge_request_1) do let(:merge_request_1) do
create(:merge_request, create(:merge_request,
......
...@@ -64,7 +64,7 @@ RSpec.describe 'User adds a merge request to a merge train', :js do ...@@ -64,7 +64,7 @@ RSpec.describe 'User adds a merge request to a merge train', :js do
end end
context 'when pipeline for merge train succeeds', :sidekiq_might_not_need_inline do context 'when pipeline for merge train succeeds', :sidekiq_might_not_need_inline do
let_it_be(:runner) { create(:ci_runner) } let_it_be(:runner) { create(:ci_runner, :online) }
before do before do
visit project_merge_request_path(project, merge_request) visit project_merge_request_path(project, merge_request)
......
...@@ -75,7 +75,7 @@ RSpec.describe Ci::CreatePipelineService do ...@@ -75,7 +75,7 @@ RSpec.describe Ci::CreatePipelineService do
end end
it 'creates a pipeline with regular_job and bridge_dag_job pending' do it 'creates a pipeline with regular_job and bridge_dag_job pending' do
create(:ci_runner) create(:ci_runner, :online)
pipeline = create_pipeline! pipeline = create_pipeline!
processables = pipeline.processables processables = pipeline.processables
Ci::InitialPipelineProcessWorker.new.perform(pipeline.id) Ci::InitialPipelineProcessWorker.new.perform(pipeline.id)
......
...@@ -13,6 +13,7 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do ...@@ -13,6 +13,7 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do
let_it_be(:instance_runner) do let_it_be(:instance_runner) do
create(:ci_runner, create(:ci_runner,
:online,
runner_type: :instance_type, runner_type: :instance_type,
public_projects_minutes_cost_factor: 0, public_projects_minutes_cost_factor: 0,
private_projects_minutes_cost_factor: 1) private_projects_minutes_cost_factor: 1)
......
...@@ -31,7 +31,7 @@ RSpec.describe Ci::ProcessPipelineService, '#execute' do ...@@ -31,7 +31,7 @@ RSpec.describe Ci::ProcessPipelineService, '#execute' do
context 'when there is a runner available' do context 'when there is a runner available' do
let_it_be(:runner) do let_it_be(:runner) do
create(:ci_runner, tag_list: %w[ruby postgres mysql]) create(:ci_runner, :online, tag_list: %w[ruby postgres mysql])
end end
it 'creates a downstream cross-project pipeline' do it 'creates a downstream cross-project pipeline' do
......
...@@ -25,7 +25,7 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request', ...@@ -25,7 +25,7 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request',
} }
end end
let_it_be(:runner) { create(:ci_runner) } let_it_be(:runner) { create(:ci_runner, :online) }
before do before do
stub_application_setting(auto_devops_enabled: false) stub_application_setting(auto_devops_enabled: false)
......
...@@ -8,7 +8,7 @@ RSpec.describe Gitlab::Ci::Build::AutoRetry do ...@@ -8,7 +8,7 @@ RSpec.describe Gitlab::Ci::Build::AutoRetry do
describe '#allowed?' do describe '#allowed?' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
let(:build) { build_stubbed(:ci_build) } let(:build) { create(:ci_build) }
subject { auto_retry.allowed? } subject { auto_retry.allowed? }
......
...@@ -53,7 +53,7 @@ RSpec.describe Ci::CreatePipelineService, '#execute' do ...@@ -53,7 +53,7 @@ RSpec.describe Ci::CreatePipelineService, '#execute' do
end end
context 'when sidekiq processes the job', :sidekiq_inline do context 'when sidekiq processes the job', :sidekiq_inline do
let_it_be(:runner) { create(:ci_runner) } let_it_be(:runner) { create(:ci_runner, :online) }
it 'transitions to pending status and triggers a downstream pipeline' do it 'transitions to pending status and triggers a downstream pipeline' do
pipeline = create_pipeline! pipeline = create_pipeline!
......
...@@ -204,7 +204,7 @@ RSpec.describe Ci::CreatePipelineService do ...@@ -204,7 +204,7 @@ RSpec.describe Ci::CreatePipelineService do
context 'when there are runners matching the builds' do context 'when there are runners matching the builds' do
before do before do
create(:ci_runner) create(:ci_runner, :online)
end end
it 'creates a pipeline with build_a and test_b pending; deploy_b manual', :sidekiq_inline do it 'creates a pipeline with build_a and test_b pending; deploy_b manual', :sidekiq_inline do
......
...@@ -7,7 +7,7 @@ RSpec.describe Ci::CreatePipelineService do ...@@ -7,7 +7,7 @@ RSpec.describe Ci::CreatePipelineService do
let_it_be(:project, reload: true) { create(:project, :repository) } let_it_be(:project, reload: true) { create(:project, :repository) }
let_it_be(:user, reload: true) { project.owner } let_it_be(:user, reload: true) { project.owner }
let_it_be(:runner) { create(:ci_runner, tag_list: %w[postgres mysql ruby]) } let_it_be(:runner) { create(:ci_runner, :online, tag_list: %w[postgres mysql ruby]) }
let(:ref_name) { 'refs/heads/master' } let(:ref_name) { 'refs/heads/master' }
......
...@@ -38,6 +38,10 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do ...@@ -38,6 +38,10 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do
end end
context 'when there are no runners available' do context 'when there are no runners available' do
let_it_be(:offline_project_runner) do
create(:ci_runner, runner_type: :project_type, projects: [project])
end
it 'drops the job' do it 'drops the job' do
execute execute
job.reload job.reload
...@@ -49,7 +53,7 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do ...@@ -49,7 +53,7 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do
context 'with project runners' do context 'with project runners' do
let_it_be(:project_runner) do let_it_be(:project_runner) do
create(:ci_runner, runner_type: :project_type, projects: [project]) create(:ci_runner, :online, runner_type: :project_type, projects: [project])
end end
it 'does not drop the jobs' do it 'does not drop the jobs' do
...@@ -59,7 +63,7 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do ...@@ -59,7 +63,7 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do
context 'with group runners' do context 'with group runners' do
let_it_be(:group_runner) do let_it_be(:group_runner) do
create(:ci_runner, runner_type: :group_type, groups: [group]) create(:ci_runner, :online, runner_type: :group_type, groups: [group])
end end
it 'does not drop the jobs' do it 'does not drop the jobs' do
...@@ -69,7 +73,7 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do ...@@ -69,7 +73,7 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do
context 'with instance runners' do context 'with instance runners' do
let_it_be(:instance_runner) do let_it_be(:instance_runner) do
create(:ci_runner, runner_type: :instance_type) create(:ci_runner, :online, runner_type: :instance_type)
end end
it 'does not drop the jobs' do it 'does not drop the jobs' do
......
...@@ -859,7 +859,7 @@ RSpec.shared_examples 'Pipeline Processing Service' do ...@@ -859,7 +859,7 @@ RSpec.shared_examples 'Pipeline Processing Service' do
end end
context 'when a bridge job has parallel:matrix config', :sidekiq_inline do context 'when a bridge job has parallel:matrix config', :sidekiq_inline do
let_it_be(:runner) { create(:ci_runner) } let_it_be(:runner) { create(:ci_runner, :online) }
let(:parent_config) do let(:parent_config) do
<<-EOY <<-EOY
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
RSpec.shared_context 'Pipeline Processing Service Tests With Yaml' do RSpec.shared_context 'Pipeline Processing Service Tests With Yaml' do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { project.owner } let_it_be(:user) { project.owner }
let_it_be(:runner) { create(:ci_runner) } let_it_be(:runner) { create(:ci_runner, :online) }
where(:test_file_path) do where(:test_file_path) do
Dir.glob(Rails.root.join('spec/services/ci/pipeline_processing/test_cases/*.yml')) Dir.glob(Rails.root.join('spec/services/ci/pipeline_processing/test_cases/*.yml'))
......
...@@ -13,7 +13,7 @@ RSpec.describe Ci::InitialPipelineProcessWorker do ...@@ -13,7 +13,7 @@ RSpec.describe Ci::InitialPipelineProcessWorker do
context 'when there are runners available' do context 'when there are runners available' do
before do before do
create(:ci_runner) create(:ci_runner, :online)
end end
it 'marks the pipeline as pending' do it 'marks the pipeline as pending' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment