Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-10-19 15:57:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-10-19 15:57:54 +0300
commit419c53ec62de6e97a517abd5fdd4cbde3a942a34 (patch)
tree1f43a548b46bca8a5fb8fe0c31cef1883d49c5b6 /spec/lib/backup
parent1da20d9135b3ad9e75e65b028bffc921aaf8deb7 (diff)
Add latest changes from gitlab-org/gitlab@16-5-stable-eev16.5.0-rc42
Diffstat (limited to 'spec/lib/backup')
-rw-r--r--spec/lib/backup/database_model_spec.rb90
-rw-r--r--spec/lib/backup/database_spec.rb17
-rw-r--r--spec/lib/backup/files_spec.rb24
-rw-r--r--spec/lib/backup/manager_spec.rb21
-rw-r--r--spec/lib/backup/repositories_spec.rb38
-rw-r--r--spec/lib/backup/task_spec.rb2
6 files changed, 134 insertions, 58 deletions
diff --git a/spec/lib/backup/database_model_spec.rb b/spec/lib/backup/database_model_spec.rb
index 5758ad2c1aa..c9d036b37f8 100644
--- a/spec/lib/backup/database_model_spec.rb
+++ b/spec/lib/backup/database_model_spec.rb
@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe Backup::DatabaseModel, :reestablished_active_record_base, feature_category: :backup_restore do
+ using RSpec::Parameterized::TableSyntax
+
let(:gitlab_database_name) { 'main' }
describe '#connection' do
@@ -30,7 +32,7 @@ RSpec.describe Backup::DatabaseModel, :reestablished_active_record_base, feature
).to receive(:configuration_hash).and_return(application_config)
end
- context 'when no GITLAB_BACKUP_PG* variables are set' do
+ shared_examples 'no configuration is overridden' do
it 'ActiveRecord backup configuration is expected to equal application configuration' do
expect(subject[:activerecord]).to eq(application_config)
end
@@ -45,9 +47,23 @@ RSpec.describe Backup::DatabaseModel, :reestablished_active_record_base, feature
end
end
- context 'when GITLAB_BACKUP_PG* variables are set' do
- using RSpec::Parameterized::TableSyntax
+ shared_examples 'environment variables override application configuration' do
+ let(:active_record_key) { described_class::SUPPORTED_OVERRIDES.invert[pg_env] }
+
+ it 'ActiveRecord backup configuration overrides application configuration' do
+ expect(subject[:activerecord]).to eq(application_config.merge(active_record_key => overridden_value))
+ end
+
+ it 'PostgreSQL ENV overrides application configuration' do
+ expect(subject[:pg_env]).to include({ pg_env => overridden_value })
+ end
+ end
+ context 'when no GITLAB_BACKUP_PG* variables are set' do
+ it_behaves_like 'no configuration is overridden'
+ end
+
+ context 'when GITLAB_BACKUP_PG* variables are set' do
where(:env_variable, :overridden_value) do
'GITLAB_BACKUP_PGHOST' | 'test.invalid.'
'GITLAB_BACKUP_PGUSER' | 'some_user'
@@ -63,18 +79,76 @@ RSpec.describe Backup::DatabaseModel, :reestablished_active_record_base, feature
with_them do
let(:pg_env) { env_variable[/GITLAB_BACKUP_(\w+)/, 1] }
- let(:active_record_key) { described_class::SUPPORTED_OVERRIDES.invert[pg_env] }
before do
stub_env(env_variable, overridden_value)
end
- it 'ActiveRecord backup configuration overrides application configuration' do
- expect(subject[:activerecord]).to eq(application_config.merge(active_record_key => overridden_value))
+ it_behaves_like 'environment variables override application configuration'
+ end
+ end
+
+ context 'when GITLAB_BACKUP_<DBNAME>_PG* variables are set' do
+ context 'and environment variables are for the current database name' do
+ where(:env_variable, :overridden_value) do
+ 'GITLAB_BACKUP_MAIN_PGHOST' | 'test.invalid.'
+ 'GITLAB_BACKUP_MAIN_PGUSER' | 'some_user'
+ 'GITLAB_BACKUP_MAIN_PGPORT' | '1543'
+ 'GITLAB_BACKUP_MAIN_PGPASSWORD' | 'secret'
+ 'GITLAB_BACKUP_MAIN_PGSSLMODE' | 'allow'
+ 'GITLAB_BACKUP_MAIN_PGSSLKEY' | 'some_key'
+ 'GITLAB_BACKUP_MAIN_PGSSLCERT' | '/path/to/cert'
+ 'GITLAB_BACKUP_MAIN_PGSSLROOTCERT' | '/path/to/root/cert'
+ 'GITLAB_BACKUP_MAIN_PGSSLCRL' | '/path/to/crl'
+ 'GITLAB_BACKUP_MAIN_PGSSLCOMPRESSION' | '1'
+ end
+
+ with_them do
+ let(:pg_env) { env_variable[/GITLAB_BACKUP_MAIN_(\w+)/, 1] }
+
+ before do
+ stub_env(env_variable, overridden_value)
+ end
+
+ it_behaves_like 'environment variables override application configuration'
+ end
+ end
+
+ context 'and environment variables are for another database' do
+ where(:env_variable, :overridden_value) do
+ 'GITLAB_BACKUP_CI_PGHOST' | 'test.invalid.'
+ 'GITLAB_BACKUP_CI_PGUSER' | 'some_user'
+ 'GITLAB_BACKUP_CI_PGPORT' | '1543'
+ 'GITLAB_BACKUP_CI_PGPASSWORD' | 'secret'
+ 'GITLAB_BACKUP_CI_PGSSLMODE' | 'allow'
+ 'GITLAB_BACKUP_CI_PGSSLKEY' | 'some_key'
+ 'GITLAB_BACKUP_CI_PGSSLCERT' | '/path/to/cert'
+ 'GITLAB_BACKUP_CI_PGSSLROOTCERT' | '/path/to/root/cert'
+ 'GITLAB_BACKUP_CI_PGSSLCRL' | '/path/to/crl'
+ 'GITLAB_BACKUP_CI_PGSSLCOMPRESSION' | '1'
+ end
+
+ with_them do
+ let(:pg_env) { env_variable[/GITLAB_BACKUP_CI_(\w+)/, 1] }
+
+ before do
+ stub_env(env_variable, overridden_value)
+ end
+
+ it_behaves_like 'no configuration is overridden'
+ end
+ end
+
+ context 'when both GITLAB_BACKUP_PGUSER and GITLAB_BACKUP_MAIN_PGUSER variable are present' do
+ before do
+ stub_env('GITLAB_BACKUP_PGUSER', 'generic_user')
+ stub_env('GITLAB_BACKUP_MAIN_PGUSER', 'specfic_user')
end
- it 'PostgreSQL ENV overrides application configuration' do
- expect(subject[:pg_env]).to include({ pg_env => overridden_value })
+ it 'prefers more specific GITLAB_BACKUP_MAIN_PGUSER' do
+ config = subject
+ expect(config.dig(:activerecord, :username)).to eq('specfic_user')
+ expect(config.dig(:pg_env, 'PGUSER')).to eq('specfic_user')
end
end
end
diff --git a/spec/lib/backup/database_spec.rb b/spec/lib/backup/database_spec.rb
index 2f14b403576..073efbbbfcc 100644
--- a/spec/lib/backup/database_spec.rb
+++ b/spec/lib/backup/database_spec.rb
@@ -5,6 +5,7 @@ require 'spec_helper'
RSpec.describe Backup::Database, :reestablished_active_record_base, feature_category: :backup_restore do
let(:progress) { StringIO.new }
let(:output) { progress.string }
+ let(:backup_id) { 'some_id' }
let(:one_database_configured?) { base_models_for_backup.one? }
let(:timeout_service) do
instance_double(Gitlab::Database::TransactionTimeoutSettings, restore_timeouts: nil, disable_timeouts: nil)
@@ -17,7 +18,6 @@ RSpec.describe Backup::Database, :reestablished_active_record_base, feature_cate
end
before(:all) do # rubocop:disable RSpec/BeforeAll
- Rake::Task.define_task(:environment)
Rake.application.rake_require 'active_record/railties/databases'
Rake.application.rake_require 'tasks/gitlab/backup'
Rake.application.rake_require 'tasks/gitlab/shell'
@@ -26,7 +26,6 @@ RSpec.describe Backup::Database, :reestablished_active_record_base, feature_cate
end
describe '#dump', :delete do
- let(:backup_id) { 'some_id' }
let(:force) { true }
subject { described_class.new(progress, force: force) }
@@ -222,7 +221,7 @@ RSpec.describe Backup::Database, :reestablished_active_record_base, feature_cate
expect(Rake::Task['gitlab:db:drop_tables:main']).to receive(:invoke)
end
- subject.restore(backup_dir)
+ subject.restore(backup_dir, backup_id)
expect(output).to include('Removing all tables. Press `Ctrl-C` within 5 seconds to abort')
end
@@ -240,7 +239,7 @@ RSpec.describe Backup::Database, :reestablished_active_record_base, feature_cate
expect(Rake::Task['gitlab:db:drop_tables:main']).to receive(:invoke)
end
- subject.restore(backup_dir)
+ subject.restore(backup_dir, backup_id)
expect(output).to include("Restoring PostgreSQL database")
expect(output).to include("[DONE]")
@@ -260,7 +259,7 @@ RSpec.describe Backup::Database, :reestablished_active_record_base, feature_cate
expect(Rake::Task['gitlab:db:drop_tables:main']).to receive(:invoke)
end
- expect { subject.restore(backup_dir) }.to raise_error(Backup::Error)
+ expect { subject.restore(backup_dir, backup_id) }.to raise_error(Backup::Error)
end
end
@@ -276,7 +275,7 @@ RSpec.describe Backup::Database, :reestablished_active_record_base, feature_cate
expect(Rake::Task['gitlab:db:drop_tables:main']).to receive(:invoke)
end
- subject.restore(backup_dir)
+ subject.restore(backup_dir, backup_id)
expect(output).to include("ERRORS")
expect(output).not_to include(noise)
@@ -305,7 +304,7 @@ RSpec.describe Backup::Database, :reestablished_active_record_base, feature_cate
expect(ENV).to receive(:merge!).with(hash_including { 'PGHOST' => 'test.example.com' })
expect(ENV).not_to receive(:[]=).with('PGPASSWORD', anything)
- subject.restore(backup_dir)
+ subject.restore(backup_dir, backup_id)
expect(ENV['PGPORT']).to eq(config['port']) if config['port']
expect(ENV['PGUSER']).to eq(config['username']) if config['username']
@@ -328,14 +327,14 @@ RSpec.describe Backup::Database, :reestablished_active_record_base, feature_cate
end
expect do
- subject.restore('db')
+ subject.restore('db', backup_id)
end.to raise_error(Backup::Error, /Source database file does not exist/)
end
end
context 'for ci database' do
it 'ci database tolerates missing source file' do
- expect { subject.restore(backup_dir) }.not_to raise_error
+ expect { subject.restore(backup_dir, backup_id) }.not_to raise_error
end
end
end
diff --git a/spec/lib/backup/files_spec.rb b/spec/lib/backup/files_spec.rb
index f98b5e1414f..48c89e06dfa 100644
--- a/spec/lib/backup/files_spec.rb
+++ b/spec/lib/backup/files_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Backup::Files do
+RSpec.describe Backup::Files, feature_category: :backup_restore do
let(:progress) { StringIO.new }
let!(:project) { create(:project) }
@@ -58,25 +58,25 @@ RSpec.describe Backup::Files do
it 'moves all necessary files' do
allow(subject).to receive(:backup_existing_files).and_call_original
expect(FileUtils).to receive(:mv).with(["/var/gitlab-registry/sample1"], File.join(Gitlab.config.backup.path, "tmp", "registry.#{Time.now.to_i}"))
- subject.restore('registry.tar.gz')
+ subject.restore('registry.tar.gz', 'backup_id')
end
it 'raises no errors' do
- expect { subject.restore('registry.tar.gz') }.not_to raise_error
+ expect { subject.restore('registry.tar.gz', 'backup_id') }.not_to raise_error
end
it 'calls tar command with unlink' do
expect(subject).to receive(:tar).and_return('blabla-tar')
- expect(subject).to receive(:run_pipeline!).with([%w(gzip -cd), %w(blabla-tar --unlink-first --recursive-unlink -C /var/gitlab-registry -xf -)], any_args)
+ expect(subject).to receive(:run_pipeline!).with([%w[gzip -cd], %w[blabla-tar --unlink-first --recursive-unlink -C /var/gitlab-registry -xf -]], any_args)
expect(subject).to receive(:pipeline_succeeded?).and_return(true)
- subject.restore('registry.tar.gz')
+ subject.restore('registry.tar.gz', 'backup_id')
end
it 'raises an error on failure' do
expect(subject).to receive(:pipeline_succeeded?).and_return(false)
- expect { subject.restore('registry.tar.gz') }.to raise_error(/Restore operation failed:/)
+ expect { subject.restore('registry.tar.gz', 'backup_id') }.to raise_error(/Restore operation failed:/)
end
end
@@ -89,7 +89,7 @@ RSpec.describe Backup::Files do
it 'shows error message' do
expect(subject).to receive(:access_denied_error).with("/var/gitlab-registry")
- subject.restore('registry.tar.gz')
+ subject.restore('registry.tar.gz', 'backup_id')
end
end
@@ -104,7 +104,7 @@ RSpec.describe Backup::Files do
expect(subject).to receive(:resource_busy_error).with("/var/gitlab-registry")
.and_call_original
- expect { subject.restore('registry.tar.gz') }.to raise_error(/is a mountpoint/)
+ expect { subject.restore('registry.tar.gz', 'backup_id') }.to raise_error(/is a mountpoint/)
end
end
end
@@ -124,7 +124,7 @@ RSpec.describe Backup::Files do
it 'excludes tmp dirs from archive' do
expect(subject).to receive(:tar).and_return('blabla-tar')
- expect(subject).to receive(:run_pipeline!).with([%w(blabla-tar --exclude=lost+found --exclude=./@pages.tmp -C /var/gitlab-pages -cf - .), 'gzip -c -1'], any_args)
+ expect(subject).to receive(:run_pipeline!).with([%w[blabla-tar --exclude=lost+found --exclude=./@pages.tmp -C /var/gitlab-pages -cf - .], 'gzip -c -1'], any_args)
subject.dump('registry.tar.gz', 'backup_id')
end
@@ -146,7 +146,7 @@ RSpec.describe Backup::Files do
it 'excludes tmp dirs from rsync' do
expect(Gitlab::Popen).to receive(:popen)
- .with(%w(rsync -a --delete --exclude=lost+found --exclude=/gitlab-pages/@pages.tmp /var/gitlab-pages /var/gitlab-backup))
+ .with(%w[rsync -a --delete --exclude=lost+found --exclude=/gitlab-pages/@pages.tmp /var/gitlab-pages /var/gitlab-backup])
.and_return(['', 0])
subject.dump('registry.tar.gz', 'backup_id')
@@ -154,7 +154,7 @@ RSpec.describe Backup::Files do
it 'retries if rsync fails due to vanishing files' do
expect(Gitlab::Popen).to receive(:popen)
- .with(%w(rsync -a --delete --exclude=lost+found --exclude=/gitlab-pages/@pages.tmp /var/gitlab-pages /var/gitlab-backup))
+ .with(%w[rsync -a --delete --exclude=lost+found --exclude=/gitlab-pages/@pages.tmp /var/gitlab-pages /var/gitlab-backup])
.and_return(['rsync failed', 24], ['', 0])
expect do
@@ -164,7 +164,7 @@ RSpec.describe Backup::Files do
it 'raises an error and outputs an error message if rsync failed' do
allow(Gitlab::Popen).to receive(:popen)
- .with(%w(rsync -a --delete --exclude=lost+found --exclude=/gitlab-pages/@pages.tmp /var/gitlab-pages /var/gitlab-backup))
+ .with(%w[rsync -a --delete --exclude=lost+found --exclude=/gitlab-pages/@pages.tmp /var/gitlab-pages /var/gitlab-backup])
.and_return(['rsync failed', 1])
expect do
diff --git a/spec/lib/backup/manager_spec.rb b/spec/lib/backup/manager_spec.rb
index 1733d21c23f..8f85cd9d8b3 100644
--- a/spec/lib/backup/manager_spec.rb
+++ b/spec/lib/backup/manager_spec.rb
@@ -69,7 +69,7 @@ RSpec.describe Backup::Manager, feature_category: :backup_restore do
let(:pre_restore_warning) { nil }
let(:post_restore_warning) { nil }
let(:definitions) { { 'my_task' => Backup::Manager::TaskDefinition.new(task: task, enabled: enabled, human_name: 'my task', destination_path: 'my_task.tar.gz') } }
- let(:backup_information) { {} }
+ let(:backup_information) { { backup_created_at: Time.zone.parse('2019-01-01'), gitlab_version: '12.3' } }
let(:task) do
instance_double(Backup::Task,
pre_restore_warning: pre_restore_warning,
@@ -156,7 +156,7 @@ RSpec.describe Backup::Manager, feature_category: :backup_restore do
describe '#create' do
let(:incremental_env) { 'false' }
- let(:expected_backup_contents) { %w{backup_information.yml task1.tar.gz task2.tar.gz} }
+ let(:expected_backup_contents) { %w[backup_information.yml task1.tar.gz task2.tar.gz] }
let(:backup_time) { Time.zone.parse('2019-1-1') }
let(:backup_id) { "1546300800_2019_01_01_#{Gitlab::VERSION}" }
let(:full_backup_id) { backup_id }
@@ -179,8 +179,8 @@ RSpec.describe Backup::Manager, feature_category: :backup_restore do
allow(Gitlab::BackupLogger).to receive(:info)
allow(Kernel).to receive(:system).and_return(true)
- allow(task1).to receive(:dump).with(File.join(Gitlab.config.backup.path, 'task1.tar.gz'), full_backup_id)
- allow(task2).to receive(:dump).with(File.join(Gitlab.config.backup.path, 'task2.tar.gz'), full_backup_id)
+ allow(task1).to receive(:dump).with(File.join(Gitlab.config.backup.path, 'task1.tar.gz'), backup_id)
+ allow(task2).to receive(:dump).with(File.join(Gitlab.config.backup.path, 'task2.tar.gz'), backup_id)
end
it 'creates a backup tar' do
@@ -223,7 +223,7 @@ RSpec.describe Backup::Manager, feature_category: :backup_restore do
end
context 'when SKIP env is set' do
- let(:expected_backup_contents) { %w{backup_information.yml task1.tar.gz} }
+ let(:expected_backup_contents) { %w[backup_information.yml task1.tar.gz] }
before do
stub_env('SKIP', 'task2')
@@ -237,7 +237,7 @@ RSpec.describe Backup::Manager, feature_category: :backup_restore do
end
context 'when the destination is optional' do
- let(:expected_backup_contents) { %w{backup_information.yml task1.tar.gz} }
+ let(:expected_backup_contents) { %w[backup_information.yml task1.tar.gz] }
let(:definitions) do
{
'task1' => Backup::Manager::TaskDefinition.new(task: task1, destination_path: 'task1.tar.gz'),
@@ -936,6 +936,8 @@ RSpec.describe Backup::Manager, feature_category: :backup_restore do
end
let(:gitlab_version) { Gitlab::VERSION }
+ let(:backup_id) { "1546300800_2019_01_01_#{gitlab_version}" }
+
let(:backup_information) do
{
backup_created_at: Time.zone.parse('2019-01-01'),
@@ -948,8 +950,8 @@ RSpec.describe Backup::Manager, feature_category: :backup_restore do
Rake.application.rake_require 'tasks/cache'
allow(Gitlab::BackupLogger).to receive(:info)
- allow(task1).to receive(:restore).with(File.join(Gitlab.config.backup.path, 'task1.tar.gz'))
- allow(task2).to receive(:restore).with(File.join(Gitlab.config.backup.path, 'task2.tar.gz'))
+ allow(task1).to receive(:restore).with(File.join(Gitlab.config.backup.path, 'task1.tar.gz'), backup_id)
+ allow(task2).to receive(:restore).with(File.join(Gitlab.config.backup.path, 'task2.tar.gz'), backup_id)
allow(YAML).to receive(:safe_load_file).with(File.join(Gitlab.config.backup.path, 'backup_information.yml'),
permitted_classes: described_class::YAML_PERMITTED_CLASSES)
.and_return(backup_information)
@@ -1013,7 +1015,8 @@ RSpec.describe Backup::Manager, feature_category: :backup_restore do
end
context 'when BACKUP variable is set to a correct file' do
- let(:tar_cmdline) { %w{tar -xf 1451606400_2016_01_01_1.2.3_gitlab_backup.tar} }
+ let(:tar_cmdline) { %w[tar -xf 1451606400_2016_01_01_1.2.3_gitlab_backup.tar] }
+ let(:backup_id) { "1451606400_2016_01_01_1.2.3" }
before do
allow(Gitlab::BackupLogger).to receive(:info)
diff --git a/spec/lib/backup/repositories_spec.rb b/spec/lib/backup/repositories_spec.rb
index 1f3818de4a0..ad5fb8ea84e 100644
--- a/spec/lib/backup/repositories_spec.rb
+++ b/spec/lib/backup/repositories_spec.rb
@@ -85,7 +85,7 @@ RSpec.describe Backup::Repositories, feature_category: :backup_restore do
end
describe 'storages' do
- let(:storages) { %w{default} }
+ let(:storages) { %w[default] }
let_it_be(:project) { create(:project_with_design, :repository) }
@@ -215,9 +215,9 @@ RSpec.describe Backup::Repositories, feature_category: :backup_restore do
let_it_be(:project_snippet) { create(:project_snippet, :repository, project: project, author: project.first_owner) }
it 'calls enqueue for each repository type', :aggregate_failures do
- subject.restore(destination)
+ subject.restore(destination, backup_id)
- expect(strategy).to have_received(:start).with(:restore, destination, remove_all_repositories: %w[default])
+ expect(strategy).to have_received(:start).with(:restore, destination, remove_all_repositories: %w[default], backup_id: backup_id)
expect(strategy).to have_received(:enqueue).with(project, Gitlab::GlRepository::PROJECT)
expect(strategy).to have_received(:enqueue).with(project, Gitlab::GlRepository::WIKI)
expect(strategy).to have_received(:enqueue).with(project.design_management_repository, Gitlab::GlRepository::DESIGN)
@@ -231,7 +231,7 @@ RSpec.describe Backup::Repositories, feature_category: :backup_restore do
pool_repository = create(:pool_repository, :failed)
pool_repository.delete_object_pool
- subject.restore(destination)
+ subject.restore(destination, backup_id)
pool_repository.reload
expect(pool_repository).not_to be_failed
@@ -242,7 +242,7 @@ RSpec.describe Backup::Repositories, feature_category: :backup_restore do
pool_repository = create(:pool_repository, state: :obsolete)
pool_repository.update_column(:source_project_id, nil)
- subject.restore(destination)
+ subject.restore(destination, backup_id)
pool_repository.reload
expect(pool_repository).to be_obsolete
@@ -256,14 +256,14 @@ RSpec.describe Backup::Repositories, feature_category: :backup_restore do
end
it 'shows the appropriate error' do
- subject.restore(destination)
+ subject.restore(destination, backup_id)
expect(progress).to have_received(:puts).with("Snippet #{personal_snippet.full_path} can't be restored: Repository has more than one branch")
expect(progress).to have_received(:puts).with("Snippet #{project_snippet.full_path} can't be restored: Repository has more than one branch")
end
it 'removes the snippets from the DB' do
- expect { subject.restore(destination) }.to change(PersonalSnippet, :count).by(-1)
+ expect { subject.restore(destination, backup_id) }.to change(PersonalSnippet, :count).by(-1)
.and change(ProjectSnippet, :count).by(-1)
.and change(SnippetRepository, :count).by(-2)
end
@@ -273,14 +273,14 @@ RSpec.describe Backup::Repositories, feature_category: :backup_restore do
shard_name = personal_snippet.repository.shard
path = personal_snippet.disk_path + '.git'
- subject.restore(destination)
+ subject.restore(destination, backup_id)
expect(gitlab_shell.repository_exists?(shard_name, path)).to eq false
end
end
context 'storages' do
- let(:storages) { %w{default} }
+ let(:storages) { %w[default] }
before do
stub_storage_settings('test_second_storage' => {
@@ -296,9 +296,9 @@ RSpec.describe Backup::Repositories, feature_category: :backup_restore do
excluded_personal_snippet = create(:personal_snippet, :repository, author: excluded_project.first_owner)
excluded_personal_snippet.track_snippet_repository('test_second_storage')
- subject.restore(destination)
+ subject.restore(destination, backup_id)
- expect(strategy).to have_received(:start).with(:restore, destination, remove_all_repositories: %w[default])
+ expect(strategy).to have_received(:start).with(:restore, destination, remove_all_repositories: %w[default], backup_id: backup_id)
expect(strategy).not_to have_received(:enqueue).with(excluded_project, Gitlab::GlRepository::PROJECT)
expect(strategy).not_to have_received(:enqueue).with(excluded_project_snippet, Gitlab::GlRepository::SNIPPET)
expect(strategy).not_to have_received(:enqueue).with(excluded_personal_snippet, Gitlab::GlRepository::SNIPPET)
@@ -318,9 +318,9 @@ RSpec.describe Backup::Repositories, feature_category: :backup_restore do
excluded_project_snippet = create(:project_snippet, :repository, project: excluded_project)
excluded_personal_snippet = create(:personal_snippet, :repository, author: excluded_project.first_owner)
- subject.restore(destination)
+ subject.restore(destination, backup_id)
- expect(strategy).to have_received(:start).with(:restore, destination, remove_all_repositories: nil)
+ expect(strategy).to have_received(:start).with(:restore, destination, remove_all_repositories: nil, backup_id: backup_id)
expect(strategy).not_to have_received(:enqueue).with(excluded_project, Gitlab::GlRepository::PROJECT)
expect(strategy).not_to have_received(:enqueue).with(excluded_project_snippet, Gitlab::GlRepository::SNIPPET)
expect(strategy).not_to have_received(:enqueue).with(excluded_personal_snippet, Gitlab::GlRepository::SNIPPET)
@@ -339,9 +339,9 @@ RSpec.describe Backup::Repositories, feature_category: :backup_restore do
excluded_project_snippet = create(:project_snippet, :repository, project: excluded_project)
excluded_personal_snippet = create(:personal_snippet, :repository, author: excluded_project.first_owner)
- subject.restore(destination)
+ subject.restore(destination, backup_id)
- expect(strategy).to have_received(:start).with(:restore, destination, remove_all_repositories: nil)
+ expect(strategy).to have_received(:start).with(:restore, destination, remove_all_repositories: nil, backup_id: backup_id)
expect(strategy).not_to have_received(:enqueue).with(excluded_project, Gitlab::GlRepository::PROJECT)
expect(strategy).not_to have_received(:enqueue).with(excluded_project_snippet, Gitlab::GlRepository::SNIPPET)
expect(strategy).not_to have_received(:enqueue).with(excluded_personal_snippet, Gitlab::GlRepository::SNIPPET)
@@ -363,9 +363,9 @@ RSpec.describe Backup::Repositories, feature_category: :backup_restore do
excluded_project_snippet = create(:project_snippet, :repository, project: excluded_project)
included_personal_snippet = create(:personal_snippet, :repository, author: excluded_project.first_owner)
- subject.restore(destination)
+ subject.restore(destination, backup_id)
- expect(strategy).to have_received(:start).with(:restore, destination, remove_all_repositories: %w[default])
+ expect(strategy).to have_received(:start).with(:restore, destination, remove_all_repositories: %w[default], backup_id: backup_id)
expect(strategy).not_to have_received(:enqueue).with(excluded_project, Gitlab::GlRepository::PROJECT)
expect(strategy).not_to have_received(:enqueue).with(excluded_project_snippet, Gitlab::GlRepository::SNIPPET)
expect(strategy).to have_received(:enqueue).with(included_personal_snippet, Gitlab::GlRepository::SNIPPET)
@@ -383,9 +383,9 @@ RSpec.describe Backup::Repositories, feature_category: :backup_restore do
excluded_project_snippet = create(:project_snippet, :repository, project: excluded_project)
included_personal_snippet = create(:personal_snippet, :repository, author: excluded_project.first_owner)
- subject.restore(destination)
+ subject.restore(destination, backup_id)
- expect(strategy).to have_received(:start).with(:restore, destination, remove_all_repositories: %w[default])
+ expect(strategy).to have_received(:start).with(:restore, destination, remove_all_repositories: %w[default], backup_id: backup_id)
expect(strategy).not_to have_received(:enqueue).with(excluded_project, Gitlab::GlRepository::PROJECT)
expect(strategy).not_to have_received(:enqueue).with(excluded_project_snippet, Gitlab::GlRepository::SNIPPET)
expect(strategy).to have_received(:enqueue).with(included_personal_snippet, Gitlab::GlRepository::SNIPPET)
diff --git a/spec/lib/backup/task_spec.rb b/spec/lib/backup/task_spec.rb
index 1de99729512..370d9e4a64f 100644
--- a/spec/lib/backup/task_spec.rb
+++ b/spec/lib/backup/task_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe Backup::Task do
describe '#restore' do
it 'must be implemented by the subclass' do
- expect { subject.restore('some/path') }.to raise_error(NotImplementedError)
+ expect { subject.restore('some/path', 'backup_id') }.to raise_error(NotImplementedError)
end
end
end