Commit c4372c85 authored by Sean McGivern's avatar Sean McGivern

Merge branch '233627-fj-restore-snippets-in-backups' into 'master'

Restore snippets from backups

See merge request gitlab-org/gitlab!43696
parents db6ca452 4f93e8f3
---
title: Restore snippet repositories from backups
merge_request: 43696
author:
type: changed
......@@ -46,6 +46,10 @@ module Backup
restore_repository(project, Gitlab::GlRepository::DESIGN)
end
Snippet.find_each(batch_size: 1000) do |snippet|
restore_repository(snippet, Gitlab::GlRepository::SNIPPET)
end
restore_object_pools
end
......
......@@ -159,12 +159,16 @@ RSpec.describe Backup::Repositories do
describe '#restore' do
let_it_be(:project) { create(:project) }
let_it_be(:personal_snippet) { create(:personal_snippet, author: project.owner) }
let_it_be(:project_snippet) { create(:project_snippet, project: project, author: project.owner) }
it 'restores repositories from bundles', :aggregate_failures do
next_path_to_bundle = [
Rails.root.join('spec/fixtures/lib/backup/project_repo.bundle'),
Rails.root.join('spec/fixtures/lib/backup/wiki_repo.bundle'),
Rails.root.join('spec/fixtures/lib/backup/design_repo.bundle')
Rails.root.join('spec/fixtures/lib/backup/design_repo.bundle'),
Rails.root.join('spec/fixtures/lib/backup/personal_snippet_repo.bundle'),
Rails.root.join('spec/fixtures/lib/backup/project_snippet_repo.bundle')
].to_enum
allow_next_instance_of(described_class::BackupRestore) do |backup_restore|
......@@ -178,6 +182,8 @@ RSpec.describe Backup::Repositories do
expect(collect_commit_shas.call(project.repository)).to eq(['393a7d860a5a4c3cc736d7eb00604e3472bb95ec'])
expect(collect_commit_shas.call(project.wiki.repository)).to eq(['c74b9948d0088d703ee1fafeddd9ed9add2901ea'])
expect(collect_commit_shas.call(project.design_repository)).to eq(['c3cd4d7bd73a51a0f22045c3a4c871c435dc959d'])
expect(collect_commit_shas.call(personal_snippet.repository)).to eq(['3b3c067a3bc1d1b695b51e2be30c0f8cf698a06e'])
expect(collect_commit_shas.call(project_snippet.repository)).to eq(['6e44ba56a4748be361a841e759c20e421a1651a1'])
end
describe 'command failure' do
......@@ -228,7 +234,9 @@ RSpec.describe Backup::Repositories do
expect_next_instance_of(DesignManagement::Repository) do |repository|
expect(repository).to receive(:remove)
end
expect(Repository).to receive(:new).twice.and_wrap_original do |method, *original_args|
# 4 times = project repo + wiki repo + project_snippet repo + personal_snippet repo
expect(Repository).to receive(:new).exactly(4).times.and_wrap_original do |method, *original_args|
repository = method.call(*original_args)
expect(repository).to receive(:remove)
......
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