summaryrefslogtreecommitdiff
path: root/spec/workers
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-04-29 17:18:34 +0000
committerStan Hu <stanhu@gmail.com>2019-04-29 17:18:34 +0000
commitca8e5aded8e5e63b97a511ca7e50cc981ac7c4dd (patch)
treec2997a437de5b7ee0ad64adaf932cc27f69619b5 /spec/workers
parentbb733375d1f7868cb713e4fd92c6f52956650b92 (diff)
parent28f785404a6659d61c69ee4bfdaca915652d1759 (diff)
downloadgitlab-ce-ca8e5aded8e5e63b97a511ca7e50cc981ac7c4dd.tar.gz
Merge branch 'lock-pipeline-schedule-worker' into 'master'
Prevent concurrent execution of PipelineScheduleWorker Closes gitlab-com/gl-infra/production#805 See merge request gitlab-org/gitlab-ce!27781
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/pipeline_schedule_worker_spec.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/workers/pipeline_schedule_worker_spec.rb b/spec/workers/pipeline_schedule_worker_spec.rb
index f23910d23be..8c604b13297 100644
--- a/spec/workers/pipeline_schedule_worker_spec.rb
+++ b/spec/workers/pipeline_schedule_worker_spec.rb
@@ -3,6 +3,8 @@
require 'spec_helper'
describe PipelineScheduleWorker do
+ include ExclusiveLeaseHelpers
+
subject { described_class.new.perform }
set(:project) { create(:project, :repository) }
@@ -39,6 +41,16 @@ describe PipelineScheduleWorker do
it_behaves_like 'successful scheduling'
+ context 'when exclusive lease has already been taken by the other instance' do
+ before do
+ stub_exclusive_lease_taken(described_class::EXCLUSIVE_LOCK_KEY, timeout: described_class::LOCK_TIMEOUT)
+ end
+
+ it 'raises an error and does not start creating pipelines' do
+ expect { subject }.to raise_error(Gitlab::ExclusiveLeaseHelpers::FailedToObtainLockError)
+ end
+ end
+
context 'when the latest commit contains [ci skip]' do
before do
allow_any_instance_of(Ci::Pipeline)