diff options
Diffstat (limited to 'spec/services/ci/pipelines/add_job_service_spec.rb')
-rw-r--r-- | spec/services/ci/pipelines/add_job_service_spec.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/spec/services/ci/pipelines/add_job_service_spec.rb b/spec/services/ci/pipelines/add_job_service_spec.rb index c62aa9506bd..6380a6a5ec3 100644 --- a/spec/services/ci/pipelines/add_job_service_spec.rb +++ b/spec/services/ci/pipelines/add_job_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Ci::Pipelines::AddJobService do +RSpec.describe Ci::Pipelines::AddJobService, feature_category: :continuous_integration do include ExclusiveLeaseHelpers let_it_be_with_reload(:pipeline) { create(:ci_pipeline) } @@ -86,5 +86,15 @@ RSpec.describe Ci::Pipelines::AddJobService do expect(execute.payload[:job]).to eq(job) end end + + it 'locks pipelines and stages before persisting builds', :aggregate_failures do + expect(job).not_to be_persisted + + recorder = ActiveRecord::QueryRecorder.new(skip_cached: false) { execute } + entries = recorder.log.select { |query| query.match(/LOCK|INSERT INTO ".{0,2}ci_builds"/) } + + expect(entries.size).to eq(2) + expect(entries.first).to match(/LOCK "ci_pipelines", "ci_stages" IN ROW SHARE MODE;/) + end end end |