fix the failing spec
This commit is contained in:
parent
a667de18d3
commit
50872bcc24
|
@ -9,6 +9,7 @@ module ObjectStorage
|
||||||
RemoteStoreError = Class.new(StandardError)
|
RemoteStoreError = Class.new(StandardError)
|
||||||
UnknownStoreError = Class.new(StandardError)
|
UnknownStoreError = Class.new(StandardError)
|
||||||
ObjectStorageUnavailable = Class.new(StandardError)
|
ObjectStorageUnavailable = Class.new(StandardError)
|
||||||
|
ExclusiveLeaseTaken = Class.new(StandardError)
|
||||||
|
|
||||||
TMP_UPLOAD_PATH = 'tmp/uploads'.freeze
|
TMP_UPLOAD_PATH = 'tmp/uploads'.freeze
|
||||||
|
|
||||||
|
@ -378,7 +379,7 @@ module ObjectStorage
|
||||||
def with_exclusive_lease
|
def with_exclusive_lease
|
||||||
lease_key = exclusive_lease_key
|
lease_key = exclusive_lease_key
|
||||||
uuid = Gitlab::ExclusiveLease.new(lease_key, timeout: 1.hour.to_i).try_obtain
|
uuid = Gitlab::ExclusiveLease.new(lease_key, timeout: 1.hour.to_i).try_obtain
|
||||||
raise "Exclusive lease #{lease_key} already taken." unless uuid
|
raise ExclusiveLeaseTaken, "Exclusive lease #{lease_key} already taken." unless uuid
|
||||||
|
|
||||||
yield uuid
|
yield uuid
|
||||||
ensure
|
ensure
|
||||||
|
|
|
@ -85,13 +85,13 @@ shared_examples "migrates" do |to_store:, from_store: nil|
|
||||||
it 'does not execute migrate!' do
|
it 'does not execute migrate!' do
|
||||||
expect(subject).not_to receive(:unsafe_migrate!)
|
expect(subject).not_to receive(:unsafe_migrate!)
|
||||||
|
|
||||||
expect { migrate(to) }.to raise_error('exclusive lease already taken')
|
expect { migrate(to) }.to raise_error(ObjectStorage::ExclusiveLeaseTaken)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not execute use_file' do
|
it 'does not execute use_file' do
|
||||||
expect(subject).not_to receive(:unsafe_use_file)
|
expect(subject).not_to receive(:unsafe_use_file)
|
||||||
|
|
||||||
expect { subject.use_file }.to raise_error('exclusive lease already taken')
|
expect { subject.use_file }.to raise_error(ObjectStorage::ExclusiveLeaseTaken)
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
|
|
@ -321,7 +321,7 @@ describe ObjectStorage do
|
||||||
when_file_is_in_use do
|
when_file_is_in_use do
|
||||||
expect(uploader).not_to receive(:unsafe_migrate!)
|
expect(uploader).not_to receive(:unsafe_migrate!)
|
||||||
|
|
||||||
expect { uploader.migrate!(described_class::Store::REMOTE) }.to raise_error('exclusive lease already taken')
|
expect { uploader.migrate!(described_class::Store::REMOTE) }.to raise_error(ObjectStorage::ExclusiveLeaseTaken)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ describe ObjectStorage do
|
||||||
when_file_is_in_use do
|
when_file_is_in_use do
|
||||||
expect(uploader).not_to receive(:unsafe_use_file)
|
expect(uploader).not_to receive(:unsafe_use_file)
|
||||||
|
|
||||||
expect { uploader.use_file }.to raise_error('exclusive lease already taken')
|
expect { uploader.use_file }.to raise_error(ObjectStorage::ExclusiveLeaseTaken)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue