diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-03-29 10:50:11 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-03-29 10:50:11 +0000 |
commit | b2ccfc084d790d012f43b8f5ffeaaee4c913a08c (patch) | |
tree | 60501362b6c390455111dedf1b5d67539065677b /spec/support | |
parent | f39beff64cafba35097637e5e9c3a5f999745eaa (diff) | |
parent | ae27a47b6e5a27bb16d8f1555207784e34ec2ec1 (diff) | |
download | gitlab-ce-b2ccfc084d790d012f43b8f5ffeaaee4c913a08c.tar.gz |
Merge branch 'ac/fix-use_file-race' into 'master'
ObjectStorage#use_file should respect exclusive lease
Closes gitlab-com/infrastructure#3874
See merge request gitlab-org/gitlab-ce!18052
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/shared_examples/uploaders/object_storage_shared_examples.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/spec/support/shared_examples/uploaders/object_storage_shared_examples.rb b/spec/support/shared_examples/uploaders/object_storage_shared_examples.rb index cd9974cd6e2..6352f1527cd 100644 --- a/spec/support/shared_examples/uploaders/object_storage_shared_examples.rb +++ b/spec/support/shared_examples/uploaders/object_storage_shared_examples.rb @@ -61,12 +61,18 @@ shared_examples "migrates" do |to_store:, from_store: nil| expect { migrate(to) }.not_to change { file.exists? } end - context 'when migrate! is not oqqupied by another process' do + context 'when migrate! is not occupied by another process' do it 'executes migrate!' do expect(subject).to receive(:object_store=).at_least(1) migrate(to) end + + it 'executes use_file' do + expect(subject).to receive(:unsafe_use_file).once + + subject.use_file + end end context 'when migrate! is occupied by another process' do @@ -79,7 +85,13 @@ shared_examples "migrates" do |to_store:, from_store: nil| it 'does not execute migrate!' do expect(subject).not_to receive(:unsafe_migrate!) - expect { migrate(to) }.to raise_error('Already running') + expect { migrate(to) }.to raise_error('exclusive lease already taken') + end + + it 'does not execute use_file' do + expect(subject).not_to receive(:unsafe_use_file) + + expect { subject.use_file }.to raise_error('exclusive lease already taken') end after do |