Commit 23764d5f authored by Nick Thomas's avatar Nick Thomas

Merge branch 'replicate_repository_stop_creating_destination' into 'master'

Stop creating destination repository for ReplicateRepository

See merge request gitlab-org/gitlab!34113
parents a508dba7 cacb8f8e
...@@ -79,8 +79,6 @@ module Projects ...@@ -79,8 +79,6 @@ module Projects
full_path full_path
) )
new_repository.create_repository
new_repository.replicate(raw_repository) new_repository.replicate(raw_repository)
new_checksum = new_repository.checksum new_checksum = new_repository.checksum
......
---
title: Use snapshot transfers for repository shard moves when possible
merge_request: 34113
author:
type: performance
...@@ -2187,34 +2187,47 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do ...@@ -2187,34 +2187,47 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do
'gitaly_address' => Gitlab.config.repositories.storages.default.gitaly_address, 'gitaly_address' => Gitlab.config.repositories.storages.default.gitaly_address,
'path' => TestEnv::SECOND_STORAGE_PATH 'path' => TestEnv::SECOND_STORAGE_PATH
}) })
new_repository.create_repository
end end
after do after do
new_repository.remove new_repository.remove
end end
it 'mirrors the source repository' do context 'destination does not exist' do
subject it 'mirrors the source repository' do
subject
expect(refs(new_repository_path)).to eq(refs(repository_path)) expect(refs(new_repository_path)).to eq(refs(repository_path))
end
end end
context 'with keep-around refs' do context 'destination exists' do
let(:sha) { SeedRepo::Commit::ID }
let(:keep_around_ref) { "refs/keep-around/#{sha}" }
let(:tmp_ref) { "refs/tmp/#{SecureRandom.hex}" }
before do before do
repository.write_ref(keep_around_ref, sha) new_repository.create_repository
repository.write_ref(tmp_ref, sha)
end end
it 'includes the temporary and keep-around refs' do it 'mirrors the source repository' do
subject subject
expect(refs(new_repository_path)).to include(keep_around_ref) expect(refs(new_repository_path)).to eq(refs(repository_path))
expect(refs(new_repository_path)).to include(tmp_ref) end
context 'with keep-around refs' do
let(:sha) { SeedRepo::Commit::ID }
let(:keep_around_ref) { "refs/keep-around/#{sha}" }
let(:tmp_ref) { "refs/tmp/#{SecureRandom.hex}" }
before do
repository.write_ref(keep_around_ref, sha)
repository.write_ref(tmp_ref, sha)
end
it 'includes the temporary and keep-around refs' do
subject
expect(refs(new_repository_path)).to include(keep_around_ref)
expect(refs(new_repository_path)).to include(tmp_ref)
end
end end
end end
end end
......
...@@ -37,8 +37,6 @@ RSpec.describe Projects::UpdateRepositoryStorageService do ...@@ -37,8 +37,6 @@ RSpec.describe Projects::UpdateRepositoryStorageService do
project.repository.path_to_repo project.repository.path_to_repo
end end
expect(project_repository_double).to receive(:create_repository)
.and_return(true)
expect(project_repository_double).to receive(:replicate) expect(project_repository_double).to receive(:replicate)
.with(project.repository.raw) .with(project.repository.raw)
expect(project_repository_double).to receive(:checksum) expect(project_repository_double).to receive(:checksum)
...@@ -72,8 +70,6 @@ RSpec.describe Projects::UpdateRepositoryStorageService do ...@@ -72,8 +70,6 @@ RSpec.describe Projects::UpdateRepositoryStorageService do
allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('default').and_call_original allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('default').and_call_original
allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('test_second_storage').and_return(SecureRandom.uuid) allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('test_second_storage').and_return(SecureRandom.uuid)
expect(project_repository_double).to receive(:create_repository)
.and_return(true)
expect(project_repository_double).to receive(:replicate) expect(project_repository_double).to receive(:replicate)
.with(project.repository.raw) .with(project.repository.raw)
.and_raise(Gitlab::Git::CommandError) .and_raise(Gitlab::Git::CommandError)
...@@ -92,8 +88,6 @@ RSpec.describe Projects::UpdateRepositoryStorageService do ...@@ -92,8 +88,6 @@ RSpec.describe Projects::UpdateRepositoryStorageService do
allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('default').and_call_original allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('default').and_call_original
allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('test_second_storage').and_return(SecureRandom.uuid) allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('test_second_storage').and_return(SecureRandom.uuid)
expect(project_repository_double).to receive(:create_repository)
.and_return(true)
expect(project_repository_double).to receive(:replicate) expect(project_repository_double).to receive(:replicate)
.with(project.repository.raw) .with(project.repository.raw)
expect(project_repository_double).to receive(:checksum) expect(project_repository_double).to receive(:checksum)
...@@ -115,8 +109,6 @@ RSpec.describe Projects::UpdateRepositoryStorageService do ...@@ -115,8 +109,6 @@ RSpec.describe Projects::UpdateRepositoryStorageService do
allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('default').and_call_original allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('default').and_call_original
allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('test_second_storage').and_return(SecureRandom.uuid) allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('test_second_storage').and_return(SecureRandom.uuid)
expect(project_repository_double).to receive(:create_repository)
.and_return(true)
expect(project_repository_double).to receive(:replicate) expect(project_repository_double).to receive(:replicate)
.with(project.repository.raw) .with(project.repository.raw)
expect(project_repository_double).to receive(:checksum) expect(project_repository_double).to receive(:checksum)
......
...@@ -25,15 +25,11 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type| ...@@ -25,15 +25,11 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type|
allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('default').and_call_original allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('default').and_call_original
allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('test_second_storage').and_return(SecureRandom.uuid) allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('test_second_storage').and_return(SecureRandom.uuid)
allow(project_repository_double).to receive(:create_repository)
.and_return(true)
allow(project_repository_double).to receive(:replicate) allow(project_repository_double).to receive(:replicate)
.with(project.repository.raw) .with(project.repository.raw)
allow(project_repository_double).to receive(:checksum) allow(project_repository_double).to receive(:checksum)
.and_return(project_repository_checksum) .and_return(project_repository_checksum)
allow(repository_double).to receive(:create_repository)
.and_return(true)
allow(repository_double).to receive(:replicate) allow(repository_double).to receive(:replicate)
.with(repository.raw) .with(repository.raw)
allow(repository_double).to receive(:checksum) allow(repository_double).to receive(:checksum)
...@@ -104,15 +100,11 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type| ...@@ -104,15 +100,11 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type|
it 'unmarks the repository as read-only without updating the repository storage' do it 'unmarks the repository as read-only without updating the repository storage' do
allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('default').and_call_original allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('default').and_call_original
allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('test_second_storage').and_return(SecureRandom.uuid) allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('test_second_storage').and_return(SecureRandom.uuid)
allow(project_repository_double).to receive(:create_repository)
.and_return(true)
allow(project_repository_double).to receive(:replicate) allow(project_repository_double).to receive(:replicate)
.with(project.repository.raw) .with(project.repository.raw)
allow(project_repository_double).to receive(:checksum) allow(project_repository_double).to receive(:checksum)
.and_return(project_repository_checksum) .and_return(project_repository_checksum)
allow(repository_double).to receive(:create_repository)
.and_return(true)
allow(repository_double).to receive(:replicate) allow(repository_double).to receive(:replicate)
.with(repository.raw) .with(repository.raw)
.and_raise(Gitlab::Git::CommandError) .and_raise(Gitlab::Git::CommandError)
...@@ -131,15 +123,11 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type| ...@@ -131,15 +123,11 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type|
it 'unmarks the repository as read-only without updating the repository storage' do it 'unmarks the repository as read-only without updating the repository storage' do
allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('default').and_call_original allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('default').and_call_original
allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('test_second_storage').and_return(SecureRandom.uuid) allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('test_second_storage').and_return(SecureRandom.uuid)
allow(project_repository_double).to receive(:create_repository)
.and_return(true)
allow(project_repository_double).to receive(:replicate) allow(project_repository_double).to receive(:replicate)
.with(project.repository.raw) .with(project.repository.raw)
allow(project_repository_double).to receive(:checksum) allow(project_repository_double).to receive(:checksum)
.and_return(project_repository_checksum) .and_return(project_repository_checksum)
allow(repository_double).to receive(:create_repository)
.and_return(true)
allow(repository_double).to receive(:replicate) allow(repository_double).to receive(:replicate)
.with(repository.raw) .with(repository.raw)
allow(repository_double).to receive(:checksum) allow(repository_double).to receive(:checksum)
......
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