Commit 002819ad authored by Gabriel Mazetto's avatar Gabriel Mazetto

Rename Transfer to BaseTransfer

parent b7c83960
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module Gitlab module Gitlab
module Geo module Geo
module Replication module Replication
class Transfer class BaseTransfer
include LogHelpers include LogHelpers
attr_reader :file_type, :file_id, :filename, :expected_checksum, :request_data attr_reader :file_type, :file_id, :filename, :expected_checksum, :request_data
...@@ -127,7 +127,7 @@ module Gitlab ...@@ -127,7 +127,7 @@ module Gitlab
end end
def code_file_not_found?(geo_code) def code_file_not_found?(geo_code)
geo_code == Gitlab::Geo::FileUploader::FILE_NOT_FOUND_GEO_CODE geo_code == Gitlab::Geo::Replication::FileUploader::FILE_NOT_FOUND_GEO_CODE
end end
def default_permissions def default_permissions
......
...@@ -7,7 +7,7 @@ module Gitlab ...@@ -7,7 +7,7 @@ module Gitlab
# * Requesting an Upload file from the primary # * Requesting an Upload file from the primary
# * Saving it in the right place on successful download # * Saving it in the right place on successful download
# * Returning a detailed Result object # * Returning a detailed Result object
class FileTransfer < Transfer class FileTransfer < BaseTransfer
def initialize(file_type, upload) def initialize(file_type, upload)
super( super(
file_type, file_type,
......
...@@ -7,7 +7,7 @@ module Gitlab ...@@ -7,7 +7,7 @@ module Gitlab
# * Requesting an ::Ci::JobArtifact file from the primary # * Requesting an ::Ci::JobArtifact file from the primary
# * Saving it in the right place on successful download # * Saving it in the right place on successful download
# * Returning a detailed Result object # * Returning a detailed Result object
class JobArtifactTransfer < Transfer class JobArtifactTransfer < BaseTransfer
def initialize(job_artifact) def initialize(job_artifact)
super( super(
:job_artifact, :job_artifact,
......
...@@ -7,7 +7,7 @@ module Gitlab ...@@ -7,7 +7,7 @@ module Gitlab
# * Requesting an LfsObject file from the primary # * Requesting an LfsObject file from the primary
# * Saving it in the right place on successful download # * Saving it in the right place on successful download
# * Returning a detailed Result object # * Returning a detailed Result object
class LfsTransfer < Transfer class LfsTransfer < BaseTransfer
def initialize(lfs_object) def initialize(lfs_object)
super( super(
:lfs, :lfs,
......
...@@ -65,6 +65,7 @@ describe Gitlab::Geo::Replication::FileTransfer do ...@@ -65,6 +65,7 @@ describe Gitlab::Geo::Replication::FileTransfer do
it 'returns a failed result indicating primary_missing_file' do it 'returns a failed result indicating primary_missing_file' do
expect(FileUtils).not_to receive(:mv).with(anything, upload.absolute_path).and_call_original expect(FileUtils).not_to receive(:mv).with(anything, upload.absolute_path).and_call_original
response = double(:response, success?: false, code: 404, msg: "No such file") response = double(:response, success?: false, code: 404, msg: "No such file")
expect(File).to receive(:read).and_return("{\"geo_code\":\"#{Gitlab::Geo::Replication::FileUploader::FILE_NOT_FOUND_GEO_CODE}\"}") expect(File).to receive(:read).and_return("{\"geo_code\":\"#{Gitlab::Geo::Replication::FileUploader::FILE_NOT_FOUND_GEO_CODE}\"}")
expect(Gitlab::HTTP).to receive(:get).and_return(response) expect(Gitlab::HTTP).to receive(:get).and_return(response)
...@@ -78,6 +79,7 @@ describe Gitlab::Geo::Replication::FileTransfer do ...@@ -78,6 +79,7 @@ describe Gitlab::Geo::Replication::FileTransfer do
it 'returns a failed result' do it 'returns a failed result' do
expect(FileUtils).not_to receive(:mv).with(anything, upload.absolute_path).and_call_original expect(FileUtils).not_to receive(:mv).with(anything, upload.absolute_path).and_call_original
response = double(:response, success?: false, code: 404, msg: 'No such file') response = double(:response, success?: false, code: 404, msg: 'No such file')
expect(Gitlab::HTTP).to receive(:get).and_return(response) expect(Gitlab::HTTP).to receive(:get).and_return(response)
result = subject.download_from_primary result = subject.download_from_primary
......
...@@ -7,7 +7,7 @@ describe Gitlab::Geo::Replication::JobArtifactDownloader, :geo do ...@@ -7,7 +7,7 @@ describe Gitlab::Geo::Replication::JobArtifactDownloader, :geo do
context 'with job artifact' do context 'with job artifact' do
it 'returns a FileDownloader::Result object' do it 'returns a FileDownloader::Result object' do
downloader = described_class.new(:job_artifact, job_artifact.id) downloader = described_class.new(:job_artifact, job_artifact.id)
result = Gitlab::Geo::Replication::Transfer::Result.new(success: true, bytes_downloaded: 1) result = Gitlab::Geo::Replication::BaseTransfer::Result.new(success: true, bytes_downloaded: 1)
allow_any_instance_of(Gitlab::Geo::Replication::JobArtifactTransfer) allow_any_instance_of(Gitlab::Geo::Replication::JobArtifactTransfer)
.to receive(:download_from_primary).and_return(result) .to receive(:download_from_primary).and_return(result)
......
...@@ -7,7 +7,7 @@ describe Gitlab::Geo::Replication::LfsDownloader, :geo do ...@@ -7,7 +7,7 @@ describe Gitlab::Geo::Replication::LfsDownloader, :geo do
context 'with LFS object' do context 'with LFS object' do
it 'returns a FileDownloader::Result object' do it 'returns a FileDownloader::Result object' do
downloader = described_class.new(:lfs, lfs_object.id) downloader = described_class.new(:lfs, lfs_object.id)
result = Gitlab::Geo::Replication::Transfer::Result.new(success: true, bytes_downloaded: 1) result = Gitlab::Geo::Replication::BaseTransfer::Result.new(success: true, bytes_downloaded: 1)
allow_any_instance_of(Gitlab::Geo::Replication::LfsTransfer) allow_any_instance_of(Gitlab::Geo::Replication::LfsTransfer)
.to receive(:download_from_primary).and_return(result) .to receive(:download_from_primary).and_return(result)
......
...@@ -446,6 +446,6 @@ describe Geo::FileDownloadService do ...@@ -446,6 +446,6 @@ describe Geo::FileDownloadService do
success: success, success: success,
primary_missing_file: primary_missing_file) primary_missing_file: primary_missing_file)
instance = double("(instance of Gitlab::Geo::Replication::Transfer)", download_from_primary: result) instance = double("(instance of Gitlab::Geo::Replication::Transfer)", download_from_primary: result)
allow(Gitlab::Geo::Replication::Transfer).to receive(:new).and_return(instance) allow(Gitlab::Geo::Replication::BaseTransfer).to receive(:new).and_return(instance)
end end
end end
...@@ -312,7 +312,7 @@ describe Geo::FileDownloadDispatchWorker, :geo, :geo_fdw do ...@@ -312,7 +312,7 @@ describe Geo::FileDownloadDispatchWorker, :geo, :geo_fdw do
stub_const('Geo::Scheduler::SchedulerWorker::DB_RETRIEVE_BATCH_SIZE', 5) stub_const('Geo::Scheduler::SchedulerWorker::DB_RETRIEVE_BATCH_SIZE', 5)
secondary.update!(files_max_capacity: 2) secondary.update!(files_max_capacity: 2)
result_object = double(:result, success: true, bytes_downloaded: 100, primary_missing_file: false) result_object = double(:result, success: true, bytes_downloaded: 100, primary_missing_file: false)
allow_any_instance_of(::Gitlab::Geo::Replication::Transfer).to receive(:download_from_primary).and_return(result_object) allow_any_instance_of(::Gitlab::Geo::Replication::BaseTransfer).to receive(:download_from_primary).and_return(result_object)
avatar = fixture_file_upload('spec/fixtures/dk.png') avatar = fixture_file_upload('spec/fixtures/dk.png')
create_list(:lfs_object, 2, :with_file) create_list(:lfs_object, 2, :with_file)
......
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