summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-06-06 12:45:41 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2018-06-06 12:45:41 +0000
commit96747556e70470caed4175730f9342af2f0f593d (patch)
tree7e81c63f3b644ee45fd3a328d35c486c2f21b3ad /spec/support
parent75ed8a091a2d0d781fcafbc948eb87677fef5ced (diff)
parentdfb0d45ddb0747f5b72e7188d930737d57dabc4c (diff)
downloadgitlab-ce-96747556e70470caed4175730f9342af2f0f593d.tar.gz
Merge branch 'live-trace-v2-persist-data' into 'master'
Live trace: Rescue stale live trace See merge request gitlab-org/gitlab-ce!18680
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/shared_examples/ci_trace_shared_examples.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/support/shared_examples/ci_trace_shared_examples.rb b/spec/support/shared_examples/ci_trace_shared_examples.rb
index 21c6f3c829f..6dbe0f6f980 100644
--- a/spec/support/shared_examples/ci_trace_shared_examples.rb
+++ b/spec/support/shared_examples/ci_trace_shared_examples.rb
@@ -227,6 +227,42 @@ shared_examples_for 'common trace features' do
end
end
end
+
+ describe '#archive!' do
+ subject { trace.archive! }
+
+ context 'when build status is success' do
+ let!(:build) { create(:ci_build, :success, :trace_live) }
+
+ it 'does not have an archived trace yet' do
+ expect(build.job_artifacts_trace).to be_nil
+ end
+
+ context 'when archives' do
+ it 'has an archived trace' do
+ subject
+
+ build.reload
+ expect(build.job_artifacts_trace).to be_exist
+ end
+
+ context 'when another process has 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 'blocks concurrent archiving' do
+ expect(Rails.logger).to receive(:error).with('Cannot obtain an exclusive lease. There must be another instance already in execution.')
+
+ subject
+
+ build.reload
+ expect(build.job_artifacts_trace).to be_nil
+ end
+ end
+ end
+ end
+ end
end
shared_examples_for 'trace with disabled live trace feature' do