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
def load_runners
@instance_runners, @private_runners = project
.all_runners
.active
.online
.runner_matchers
.partition(&:instance_type?)
end
......
......@@ -8,7 +8,7 @@ RSpec.describe 'Two merge requests on a merge train' do
let(:project) { create(:project, :repository) }
let_it_be(:maintainer_1) { 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
create(:merge_request,
......
......@@ -64,7 +64,7 @@ RSpec.describe 'User adds a merge request to a merge train', :js do
end
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
visit project_merge_request_path(project, merge_request)
......
......@@ -75,7 +75,7 @@ RSpec.describe Ci::CreatePipelineService do
end
it 'creates a pipeline with regular_job and bridge_dag_job pending' do
create(:ci_runner)
create(:ci_runner, :online)
pipeline = create_pipeline!
processables = pipeline.processables
Ci::InitialPipelineProcessWorker.new.perform(pipeline.id)
......
......@@ -13,6 +13,7 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do
let_it_be(:instance_runner) do
create(:ci_runner,
:online,
runner_type: :instance_type,
public_projects_minutes_cost_factor: 0,
private_projects_minutes_cost_factor: 1)
......
......@@ -31,7 +31,7 @@ RSpec.describe Ci::ProcessPipelineService, '#execute' do
context 'when there is a runner available' 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
it 'creates a downstream cross-project pipeline' do
......
......@@ -25,7 +25,7 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request',
}
end
let_it_be(:runner) { create(:ci_runner) }
let_it_be(:runner) { create(:ci_runner, :online) }
before do
stub_application_setting(auto_devops_enabled: false)
......
......@@ -8,7 +8,7 @@ RSpec.describe Gitlab::Ci::Build::AutoRetry do
describe '#allowed?' do
using RSpec::Parameterized::TableSyntax
let(:build) { build_stubbed(:ci_build) }
let(:build) { create(:ci_build) }
subject { auto_retry.allowed? }
......
......@@ -53,7 +53,7 @@ RSpec.describe Ci::CreatePipelineService, '#execute' do
end
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
pipeline = create_pipeline!
......
......@@ -204,7 +204,7 @@ RSpec.describe Ci::CreatePipelineService do
context 'when there are runners matching the builds' do
before do
create(:ci_runner)
create(:ci_runner, :online)
end
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
let_it_be(:project, reload: true) { create(:project, :repository) }
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' }
......
......@@ -38,6 +38,10 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do
end
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
execute
job.reload
......@@ -49,7 +53,7 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do
context 'with project runners' 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
it 'does not drop the jobs' do
......@@ -59,7 +63,7 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do
context 'with group runners' 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
it 'does not drop the jobs' do
......@@ -69,7 +73,7 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do
context 'with instance runners' do
let_it_be(:instance_runner) do
create(:ci_runner, runner_type: :instance_type)
create(:ci_runner, :online, runner_type: :instance_type)
end
it 'does not drop the jobs' do
......
......@@ -859,7 +859,7 @@ RSpec.shared_examples 'Pipeline Processing Service' do
end
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
<<-EOY
......
......@@ -3,7 +3,7 @@
RSpec.shared_context 'Pipeline Processing Service Tests With Yaml' do
let_it_be(:project) { create(:project, :repository) }
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
Dir.glob(Rails.root.join('spec/services/ci/pipeline_processing/test_cases/*.yml'))
......
......@@ -13,7 +13,7 @@ RSpec.describe Ci::InitialPipelineProcessWorker do
context 'when there are runners available' do
before do
create(:ci_runner)
create(:ci_runner, :online)
end
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