Commit 1b4e1fa8 authored by James Fargher's avatar James Fargher

Use ReplicateRepository in favor of FetchInternalRemote

This was the last usage of FetchInternalRemote
parent 8cc82033
......@@ -65,7 +65,7 @@ module Projects
raw_repository.gl_repository,
full_path)
unless new_repository.fetch_repository_as_mirror(raw_repository)
unless new_repository.replicate(raw_repository)
raise Error, s_('UpdateRepositoryStorage|Failed to fetch %{type} repository as mirror') % { type: type.name }
end
......
---
title: Use ReplicateRepository when moving repo storage
merge_request: 26550
author:
type: changed
......@@ -312,7 +312,7 @@ describe Projects::ForkService do
# Stub everything required to move a project to a Gitaly shard that does not exist
stub_storage_settings('test_second_storage' => { 'path' => 'tmp/tests/second_storage' })
allow_any_instance_of(Gitlab::Git::Repository).to receive(:fetch_repository_as_mirror).and_return(true)
allow_any_instance_of(Gitlab::Git::Repository).to receive(:replicate).and_return(true)
allow_any_instance_of(Gitlab::Git::Repository).to receive(:checksum).and_return(::Gitlab::Git::BLANK_SHA)
Projects::UpdateRepositoryStorageService.new(project).execute('test_second_storage')
......
......@@ -32,7 +32,7 @@ describe Projects::UpdateRepositoryStorageService do
project.repository.path_to_repo
end
expect(project_repository_double).to receive(:fetch_repository_as_mirror)
expect(project_repository_double).to receive(:replicate)
.with(project.repository.raw).and_return(true)
expect(project_repository_double).to receive(:checksum)
.and_return(checksum)
......@@ -57,7 +57,7 @@ describe Projects::UpdateRepositoryStorageService do
context 'when the move fails' do
it 'unmarks the repository as read-only without updating the repository storage' do
expect(project_repository_double).to receive(:fetch_repository_as_mirror)
expect(project_repository_double).to receive(:replicate)
.with(project.repository.raw).and_return(false)
expect(GitlabShellWorker).not_to receive(:perform_async)
......@@ -71,7 +71,7 @@ describe Projects::UpdateRepositoryStorageService do
context 'when the checksum does not match' do
it 'unmarks the repository as read-only without updating the repository storage' do
expect(project_repository_double).to receive(:fetch_repository_as_mirror)
expect(project_repository_double).to receive(:replicate)
.with(project.repository.raw).and_return(true)
expect(project_repository_double).to receive(:checksum)
.and_return('not matching checksum')
......@@ -89,7 +89,7 @@ describe Projects::UpdateRepositoryStorageService do
let!(:pool) { create(:pool_repository, :ready, source_project: project) }
it 'leaves the pool' do
expect(project_repository_double).to receive(:fetch_repository_as_mirror)
expect(project_repository_double).to receive(:replicate)
.with(project.repository.raw).and_return(true)
expect(project_repository_double).to receive(:checksum)
.and_return(checksum)
......
......@@ -22,14 +22,15 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type|
context 'when the move succeeds', :clean_gitlab_redis_shared_state do
before do
allow(project_repository_double).to receive(:fetch_repository_as_mirror)
allow(project_repository_double).to receive(:replicate)
.with(project.repository.raw)
.and_return(true)
allow(project_repository_double).to receive(:checksum)
.and_return(project_repository_checksum)
allow(repository_double).to receive(:fetch_repository_as_mirror)
.with(repository.raw).and_return(true)
allow(repository_double).to receive(:replicate)
.with(repository.raw)
.and_return(true)
allow(repository_double).to receive(:checksum)
.and_return(repository_checksum)
end
......@@ -90,12 +91,15 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type|
context "when the move of the #{repository_type} repository fails" do
it 'unmarks the repository as read-only without updating the repository storage' do
allow(project_repository_double).to receive(:fetch_repository_as_mirror)
.with(project.repository.raw).and_return(true)
allow(project_repository_double).to receive(:replicate)
.with(project.repository.raw)
.and_return(true)
allow(project_repository_double).to receive(:checksum)
.and_return(project_repository_checksum)
allow(repository_double).to receive(:fetch_repository_as_mirror)
.with(repository.raw).and_return(false)
allow(repository_double).to receive(:replicate)
.with(repository.raw)
.and_return(false)
expect(GitlabShellWorker).not_to receive(:perform_async)
......@@ -109,12 +113,12 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type|
context "when the checksum of the #{repository_type} repository does not match" do
it 'unmarks the repository as read-only without updating the repository storage' do
allow(project_repository_double).to receive(:fetch_repository_as_mirror)
allow(project_repository_double).to receive(:replicate)
.with(project.repository.raw).and_return(true)
allow(project_repository_double).to receive(:checksum)
.and_return(project_repository_checksum)
allow(repository_double).to receive(:fetch_repository_as_mirror)
allow(repository_double).to receive(:replicate)
.with(repository.raw).and_return(true)
allow(repository_double).to receive(:checksum)
.and_return('not matching 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