Commit a87c6a70 authored by Michael Kozono's avatar Michael Kozono

Merge branch '254248-geo-blob-removal-doesn-t-work-for-ssf-blobs-2' into 'master'

Fix: [Geo] Blob removal doesn't work for SSF blobs

Closes #254248

See merge request gitlab-org/gitlab!42891
parents 464484f7 a3431a26
---
title: 'Fix: [Geo] Blob removal doesn''t work for SSF blobs'
merge_request: 42891
author:
type: fixed
...@@ -241,11 +241,6 @@ module Gitlab ...@@ -241,11 +241,6 @@ module Gitlab
consume_method = "consume_event_#{event_name}".to_sym consume_method = "consume_event_#{event_name}".to_sym
raise NotImplementedError, "Consume method not implemented: '#{consume_method}'" unless self.methods.include?(consume_method) raise NotImplementedError, "Consume method not implemented: '#{consume_method}'" unless self.methods.include?(consume_method)
# Inject model_record based on included class
if model_record
event_data[:model_record] = model_record
end
send(consume_method, **event_data) # rubocop:disable GitlabSecurity/PublicSend send(consume_method, **event_data) # rubocop:disable GitlabSecurity/PublicSend
end end
......
...@@ -106,7 +106,7 @@ RSpec.shared_examples 'a blob replicator' do ...@@ -106,7 +106,7 @@ RSpec.shared_examples 'a blob replicator' do
end end
end end
describe '#consume_event_created' do describe 'created event consumption' do
context "when the blob's project is in replicables for this geo node" do context "when the blob's project is in replicables for this geo node" do
it 'invokes Geo::BlobDownloadService' do it 'invokes Geo::BlobDownloadService' do
expect(replicator).to receive(:in_replicables_for_geo_node?).and_return(true) expect(replicator).to receive(:in_replicables_for_geo_node?).and_return(true)
...@@ -115,7 +115,7 @@ RSpec.shared_examples 'a blob replicator' do ...@@ -115,7 +115,7 @@ RSpec.shared_examples 'a blob replicator' do
expect(service).to receive(:execute) expect(service).to receive(:execute)
expect(::Geo::BlobDownloadService).to receive(:new).with(replicator: replicator).and_return(service) expect(::Geo::BlobDownloadService).to receive(:new).with(replicator: replicator).and_return(service)
replicator.consume_event_created replicator.consume(:created)
end end
end end
...@@ -125,12 +125,16 @@ RSpec.shared_examples 'a blob replicator' do ...@@ -125,12 +125,16 @@ RSpec.shared_examples 'a blob replicator' do
expect(::Geo::BlobDownloadService).not_to receive(:new) expect(::Geo::BlobDownloadService).not_to receive(:new)
replicator.consume_event_created replicator.consume(:created)
end end
end end
end end
describe '#consume_event_deleted' do describe 'deleted event consumption' do
before do
model_record.save!
end
let!(:model_record_id) { replicator.model_record_id } let!(:model_record_id) { replicator.model_record_id }
let!(:blob_path) { replicator.blob_path } let!(:blob_path) { replicator.blob_path }
let!(:deleted_params) { { model_record_id: model_record_id, blob_path: blob_path } } let!(:deleted_params) { { model_record_id: model_record_id, blob_path: blob_path } }
...@@ -145,7 +149,7 @@ RSpec.shared_examples 'a blob replicator' do ...@@ -145,7 +149,7 @@ RSpec.shared_examples 'a blob replicator' do
# replicator does not hold an instance of ActiveRecord::Base, which helps # replicator does not hold an instance of ActiveRecord::Base, which helps
# avoid a regression of # avoid a regression of
# https://gitlab.com/gitlab-org/gitlab/-/issues/233040 # https://gitlab.com/gitlab-org/gitlab/-/issues/233040
let(:secondary_side_replicator) { replicator.class.new(model_record: nil, model_record_id: model_record_id) } let(:secondary_side_replicator) { replicator.class.new(model_record_id: model_record_id) }
it 'invokes Geo::FileRegistryRemovalService' do it 'invokes Geo::FileRegistryRemovalService' do
service = double(:service) service = double(:service)
...@@ -154,7 +158,7 @@ RSpec.shared_examples 'a blob replicator' do ...@@ -154,7 +158,7 @@ RSpec.shared_examples 'a blob replicator' do
expect(::Geo::FileRegistryRemovalService) expect(::Geo::FileRegistryRemovalService)
.to receive(:new).with(secondary_side_replicator.replicable_name, model_record_id, blob_path).and_return(service) .to receive(:new).with(secondary_side_replicator.replicable_name, model_record_id, blob_path).and_return(service)
secondary_side_replicator.consume_event_deleted(deleted_params) secondary_side_replicator.consume(:deleted, deleted_params)
end end
end end
end end
......
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