Commit 74b7b3c3 authored by Michael Kozono's avatar Michael Kozono

Merge branch '328223-add-incident-metrics-image-to-geo-upload-types' into 'master'

Fix Geo replication for incident metrics uploads

See merge request gitlab-org/gitlab!59674
parents c21d167a 3806f085
---
title: Geo - Sync incident metrics uploads
merge_request: 59674
author:
type: fixed
...@@ -3,7 +3,18 @@ ...@@ -3,7 +3,18 @@
module Gitlab module Gitlab
module Geo module Geo
module Replication module Replication
USER_UPLOADS_OBJECT_TYPES = %i[attachment avatar file import_export namespace_file personal_file favicon design_management/design_v432x230].freeze USER_UPLOADS_OBJECT_TYPES = %i[
attachment
avatar
design_management/design_v432x230
favicon
file
import_export
issuable_metric_image
namespace_file
personal_file
].freeze
FILE_NOT_FOUND_GEO_CODE = 'FILE_NOT_FOUND' FILE_NOT_FOUND_GEO_CODE = 'FILE_NOT_FOUND'
def self.object_type_from_user_uploads?(object_type) def self.object_type_from_user_uploads?(object_type)
......
...@@ -8,11 +8,12 @@ FactoryBot.define do ...@@ -8,11 +8,12 @@ FactoryBot.define do
trait(:attachment) { file_type { :attachment } } trait(:attachment) { file_type { :attachment } }
trait(:avatar) { file_type { :avatar } } trait(:avatar) { file_type { :avatar } }
trait(:favicon) { file_type { :favicon } }
trait(:file) { file_type { :file } } trait(:file) { file_type { :file } }
trait(:import_export) { file_type { :import_export } }
trait(:issuable_metric_image) { file_type { :issuable_metric_image } }
trait(:namespace_file) { file_type { :namespace_file } } trait(:namespace_file) { file_type { :namespace_file } }
trait(:personal_file) { file_type { :personal_file } } trait(:personal_file) { file_type { :personal_file } }
trait(:favicon) { file_type { :favicon } }
trait(:import_export) { file_type { :import_export } }
trait :failed do trait :failed do
success { false } success { false }
......
# frozen_string_literal: true
FactoryBot.modify do
factory :upload do
trait :issue_metric_image do
model { association(:issuable_metric_image) }
mount_point { :file }
uploader { ::IssuableMetricImageUploader.name }
end
end
end
...@@ -433,6 +433,13 @@ RSpec.describe Geo::FileDownloadService do ...@@ -433,6 +433,13 @@ RSpec.describe Geo::FileDownloadService do
it_behaves_like 'a service that handles orphaned uploads', 'namespace_file' it_behaves_like 'a service that handles orphaned uploads', 'namespace_file'
end end
context 'with an incident metrics upload' do
let(:file) { create(:upload, :issue_metric_image) }
it_behaves_like 'a service that downloads the file and registers the sync result', 'issuable_metric_image'
it_behaves_like 'a service that handles orphaned uploads', 'issuable_metric_image'
end
context 'LFS object' do context 'LFS object' do
it_behaves_like "a service that downloads the file and registers the sync result", 'lfs' do it_behaves_like "a service that downloads the file and registers the sync result", 'lfs' do
let(:file) { create(:lfs_object) } let(:file) { create(:lfs_object) }
......
...@@ -162,6 +162,24 @@ RSpec.describe Geo::FileUploadService do ...@@ -162,6 +162,24 @@ RSpec.describe Geo::FileUploadService do
include_examples 'no decoded params' include_examples 'no decoded params'
end end
context 'incident metrics upload' do
let(:incident_metric_image) { create(:issuable_metric_image) }
let(:upload) { Upload.find_by(model: incident_metric_image, uploader: ::IssuableMetricImageUploader.name) }
let(:params) { { id: upload.id, type: 'issuable_metric_image' } }
let(:request_data) { Gitlab::Geo::Replication::FileTransfer.new(:file, upload).request_data }
it 'sends the file' do
service = described_class.new(params, request_data)
response = service.execute
expect(response[:code]).to eq(:ok)
expect(response[:file].path).to eq(incident_metric_image.file.path)
end
include_examples 'no decoded params'
end
context 'LFS Object' do context 'LFS Object' do
let(:lfs_object) { create(:lfs_object, :with_file) } let(:lfs_object) { create(:lfs_object, :with_file) }
let(:params) { { id: lfs_object.id, type: 'lfs' } } let(:params) { { id: lfs_object.id, type: 'lfs' } }
......
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