Add a bang suffix to Geo::EventStore#create method

The Geo::EventStore#create method doesn't have a ! on the end
of it. It should, since its behaviour is to raise an exception
if the validation or the save fails.
parent f7f872fc
...@@ -16,7 +16,7 @@ module EE ...@@ -16,7 +16,7 @@ module EE
private private
def log_geo_event def log_geo_event
::Geo::JobArtifactDeletedEventStore.new(self).create ::Geo::JobArtifactDeletedEventStore.new(self).create!
end end
end end
end end
...@@ -16,7 +16,7 @@ module EE ...@@ -16,7 +16,7 @@ module EE
private private
def log_geo_event def log_geo_event
::Geo::LfsObjectDeletedEventStore.new(self).create ::Geo::LfsObjectDeletedEventStore.new(self).create!
end end
end end
end end
...@@ -57,7 +57,7 @@ module EE ...@@ -57,7 +57,7 @@ module EE
project, project,
old_path: project.path, old_path: project.path,
old_path_with_namespace: old_path_with_namespace_for(project) old_path_with_namespace: old_path_with_namespace_for(project)
).create ).create!
end end
end end
......
...@@ -602,7 +602,7 @@ module EE ...@@ -602,7 +602,7 @@ module EE
self, self,
old_path: path_before, old_path: path_before,
old_path_with_namespace: full_path_before old_path_with_namespace: full_path_before
).create ).create!
end end
end end
end end
...@@ -15,7 +15,7 @@ module EE ...@@ -15,7 +15,7 @@ module EE
private private
def log_geo_event def log_geo_event
::Geo::UploadDeletedEventStore.new(self).create ::Geo::UploadDeletedEventStore.new(self).create!
end end
end end
end end
...@@ -38,7 +38,7 @@ module EE ...@@ -38,7 +38,7 @@ module EE
private private
def log_geo_event(project) def log_geo_event(project)
::Geo::RepositoryCreatedEventStore.new(project).create ::Geo::RepositoryCreatedEventStore.new(project).create!
end end
override :after_create_actions override :after_create_actions
......
...@@ -36,7 +36,7 @@ module EE ...@@ -36,7 +36,7 @@ module EE
project, project,
repo_path: repo_path, repo_path: repo_path,
wiki_path: wiki_path wiki_path: wiki_path
).create ).create!
end end
# Removes physical repository in a Geo replicated secondary node # Removes physical repository in a Geo replicated secondary node
......
...@@ -11,7 +11,7 @@ module EE ...@@ -11,7 +11,7 @@ module EE
project, project,
old_attachments_path: old_disk_path, old_attachments_path: old_disk_path,
new_attachments_path: new_disk_path new_attachments_path: new_disk_path
).create ).create!
end end
end end
end end
......
...@@ -12,7 +12,7 @@ module EE ...@@ -12,7 +12,7 @@ module EE
old_storage_version: old_storage_version, old_storage_version: old_storage_version,
old_disk_path: old_disk_path, old_disk_path: old_disk_path,
old_wiki_disk_path: old_wiki_disk_path old_wiki_disk_path: old_wiki_disk_path
).create ).create!
end end
end end
end end
......
...@@ -15,7 +15,7 @@ module EE ...@@ -15,7 +15,7 @@ module EE
project, project,
old_path: project.path, old_path: project.path,
old_path_with_namespace: @old_path # rubocop:disable Gitlab/ModuleWithInstanceVariables old_path_with_namespace: @old_path # rubocop:disable Gitlab/ModuleWithInstanceVariables
).create ).create!
end end
end end
end end
......
...@@ -30,7 +30,7 @@ module Geo ...@@ -30,7 +30,7 @@ module Geo
@params = params @params = params
end end
def create def create!
return unless Gitlab::Geo.primary? return unless Gitlab::Geo.primary?
return unless Gitlab::Geo.secondary_nodes.any? # no need to create an event if no one is listening return unless Gitlab::Geo.secondary_nodes.any? # no need to create an event if no one is listening
......
module Geo module Geo
class JobArtifactDeletedEventStore < EventStore class JobArtifactDeletedEventStore < EventStore
extend ::Gitlab::Utils::Override
self.event_type = :job_artifact_deleted_event self.event_type = :job_artifact_deleted_event
attr_reader :job_artifact attr_reader :job_artifact
...@@ -8,7 +10,8 @@ module Geo ...@@ -8,7 +10,8 @@ module Geo
@job_artifact = job_artifact @job_artifact = job_artifact
end end
def create override :create!
def create!
return unless job_artifact.local_store? return unless job_artifact.local_store?
super super
......
module Geo module Geo
class LfsObjectDeletedEventStore < EventStore class LfsObjectDeletedEventStore < EventStore
extend ::Gitlab::Utils::Override
self.event_type = :lfs_object_deleted_event self.event_type = :lfs_object_deleted_event
attr_reader :lfs_object attr_reader :lfs_object
...@@ -8,7 +10,8 @@ module Geo ...@@ -8,7 +10,8 @@ module Geo
@lfs_object = lfs_object @lfs_object = lfs_object
end end
def create override :create!
def create!
return unless lfs_object.local_store? return unless lfs_object.local_store?
super super
......
...@@ -15,7 +15,7 @@ module Geo ...@@ -15,7 +15,7 @@ module Geo
def execute def execute
return false unless geo_node.update(params) return false unless geo_node.update(params)
Geo::RepositoriesChangedEventStore.new(geo_node).create if selective_sync_changed? Geo::RepositoriesChangedEventStore.new(geo_node).create! if selective_sync_changed?
true true
end end
......
...@@ -30,7 +30,7 @@ module Geo ...@@ -30,7 +30,7 @@ module Geo
def create_repository_updated_event! def create_repository_updated_event!
Geo::RepositoryUpdatedEventStore.new( Geo::RepositoryUpdatedEventStore.new(
project, refs: refs, changes: changes, source: source project, refs: refs, changes: changes, source: source
).create ).create!
end end
def reset_repository_checksum! def reset_repository_checksum!
......
module Geo module Geo
class UploadDeletedEventStore < EventStore class UploadDeletedEventStore < EventStore
extend ::Gitlab::Utils::Override
self.event_type = :upload_deleted_event self.event_type = :upload_deleted_event
attr_reader :upload attr_reader :upload
...@@ -8,7 +10,8 @@ module Geo ...@@ -8,7 +10,8 @@ module Geo
@upload = upload @upload = upload
end end
def create override :create!
def create!
return unless upload.local? return unless upload.local?
super super
......
...@@ -27,7 +27,7 @@ describe Geo::HashedStorageAttachmentsEventStore do ...@@ -27,7 +27,7 @@ describe Geo::HashedStorageAttachmentsEventStore do
end end
it 'tracks project attributes' do it 'tracks project attributes' do
subject.create subject.create!
expect(Geo::HashedStorageAttachmentsEvent.last).to have_attributes( expect(Geo::HashedStorageAttachmentsEvent.last).to have_attributes(
old_attachments_path: old_attachments_path, old_attachments_path: old_attachments_path,
......
...@@ -26,7 +26,7 @@ describe Geo::HashedStorageMigratedEventStore do ...@@ -26,7 +26,7 @@ describe Geo::HashedStorageMigratedEventStore do
end end
it 'tracks project attributes' do it 'tracks project attributes' do
subject.create subject.create!
expect(Geo::HashedStorageMigratedEvent.last).to have_attributes( expect(Geo::HashedStorageMigratedEvent.last).to have_attributes(
repository_storage_name: project.repository_storage, repository_storage_name: project.repository_storage,
......
...@@ -22,11 +22,11 @@ describe Geo::JobArtifactDeletedEventStore do ...@@ -22,11 +22,11 @@ describe Geo::JobArtifactDeletedEventStore do
it 'does not create an event when LFS object is not on a local store' do it 'does not create an event when LFS object is not on a local store' do
allow(job_artifact).to receive(:local_store?).and_return(false) allow(job_artifact).to receive(:local_store?).and_return(false)
expect { subject.create }.not_to change(Geo::JobArtifactDeletedEvent, :count) expect { subject.create! }.not_to change(Geo::JobArtifactDeletedEvent, :count)
end end
it 'tracks LFS object attributes' do it 'tracks LFS object attributes' do
subject.create subject.create!
expect(Geo::JobArtifactDeletedEvent.last).to have_attributes( expect(Geo::JobArtifactDeletedEvent.last).to have_attributes(
job_artifact_id: job_artifact.id, job_artifact_id: job_artifact.id,
...@@ -49,7 +49,7 @@ describe Geo::JobArtifactDeletedEventStore do ...@@ -49,7 +49,7 @@ describe Geo::JobArtifactDeletedEventStore do
expect(Gitlab::Geo::Logger).to receive(:error) expect(Gitlab::Geo::Logger).to receive(:error)
.with(expected_message).and_call_original .with(expected_message).and_call_original
subject.create subject.create!
end end
end end
end end
......
...@@ -22,11 +22,11 @@ describe Geo::LfsObjectDeletedEventStore do ...@@ -22,11 +22,11 @@ describe Geo::LfsObjectDeletedEventStore do
it 'does not create an event when LFS object is not on a local store' do it 'does not create an event when LFS object is not on a local store' do
allow(lfs_object).to receive(:local_store?).and_return(false) allow(lfs_object).to receive(:local_store?).and_return(false)
expect { subject.create }.not_to change(Geo::LfsObjectDeletedEvent, :count) expect { subject.create! }.not_to change(Geo::LfsObjectDeletedEvent, :count)
end end
it 'tracks LFS object attributes' do it 'tracks LFS object attributes' do
subject.create subject.create!
expect(Geo::LfsObjectDeletedEvent.last).to have_attributes( expect(Geo::LfsObjectDeletedEvent.last).to have_attributes(
lfs_object_id: lfs_object.id, lfs_object_id: lfs_object.id,
...@@ -50,7 +50,7 @@ describe Geo::LfsObjectDeletedEventStore do ...@@ -50,7 +50,7 @@ describe Geo::LfsObjectDeletedEventStore do
expect(Gitlab::Geo::Logger).to receive(:error) expect(Gitlab::Geo::Logger).to receive(:error)
.with(expected_message).and_call_original .with(expected_message).and_call_original
subject.create subject.create!
end end
end end
end end
......
...@@ -19,7 +19,7 @@ describe Geo::RepositoryCreatedEventStore do ...@@ -19,7 +19,7 @@ describe Geo::RepositoryCreatedEventStore do
end end
it 'tracks information for the created project' do it 'tracks information for the created project' do
subject.create subject.create!
expect(Geo::RepositoryCreatedEvent.last).to have_attributes( expect(Geo::RepositoryCreatedEvent.last).to have_attributes(
project_id: project.id, project_id: project.id,
...@@ -33,7 +33,7 @@ describe Geo::RepositoryCreatedEventStore do ...@@ -33,7 +33,7 @@ describe Geo::RepositoryCreatedEventStore do
it 'does not set a wiki path if the wiki is disabled' do it 'does not set a wiki path if the wiki is disabled' do
project.update!(wiki_enabled: false) project.update!(wiki_enabled: false)
subject.create subject.create!
expect(Geo::RepositoryCreatedEvent.last.wiki_path).to be_nil expect(Geo::RepositoryCreatedEvent.last.wiki_path).to be_nil
end end
......
...@@ -25,7 +25,7 @@ describe Geo::RepositoryDeletedEventStore do ...@@ -25,7 +25,7 @@ describe Geo::RepositoryDeletedEventStore do
end end
it 'tracks information for the deleted project' do it 'tracks information for the deleted project' do
subject.create subject.create!
expect(Geo::RepositoryDeletedEvent.last).to have_attributes( expect(Geo::RepositoryDeletedEvent.last).to have_attributes(
project_id: project_id, project_id: project_id,
......
...@@ -22,7 +22,7 @@ describe Geo::RepositoryRenamedEventStore do ...@@ -22,7 +22,7 @@ describe Geo::RepositoryRenamedEventStore do
end end
it 'tracks old and new paths for project repositories' do it 'tracks old and new paths for project repositories' do
subject.create subject.create!
expect(Geo::RepositoryRenamedEvent.last).to have_attributes( expect(Geo::RepositoryRenamedEvent.last).to have_attributes(
repository_storage_name: project.repository_storage, repository_storage_name: project.repository_storage,
......
...@@ -30,7 +30,7 @@ describe Geo::RepositoryUpdatedEventStore do ...@@ -30,7 +30,7 @@ describe Geo::RepositoryUpdatedEventStore do
context 'when repository is being updated' do context 'when repository is being updated' do
it 'does not track ref name when post-receive event affect multiple refs' do it 'does not track ref name when post-receive event affect multiple refs' do
subject.create subject.create!
expect(Geo::RepositoryUpdatedEvent.last.ref).to be_nil expect(Geo::RepositoryUpdatedEvent.last.ref).to be_nil
end end
...@@ -40,19 +40,19 @@ describe Geo::RepositoryUpdatedEventStore do ...@@ -40,19 +40,19 @@ describe Geo::RepositoryUpdatedEventStore do
changes = [{ before: '123456', after: blankrev, ref: 'refs/heads/tést' }] changes = [{ before: '123456', after: blankrev, ref: 'refs/heads/tést' }]
subject = described_class.new(project, refs: refs, changes: changes) subject = described_class.new(project, refs: refs, changes: changes)
subject.create subject.create!
expect(Geo::RepositoryUpdatedEvent.last.ref).to eq 'refs/heads/tést' expect(Geo::RepositoryUpdatedEvent.last.ref).to eq 'refs/heads/tést'
end end
it 'tracks number of branches post-receive event affects' do it 'tracks number of branches post-receive event affects' do
subject.create subject.create!
expect(Geo::RepositoryUpdatedEvent.last.branches_affected).to eq 1 expect(Geo::RepositoryUpdatedEvent.last.branches_affected).to eq 1
end end
it 'tracks number of tags post-receive event affects' do it 'tracks number of tags post-receive event affects' do
subject.create subject.create!
expect(Geo::RepositoryUpdatedEvent.last.tags_affected).to eq 1 expect(Geo::RepositoryUpdatedEvent.last.tags_affected).to eq 1
end end
...@@ -65,7 +65,7 @@ describe Geo::RepositoryUpdatedEventStore do ...@@ -65,7 +65,7 @@ describe Geo::RepositoryUpdatedEventStore do
] ]
subject = described_class.new(project, refs: refs, changes: changes) subject = described_class.new(project, refs: refs, changes: changes)
subject.create subject.create!
expect(Geo::RepositoryUpdatedEvent.last.new_branch).to eq true expect(Geo::RepositoryUpdatedEvent.last.new_branch).to eq true
end end
...@@ -78,7 +78,7 @@ describe Geo::RepositoryUpdatedEventStore do ...@@ -78,7 +78,7 @@ describe Geo::RepositoryUpdatedEventStore do
] ]
subject = described_class.new(project, refs: refs, changes: changes) subject = described_class.new(project, refs: refs, changes: changes)
subject.create subject.create!
expect(Geo::RepositoryUpdatedEvent.last.remove_branch).to eq true expect(Geo::RepositoryUpdatedEvent.last.remove_branch).to eq true
end end
...@@ -88,7 +88,7 @@ describe Geo::RepositoryUpdatedEventStore do ...@@ -88,7 +88,7 @@ describe Geo::RepositoryUpdatedEventStore do
it 'does not track any information' do it 'does not track any information' do
subject = described_class.new(project, source: Geo::RepositoryUpdatedEvent::WIKI) subject = described_class.new(project, source: Geo::RepositoryUpdatedEvent::WIKI)
subject.create subject.create!
expect(Geo::RepositoryUpdatedEvent.last).to have_attributes( expect(Geo::RepositoryUpdatedEvent.last).to have_attributes(
ref: be_nil, ref: be_nil,
......
...@@ -19,7 +19,7 @@ describe Geo::ResetChecksumEventStore do ...@@ -19,7 +19,7 @@ describe Geo::ResetChecksumEventStore do
end end
it 'tracks the project that checksum must be wiped' do it 'tracks the project that checksum must be wiped' do
subject.create subject.create!
expect(Geo::ResetChecksumEvent.last).to have_attributes(project_id: project.id) expect(Geo::ResetChecksumEvent.last).to have_attributes(project_id: project.id)
end end
......
...@@ -22,11 +22,11 @@ describe Geo::UploadDeletedEventStore do ...@@ -22,11 +22,11 @@ describe Geo::UploadDeletedEventStore do
it 'does not create an event when the upload does not use local storage' do it 'does not create an event when the upload does not use local storage' do
allow(upload).to receive(:local?).and_return(false) allow(upload).to receive(:local?).and_return(false)
expect { subject.create }.not_to change(Geo::UploadDeletedEvent, :count) expect { subject.create! }.not_to change(Geo::UploadDeletedEvent, :count)
end end
it 'tracks upload attributes' do it 'tracks upload attributes' do
subject.create subject.create!
expect(Geo::UploadDeletedEvent.last).to have_attributes( expect(Geo::UploadDeletedEvent.last).to have_attributes(
upload_id: upload.id, upload_id: upload.id,
......
...@@ -7,7 +7,7 @@ shared_examples_for 'a Geo event store' do |event_class| ...@@ -7,7 +7,7 @@ shared_examples_for 'a Geo event store' do |event_class|
end end
it 'does not create an event ' do it 'does not create an event ' do
expect { subject.create }.not_to change(event_class, :count) expect { subject.create! }.not_to change(event_class, :count)
end end
end end
...@@ -19,11 +19,11 @@ shared_examples_for 'a Geo event store' do |event_class| ...@@ -19,11 +19,11 @@ shared_examples_for 'a Geo event store' do |event_class|
it 'does not create an event if there are no secondary nodes' do it 'does not create an event if there are no secondary nodes' do
allow(Gitlab::Geo).to receive(:secondary_nodes) { [] } allow(Gitlab::Geo).to receive(:secondary_nodes) { [] }
expect { subject.create }.not_to change(event_class, :count) expect { subject.create! }.not_to change(event_class, :count)
end end
it 'creates an event' do it 'creates an event' do
expect { subject.create }.to change(event_class, :count).by(1) expect { subject.create! }.to change(event_class, :count).by(1)
end end
end end
end end
...@@ -34,7 +34,7 @@ describe PostReceive do ...@@ -34,7 +34,7 @@ describe PostReceive do
described_class.new.perform(gl_repository, key_id, base64_changes) described_class.new.perform(gl_repository, key_id, base64_changes)
end end
it 'does not call Geo::RepositoryUpdatedEventStore when not running on a Geo primary node' do it 'does not call Geo::RepositoryUpdatedService when not running on a Geo primary node' do
allow(Gitlab::Geo).to receive(:primary?) { false } allow(Gitlab::Geo).to receive(:primary?) { false }
expect_any_instance_of(::Geo::RepositoryUpdatedService).not_to receive(:execute) expect_any_instance_of(::Geo::RepositoryUpdatedService).not_to receive(:execute)
...@@ -47,7 +47,7 @@ describe PostReceive do ...@@ -47,7 +47,7 @@ describe PostReceive do
describe '#process_wiki_changes' do describe '#process_wiki_changes' do
let(:gl_repository) { "wiki-#{project.id}" } let(:gl_repository) { "wiki-#{project.id}" }
it 'calls Geo::RepositoryUpdatedEventStore when running on a Geo primary node' do it 'calls Geo::RepositoryUpdatedService when running on a Geo primary node' do
allow(Gitlab::Geo).to receive(:primary?) { true } allow(Gitlab::Geo).to receive(:primary?) { true }
expect_any_instance_of(::Geo::RepositoryUpdatedService).to receive(:execute) expect_any_instance_of(::Geo::RepositoryUpdatedService).to receive(:execute)
...@@ -55,7 +55,7 @@ describe PostReceive do ...@@ -55,7 +55,7 @@ describe PostReceive do
described_class.new.perform(gl_repository, key_id, base64_changes) described_class.new.perform(gl_repository, key_id, base64_changes)
end end
it 'does not call Geo::RepositoryUpdatedEventStore when not running on a Geo primary node' do it 'does not call Geo::RepositoryUpdatedService when not running on a Geo primary node' do
allow(Gitlab::Geo).to receive(:primary?) { false } allow(Gitlab::Geo).to receive(:primary?) { false }
expect_any_instance_of(::Geo::RepositoryUpdatedService).not_to receive(:execute) expect_any_instance_of(::Geo::RepositoryUpdatedService).not_to receive(:execute)
......
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