summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorAlexis Reigel <alexis.reigel.ext@siemens.com>2017-12-19 15:12:21 +0100
committerAlexis Reigel <alexis.reigel.ext@siemens.com>2018-04-23 09:21:54 +0200
commit9bed8de9100a394257a4a55e8b87bcfd015f0fbd (patch)
tree29c1698a6fe5e4e338d1380c0661f4a76e299e18 /spec/services
parent1acd8eb740dd070a5290d8a36c03e1b6f9691dba (diff)
downloadgitlab-ce-9bed8de9100a394257a4a55e8b87bcfd015f0fbd.tar.gz
simplify runner selection
don't differentiate between the different runner types, instead we rely on the Runner model to provide the available projects. scheduling is now applied to all runners equally.
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/ci/register_job_service_spec.rb41
1 files changed, 38 insertions, 3 deletions
diff --git a/spec/services/ci/register_job_service_spec.rb b/spec/services/ci/register_job_service_spec.rb
index 138ef673527..0c343425392 100644
--- a/spec/services/ci/register_job_service_spec.rb
+++ b/spec/services/ci/register_job_service_spec.rb
@@ -179,6 +179,7 @@ module Ci
let!(:pipeline2) { create :ci_pipeline, project: project2 }
let!(:project3) { create :project, group_runners_enabled: true, group: group }
let!(:pipeline3) { create :ci_pipeline, project: project3 }
+
let!(:build1_project1) { pending_job }
let!(:build2_project1) { create :ci_build, pipeline: pipeline }
let!(:build3_project1) { create :ci_build, pipeline: pipeline }
@@ -186,6 +187,36 @@ module Ci
let!(:build2_project2) { create :ci_build, pipeline: pipeline2 }
let!(:build1_project3) { create :ci_build, pipeline: pipeline3 }
+ # these shouldn't influence the scheduling
+ let!(:unrelated_group) { create :group }
+ let!(:unrelated_project) { create :project, group_runners_enabled: true, group: unrelated_group }
+ let!(:unrelated_pipeline) { create :ci_pipeline, project: unrelated_project }
+ let!(:build1_unrelated_project) { create :ci_build, pipeline: unrelated_pipeline }
+ let!(:unrelated_group_runner) { create :ci_runner, groups: [unrelated_group] }
+
+ it 'does not consider builds from other group runners' do
+ expect(described_class.new(group_runner).send(:builds_for_runner).count).to eq 6
+ execute(group_runner)
+
+ expect(described_class.new(group_runner).send(:builds_for_runner).count).to eq 5
+ execute(group_runner)
+
+ expect(described_class.new(group_runner).send(:builds_for_runner).count).to eq 4
+ execute(group_runner)
+
+ expect(described_class.new(group_runner).send(:builds_for_runner).count).to eq 3
+ execute(group_runner)
+
+ expect(described_class.new(group_runner).send(:builds_for_runner).count).to eq 2
+ execute(group_runner)
+
+ expect(described_class.new(group_runner).send(:builds_for_runner).count).to eq 1
+ execute(group_runner)
+
+ expect(described_class.new(group_runner).send(:builds_for_runner).count).to eq 0
+ expect(execute(group_runner)).to be_nil
+ end
+
it 'prefers projects without builds first' do
# it gets for one build from each of the projects
expect(execute(group_runner)).to eq(build1_project1)
@@ -198,6 +229,8 @@ module Ci
# in the end the third build
expect(execute(group_runner)).to eq(build3_project1)
+
+ expect(execute(group_runner)).to be_nil
end
it 'equalises number of running builds' do
@@ -211,6 +244,8 @@ module Ci
expect(execute(group_runner)).to eq(build2_project2)
expect(execute(group_runner)).to eq(build1_project3)
expect(execute(group_runner)).to eq(build3_project1)
+
+ expect(execute(group_runner)).to be_nil
end
end
@@ -247,7 +282,7 @@ module Ci
let!(:other_build) { create :ci_build, pipeline: pipeline }
before do
- allow_any_instance_of(Ci::RegisterJobService).to receive(:builds_for_specific_runner)
+ allow_any_instance_of(Ci::RegisterJobService).to receive(:builds_for_runner)
.and_return(Ci::Build.where(id: [pending_job, other_build]))
end
@@ -259,7 +294,7 @@ module Ci
context 'when single build is in queue' do
before do
- allow_any_instance_of(Ci::RegisterJobService).to receive(:builds_for_specific_runner)
+ allow_any_instance_of(Ci::RegisterJobService).to receive(:builds_for_runner)
.and_return(Ci::Build.where(id: pending_job))
end
@@ -270,7 +305,7 @@ module Ci
context 'when there is no build in queue' do
before do
- allow_any_instance_of(Ci::RegisterJobService).to receive(:builds_for_specific_runner)
+ allow_any_instance_of(Ci::RegisterJobService).to receive(:builds_for_runner)
.and_return(Ci::Build.none)
end