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