diff options
author | Tomasz Maczukin <tomasz@maczukin.pl> | 2017-02-07 23:06:16 +0100 |
---|---|---|
committer | Tomasz Maczukin <tomasz@maczukin.pl> | 2017-03-01 13:29:52 +0100 |
commit | 0ba385b363879f270c767aab6c1799a8e675a263 (patch) | |
tree | 002964ed32cb8c247682505a227e7d26a11a8283 /spec | |
parent | a4e996d77315a9d2598e32fab42436b1a04fadcb (diff) | |
download | gitlab-ce-0ba385b363879f270c767aab6c1799a8e675a263.tar.gz |
Add exclusive lease for stuck_ci_builds_worker
Diffstat (limited to 'spec')
-rw-r--r-- | spec/workers/stuck_ci_builds_worker_spec.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/spec/workers/stuck_ci_builds_worker_spec.rb b/spec/workers/stuck_ci_builds_worker_spec.rb index e2386336447..c88a0dfa4a6 100644 --- a/spec/workers/stuck_ci_builds_worker_spec.rb +++ b/spec/workers/stuck_ci_builds_worker_spec.rb @@ -10,7 +10,10 @@ describe StuckCiBuildsWorker do build.status end - before { build.update!(status: status, updated_at: updated_at) } + before do + build.update!(status: status, updated_at: updated_at) + allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain).and_return(true) + end shared_examples 'build is dropped' do it 'changes status' do @@ -96,4 +99,16 @@ describe StuckCiBuildsWorker do worker.perform end end + + describe 'exclusive lease' do + let(:status) { 'running' } + let(:updated_at) { 2.days.ago } + + it 'is guard by exclusive lease' do + worker.perform + allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain).and_return(false) + expect(worker).not_to receive(:drop) + worker.perform + end + end end |