diff options
Diffstat (limited to 'spec/lib/backup/gitaly_backup_spec.rb')
-rw-r--r-- | spec/lib/backup/gitaly_backup_spec.rb | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/spec/lib/backup/gitaly_backup_spec.rb b/spec/lib/backup/gitaly_backup_spec.rb index 13567ead842..cdb35c0ce01 100644 --- a/spec/lib/backup/gitaly_backup_spec.rb +++ b/spec/lib/backup/gitaly_backup_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe Backup::GitalyBackup do + let(:parallel) { nil } + let(:parallel_storage) { nil } let(:progress) do Tempfile.new('progress').tap do |progress| progress.unlink @@ -13,7 +15,7 @@ RSpec.describe Backup::GitalyBackup do progress.close end - subject { described_class.new(progress) } + subject { described_class.new(progress, parallel: parallel, parallel_storage: parallel_storage) } context 'unknown' do it 'fails to start unknown' do @@ -30,6 +32,8 @@ RSpec.describe Backup::GitalyBackup do project_snippet = create(:project_snippet, :repository, project: project) personal_snippet = create(:personal_snippet, :repository, author: project.owner) + expect(Process).to receive(:spawn).with(anything, 'create', '-path', anything, { in: anything, out: progress }).and_call_original + subject.start(:create) subject.enqueue(project, Gitlab::GlRepository::PROJECT) subject.enqueue(project, Gitlab::GlRepository::WIKI) @@ -45,6 +49,28 @@ RSpec.describe Backup::GitalyBackup do expect(File).to exist(File.join(Gitlab.config.backup.path, 'repositories', project_snippet.disk_path + '.bundle')) end + context 'parallel option set' do + let(:parallel) { 3 } + + it 'passes parallel option through' do + expect(Process).to receive(:spawn).with(anything, 'create', '-path', anything, '-parallel', '3', { in: anything, out: progress }).and_call_original + + subject.start(:create) + subject.wait + end + end + + context 'parallel_storage option set' do + let(:parallel_storage) { 3 } + + it 'passes parallel option through' do + expect(Process).to receive(:spawn).with(anything, 'create', '-path', anything, '-parallel-storage', '3', { in: anything, out: progress }).and_call_original + + subject.start(:create) + subject.wait + end + end + it 'raises when the exit code not zero' do expect(subject).to receive(:bin_path).and_return(Gitlab::Utils.which('false')) @@ -83,6 +109,8 @@ RSpec.describe Backup::GitalyBackup do copy_bundle_to_backup_path('personal_snippet_repo.bundle', personal_snippet.disk_path + '.bundle') copy_bundle_to_backup_path('project_snippet_repo.bundle', project_snippet.disk_path + '.bundle') + expect(Process).to receive(:spawn).with(anything, 'restore', '-path', anything, { in: anything, out: progress }).and_call_original + subject.start(:restore) subject.enqueue(project, Gitlab::GlRepository::PROJECT) subject.enqueue(project, Gitlab::GlRepository::WIKI) @@ -100,6 +128,17 @@ RSpec.describe Backup::GitalyBackup do expect(collect_commit_shas.call(project_snippet.repository)).to eq(['6e44ba56a4748be361a841e759c20e421a1651a1']) end + context 'parallel option set' do + let(:parallel) { 3 } + + it 'does not pass parallel option through' do + expect(Process).to receive(:spawn).with(anything, 'restore', '-path', anything, { in: anything, out: progress }).and_call_original + + subject.start(:restore) + subject.wait + end + end + it 'raises when the exit code not zero' do expect(subject).to receive(:bin_path).and_return(Gitlab::Utils.which('false')) |