diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-07-03 07:24:02 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-07-03 07:24:02 +0300 |
commit | f930e94363e00e41fceb31f7d8497e5fb530dacd (patch) | |
tree | bf7129ec74644026bc7662f525ce77ab38acaae8 /spec/models/ci | |
parent | 58a1a0b70c7df0947864d0be933faf0153b537ec (diff) | |
parent | 275fbf24b1810e2fbef92b6599d5372855b97b46 (diff) |
Merge branch 'master' into build-chunks-on-object-storage
Diffstat (limited to 'spec/models/ci')
-rw-r--r-- | spec/models/ci/build_spec.rb | 6 | ||||
-rw-r--r-- | spec/models/ci/build_trace_chunk_spec.rb | 26 |
2 files changed, 17 insertions, 15 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 51b9b518117..6758adc59eb 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1871,7 +1871,11 @@ describe Ci::Build do end context 'when yaml_variables are undefined' do - let(:pipeline) { create(:ci_pipeline, project: project) } + let(:pipeline) do + create(:ci_pipeline, project: project, + sha: project.commit.id, + ref: project.default_branch) + end before do build.yaml_variables = nil diff --git a/spec/models/ci/build_trace_chunk_spec.rb b/spec/models/ci/build_trace_chunk_spec.rb index 94a5fe8e5f8..97a5de47b37 100644 --- a/spec/models/ci/build_trace_chunk_spec.rb +++ b/spec/models/ci/build_trace_chunk_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do + include ExclusiveLeaseHelpers + set(:build) { create(:ci_build, :running) } let(:chunk_index) { 0 } let(:data_store) { :redis } @@ -105,14 +107,12 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do context 'when the other process is appending' do let(:lease_key) { "trace_write:#{build_trace_chunk.build.id}:chunks:#{build_trace_chunk.chunk_index}" } - it 'raise an error' do - begin - uuid = Gitlab::ExclusiveLease.new(lease_key, timeout: 1.day).try_obtain + before do + stub_exclusive_lease_taken(lease_key) + end - expect { subject }.to raise_error('Failed to obtain a lock') - ensure - Gitlab::ExclusiveLease.cancel(lease_key, uuid) - end + it 'raise an error' do + expect { subject }.to raise_error('Failed to obtain a lock') end end @@ -406,14 +406,12 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do context 'when the other process is persisting' do let(:lease_key) { "trace_write:#{build_trace_chunk.build.id}:chunks:#{build_trace_chunk.chunk_index}" } - it 'raise an error' do - begin - uuid = Gitlab::ExclusiveLease.new(lease_key, timeout: 1.day).try_obtain + before do + stub_exclusive_lease_taken(lease_key) + end - expect { subject }.to raise_error('Failed to obtain a lock') - ensure - Gitlab::ExclusiveLease.cancel(lease_key, uuid) - end + it 'raise an error' do + expect { subject }.to raise_error('Failed to obtain a lock') end end end |