diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-12 13:17:34 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-12 13:17:34 +0300 |
commit | 3a6238c2e23454c462ccd229b1802583e657bfd0 (patch) | |
tree | 808c1151b9916516e41cea4869791cbf3dab345f /spec/services/ci | |
parent | c301cf0ca5fbb998c22be5d8033e77be4bf0a451 (diff) |
Add latest changes from gitlab-org/gitlab@14-9-stable-ee
Diffstat (limited to 'spec/services/ci')
-rw-r--r-- | spec/services/ci/register_job_service_spec.rb | 19 | ||||
-rw-r--r-- | spec/services/ci/update_build_queue_service_spec.rb | 22 |
2 files changed, 41 insertions, 0 deletions
diff --git a/spec/services/ci/register_job_service_spec.rb b/spec/services/ci/register_job_service_spec.rb index 2127a4fa0fc..245118e71fa 100644 --- a/spec/services/ci/register_job_service_spec.rb +++ b/spec/services/ci/register_job_service_spec.rb @@ -771,6 +771,25 @@ module Ci include_examples 'handles runner assignment' end + + context 'when a conflicting data is stored in denormalized table' do + let!(:specific_runner) { create(:ci_runner, :project, projects: [project], tag_list: %w[conflict]) } + let!(:pending_job) { create(:ci_build, :pending, :queued, pipeline: pipeline, tag_list: %w[conflict]) } + + before do + pending_job.update_column(:status, :running) + end + + it 'removes queuing entry upon build assignment attempt' do + expect(pending_job.reload).to be_running + expect(pending_job.queuing_entry).to be_present + + result = described_class.new(specific_runner).execute + + expect(result).not_to be_valid + expect(pending_job.reload.queuing_entry).not_to be_present + end + end end context 'when not using pending builds table' do diff --git a/spec/services/ci/update_build_queue_service_spec.rb b/spec/services/ci/update_build_queue_service_spec.rb index ef43866d8d4..d3f537a1aa0 100644 --- a/spec/services/ci/update_build_queue_service_spec.rb +++ b/spec/services/ci/update_build_queue_service_spec.rb @@ -103,6 +103,28 @@ RSpec.describe Ci::UpdateBuildQueueService do end end end + + describe '#remove!' do + context 'when pending build exists' do + before do + create(:ci_pending_build, build: build, project: build.project) + end + + it 'removes pending build in a transaction' do + dequeued = subject.remove!(build) + + expect(dequeued).to eq build.id + end + end + + context 'when pending build does not exist' do + it 'does nothing if there is no pending build to remove' do + dequeued = subject.remove!(build) + + expect(dequeued).to be_nil + end + end + end end describe 'shared runner builds tracking' do |