From f9b821f08dfc8feee2ed8a06c8f21c85c3c9d2ec Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Sat, 2 Jun 2018 14:09:24 +0900 Subject: Fix specs for exclusive lease --- .../shared_examples/ci_trace_shared_examples.rb | 29 ++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'spec') diff --git a/spec/support/shared_examples/ci_trace_shared_examples.rb b/spec/support/shared_examples/ci_trace_shared_examples.rb index a3a0b2d0eb5..59efce1b5f0 100644 --- a/spec/support/shared_examples/ci_trace_shared_examples.rb +++ b/spec/support/shared_examples/ci_trace_shared_examples.rb @@ -234,20 +234,29 @@ shared_examples_for 'common trace features' do context 'when build status is success' do let!(:build) { create(:ci_build, :success, :trace_live) } - it 'archives a trace' do - subject - - expect(build.job_artifacts_trace).to be_exist + it 'does not have an archived trace yet' do + expect(build.job_artifacts_trace).to be_nil end - context 'when anothe process had already been archiving', :clean_gitlab_redis_shared_state do - before do - Gitlab::ExclusiveLease.new("trace:archive:#{trace.job.id}", timeout: 1.hour).try_obtain - end + context 'when archives' do + it 'has an archived trace' do + subject - it 'prevents multiple archiving' do build.reload - expect(build.job_artifacts_trace).to be_nil + expect(build.job_artifacts_trace).to be_exist + end + + context 'when anothe process had already been archiving', :clean_gitlab_redis_shared_state do + before do + Gitlab::ExclusiveLease.new("trace:archive:#{trace.job.id}", timeout: 1.hour).try_obtain + end + + it 'prevents to archive concurently' do + subject + + build.reload + expect(build.job_artifacts_trace).to be_nil + end end end end -- cgit v1.2.1