summaryrefslogtreecommitdiff
path: root/spec/models/ci
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/models/ci
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/models/ci')
-rw-r--r--spec/models/ci/runner_spec.rb67
1 files changed, 67 insertions, 0 deletions
diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb
index fb724f682a5..512a490d289 100644
--- a/spec/models/ci/runner_spec.rb
+++ b/spec/models/ci/runner_spec.rb
@@ -776,4 +776,71 @@ describe Ci::Runner do
expect(runner.project?).to be true
end
end
+
+ describe '#accessible_projects' do
+ let!(:shared_runner) { create(:ci_runner, :shared) }
+ let!(:shared_project) { create(:project, shared_runners_enabled: true) }
+
+ let!(:project_runner) { create(:ci_runner) }
+ let!(:project_project) { create(:project, runners: [project_runner], shared_runners_enabled: false) }
+
+ let!(:group_runner) { create(:ci_runner) }
+
+ let!(:parent_group) { create(:group) }
+ let!(:parent_group_project) do
+ create(:project, group: parent_group, shared_runners_enabled: false)
+ end
+
+ let!(:group) { create :group, runners: [group_runner], parent: parent_group }
+ let!(:group_project) do
+ create(:project, group: group, shared_runners_enabled: false)
+ end
+
+ let!(:nested_group_project) do
+ nested_group = create :group, parent: group
+ create(:project, group: nested_group, shared_runners_enabled: false)
+ end
+
+ it 'returns the project with a shared runner' do
+ expect(shared_runner.reload.accessible_projects).to eq [shared_project]
+ end
+
+ it 'returns the project with a project runner' do
+ expect(project_runner.reload.accessible_projects).to eq [project_project]
+ end
+
+ it 'returns the projects with a group and nested group runner' do
+ expect(group_runner.reload.accessible_projects).to eq [group_project, nested_group_project]
+ end
+
+ context 'deleted' do
+ before do
+ shared_project.update_attributes!(pending_delete: true)
+ project_project.update_attributes!(pending_delete: true)
+ group_project.update_attributes!(pending_delete: true)
+ nested_group_project.update_attributes!(pending_delete: true)
+ end
+
+ it 'returns no projects' do
+ expect(shared_runner.reload.accessible_projects).to be_empty
+ expect(project_runner.reload.accessible_projects).to be_empty
+ expect(group_runner.reload.accessible_projects).to be_empty
+ end
+ end
+
+ context 'builds disabled' do
+ before do
+ shared_project.update_attributes!(builds_enabled: false)
+ project_project.update_attributes!(builds_enabled: false)
+ group_project.update_attributes!(builds_enabled: false)
+ nested_group_project.update_attributes!(builds_enabled: false)
+ end
+
+ it 'returns no projects' do
+ expect(shared_runner.reload.accessible_projects).to be_empty
+ expect(project_runner.reload.accessible_projects).to be_empty
+ expect(group_runner.reload.accessible_projects).to be_empty
+ end
+ end
+ end
end