Commit d0d176c1 authored by James Fargher's avatar James Fargher

Lock storage move before starting

Reloading projects is now required in tests as locking causes a new
project instance to be loaded.
parent 94b28e01
......@@ -14,9 +14,11 @@ module Projects
end
def execute
return ServiceResponse.success unless repository_storage_move.scheduled?
repository_storage_move.with_lock do
return ServiceResponse.success unless repository_storage_move.scheduled? # rubocop:disable Cop/AvoidReturnFromBlocks
repository_storage_move.start!
repository_storage_move.start!
end
raise SameFilesystemError if same_filesystem?(repository.storage, destination_storage_name)
......
......@@ -327,7 +327,7 @@ RSpec.describe Projects::ForkService do
destination_storage_name: 'test_second_storage'
)
Projects::UpdateRepositoryStorageService.new(storage_move).execute
fork_after_move = fork_project(project)
fork_after_move = fork_project(project.reload)
pool_repository_before_move = PoolRepository.joins(:shard)
.find_by(source_project: project, shards: { name: 'default' })
pool_repository_after_move = PoolRepository.joins(:shard)
......
......@@ -45,6 +45,7 @@ RSpec.describe Projects::UpdateRepositoryStorageService do
.and_call_original
result = subject.execute
project.reload
expect(result).to be_success
expect(project).not_to be_repository_read_only
......@@ -115,6 +116,7 @@ RSpec.describe Projects::UpdateRepositoryStorageService do
.and_return(checksum)
result = subject.execute
project.reload
expect(result).to be_success
expect(project.repository_storage).to eq('test_second_storage')
......
......@@ -47,6 +47,7 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type|
old_repository_path = repository.full_path
result = subject.execute
project.reload
expect(result).to be_success
expect(project).not_to be_repository_read_only
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment