Send a Geo hashed migration event when migrating to hashed storage

parent 2307b35f
......@@ -27,7 +27,7 @@ module Geo
end
def old_wiki_disk_path
"#{old_disk_path}.wiki"
params.fetch(:old_wiki_disk_path)
end
end
end
......@@ -4,7 +4,7 @@ module Projects
prepend ::EE::Projects::HashedStorageMigrationService
attr_reader :old_disk_path, :new_disk_path
attr_reader :old_disk_path, :new_disk_path, :old_wiki_disk_path, :old_storage_version
def initialize(project, logger = nil)
@project = project
......@@ -17,6 +17,7 @@ module Projects
@old_disk_path = project.disk_path
has_wiki = project.wiki.repository_exists?
@old_storage_version = project.storage_version
project.storage_version = Storage::HashedProject::STORAGE_VERSION
project.ensure_storage_path_exists
......@@ -25,7 +26,8 @@ module Projects
result = move_repository(@old_disk_path, @new_disk_path)
if has_wiki
result &&= move_repository("#{@old_disk_path}.wiki", "#{@new_disk_path}.wiki")
@old_wiki_disk_path = "#{@old_disk_path}.wiki"
result &&= move_repository(@old_wiki_disk_path, "#{@new_disk_path}.wiki")
end
unless result
......
......@@ -5,10 +5,11 @@ module EE
raise NotImplementedError.new unless defined?(super)
super do
::Geo::RepositoryRenamedEventStore.new(
::Geo::HashedStorageMigratedEventStore.new(
project,
old_path: File.basename(old_disk_path),
old_path_with_namespace: old_disk_path
old_storage_version: old_storage_version,
old_disk_path: old_disk_path,
old_wiki_disk_path: old_wiki_disk_path
).create
end
end
......
......@@ -10,19 +10,19 @@ describe Projects::HashedStorageMigrationService do
set(:primary) { create(:geo_node, :primary) }
set(:secondary) { create(:geo_node) }
it 'creates a Geo::RepositoryRenamedEvent on success' do
expect { service.execute }.to change { Geo::EventLog.count }.by(1)
it 'creates a Geo::HashedStorageMigratedEvent on success' do
expect { service.execute }.to change(Geo::EventLog, :count).by(1)
event = Geo::EventLog.first.event
expect(event).to be_a(Geo::RepositoryRenamedEvent)
expect(event).to be_a(Geo::HashedStorageMigratedEvent)
expect(event).to have_attributes(
old_path: project.path,
new_path: project.path,
old_path_with_namespace: legacy_storage.disk_path,
new_path_with_namespace: hashed_storage.disk_path,
old_wiki_path_with_namespace: legacy_storage.disk_path + '.wiki',
new_wiki_path_with_namespace: hashed_storage.disk_path + '.wiki'
old_storage_version: nil,
new_storage_version: Storage::HashedProject::STORAGE_VERSION,
old_disk_path: legacy_storage.disk_path,
new_disk_path: hashed_storage.disk_path,
old_wiki_disk_path: legacy_storage.disk_path + '.wiki',
new_wiki_disk_path: hashed_storage.disk_path + '.wiki'
)
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