diff options
Diffstat (limited to 'spec/lib/backup/gitaly_backup_spec.rb')
-rw-r--r-- | spec/lib/backup/gitaly_backup_spec.rb | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/spec/lib/backup/gitaly_backup_spec.rb b/spec/lib/backup/gitaly_backup_spec.rb index 7cc8ce2cbae..172fc28dd3e 100644 --- a/spec/lib/backup/gitaly_backup_spec.rb +++ b/spec/lib/backup/gitaly_backup_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Backup::GitalyBackup do +RSpec.describe Backup::GitalyBackup, feature_category: :backup_restore do let(:max_parallelism) { nil } let(:storage_parallelism) { nil } let(:destination) { File.join(Gitlab.config.backup.path, 'repositories') } @@ -17,7 +17,8 @@ RSpec.describe Backup::GitalyBackup do let(:expected_env) do { 'SSL_CERT_FILE' => Gitlab::X509::Certificate.default_cert_file, - 'SSL_CERT_DIR' => Gitlab::X509::Certificate.default_cert_dir + 'SSL_CERT_DIR' => Gitlab::X509::Certificate.default_cert_dir, + 'GITALY_SERVERS' => anything }.merge(ENV) end @@ -125,12 +126,18 @@ RSpec.describe Backup::GitalyBackup do } end + let(:expected_env) do + ssl_env.merge( + 'GITALY_SERVERS' => anything + ) + end + before do stub_const('ENV', ssl_env) end it 'passes through SSL envs' do - expect(Open3).to receive(:popen2).with(ssl_env, anything, 'create', '-path', anything, '-layout', 'pointer', '-id', backup_id).and_call_original + expect(Open3).to receive(:popen2).with(expected_env, anything, 'create', '-path', anything, '-layout', 'pointer', '-id', backup_id).and_call_original subject.start(:create, destination, backup_id: backup_id) subject.finish! @@ -174,6 +181,15 @@ RSpec.describe Backup::GitalyBackup do expect(collect_commit_shas.call(project_snippet.repository)).to match_array(['6e44ba56a4748be361a841e759c20e421a1651a1']) end + it 'clears specified storages when remove_all_repositories is set' do + expect(Open3).to receive(:popen2).with(expected_env, anything, 'restore', '-path', anything, '-layout', 'pointer', '-remove-all-repositories', 'default').and_call_original + + copy_bundle_to_backup_path('project_repo.bundle', project.disk_path + '.bundle') + subject.start(:restore, destination, backup_id: backup_id, remove_all_repositories: %w[default]) + subject.enqueue(project, Gitlab::GlRepository::PROJECT) + subject.finish! + end + context 'parallel option set' do let(:max_parallelism) { 3 } |