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:
Diffstat (limited to 'spec/tasks/gitlab')
-rw-r--r--spec/tasks/gitlab/backup_rake_spec.rb23
-rw-r--r--spec/tasks/gitlab/db_rake_spec.rb55
-rw-r--r--spec/tasks/gitlab/packages/composer_rake_spec.rb1
-rw-r--r--spec/tasks/gitlab/snippets_rake_spec.rb1
4 files changed, 36 insertions, 44 deletions
diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb
index e5a210bb344..ebaaf179546 100644
--- a/spec/tasks/gitlab/backup_rake_spec.rb
+++ b/spec/tasks/gitlab/backup_rake_spec.rb
@@ -209,6 +209,23 @@ RSpec.describe 'gitlab:app namespace rake task', :delete do
expect { run_rake_task("gitlab:backup:#{task}:create") }.to output(/Dumping /).to_stdout_from_any_process
end
end
+
+ it 'logs the progress to log file' do
+ expect(Gitlab::BackupLogger).to receive(:info).with(message: "Dumping database ... ")
+ expect(Gitlab::BackupLogger).to receive(:info).with(message: "[SKIPPED]")
+ expect(Gitlab::BackupLogger).to receive(:info).with(message: "Dumping repositories ...")
+ expect(Gitlab::BackupLogger).to receive(:info).with(message: "Dumping uploads ... ")
+ expect(Gitlab::BackupLogger).to receive(:info).with(message: "Dumping builds ... ")
+ expect(Gitlab::BackupLogger).to receive(:info).with(message: "Dumping artifacts ... ")
+ expect(Gitlab::BackupLogger).to receive(:info).with(message: "Dumping pages ... ")
+ expect(Gitlab::BackupLogger).to receive(:info).with(message: "Dumping lfs objects ... ")
+ expect(Gitlab::BackupLogger).to receive(:info).with(message: "Dumping container registry images ... ")
+ expect(Gitlab::BackupLogger).to receive(:info).with(message: "done").exactly(7).times
+
+ task_list.each do |task|
+ run_rake_task("gitlab:backup:#{task}:create")
+ end
+ end
end
end
@@ -377,6 +394,11 @@ RSpec.describe 'gitlab:app namespace rake task', :delete do
end
it 'passes through concurrency environment variables' do
+ # The way concurrency is handled will change with the `gitaly_backup`
+ # feature flag. For now we need to check that both ways continue to
+ # work. This will be cleaned up in the rollout issue.
+ # See https://gitlab.com/gitlab-org/gitlab/-/issues/333034
+
stub_env('GITLAB_BACKUP_MAX_CONCURRENCY', 5)
stub_env('GITLAB_BACKUP_MAX_STORAGE_CONCURRENCY', 2)
@@ -385,6 +407,7 @@ RSpec.describe 'gitlab:app namespace rake task', :delete do
.with(max_concurrency: 5, max_storage_concurrency: 2)
.and_call_original
end
+ expect(::Backup::GitalyBackup).to receive(:new).with(anything, parallel: 5, parallel_storage: 2).and_call_original
expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout_from_any_process
end
diff --git a/spec/tasks/gitlab/db_rake_spec.rb b/spec/tasks/gitlab/db_rake_spec.rb
index 08ca6c32b49..03fbd238ee9 100644
--- a/spec/tasks/gitlab/db_rake_spec.rb
+++ b/spec/tasks/gitlab/db_rake_spec.rb
@@ -124,64 +124,31 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout do
describe 'clean_structure_sql' do
let_it_be(:clean_rake_task) { 'gitlab:db:clean_structure_sql' }
let_it_be(:test_task_name) { 'gitlab:db:_test_multiple_structure_cleans' }
- let_it_be(:structure_file) { 'db/structure.sql' }
let_it_be(:input) { 'this is structure data' }
+
let(:output) { StringIO.new }
before do
- stub_file_read(structure_file, content: input)
- allow(File).to receive(:open).with(structure_file, any_args).and_yield(output)
- end
+ structure_files = %w[db/structure.sql db/ci_structure.sql]
- after do
- Rake::Task[test_task_name].clear if Rake::Task.task_defined?(test_task_name)
- end
+ allow(File).to receive(:open).and_call_original
- it 'can be executed multiple times within another rake task' do
- expect_multiple_executions_of_task(test_task_name, clean_rake_task) do
- expect_next_instance_of(Gitlab::Database::SchemaCleaner) do |cleaner|
- expect(cleaner).to receive(:clean).with(output)
- end
+ structure_files.each do |structure_file|
+ stub_file_read(structure_file, content: input)
+ allow(File).to receive(:open).with(Rails.root.join(structure_file).to_s, any_args).and_yield(output)
end
end
- end
-
- describe 'load_custom_structure' do
- let_it_be(:db_config) { Rails.application.config_for(:database) }
- let_it_be(:custom_load_task) { 'gitlab:db:load_custom_structure' }
- let_it_be(:custom_filepath) { Pathname.new('db/directory') }
-
- it 'uses the psql command to load the custom structure file' do
- expect(Gitlab::Database::CustomStructure).to receive(:custom_dump_filepath).and_return(custom_filepath)
-
- expect(Kernel).to receive(:system)
- .with('psql', any_args, custom_filepath.to_path, db_config['database']).and_return(true)
-
- run_rake_task(custom_load_task)
- end
-
- it 'raises an error when the call to the psql command fails' do
- expect(Gitlab::Database::CustomStructure).to receive(:custom_dump_filepath).and_return(custom_filepath)
-
- expect(Kernel).to receive(:system)
- .with('psql', any_args, custom_filepath.to_path, db_config['database']).and_return(nil)
-
- expect { run_rake_task(custom_load_task) }.to raise_error(/failed to execute:\s*psql/)
- end
- end
-
- describe 'dump_custom_structure' do
- let_it_be(:test_task_name) { 'gitlab:db:_test_multiple_task_executions' }
- let_it_be(:custom_dump_task) { 'gitlab:db:dump_custom_structure' }
after do
Rake::Task[test_task_name].clear if Rake::Task.task_defined?(test_task_name)
end
it 'can be executed multiple times within another rake task' do
- expect_multiple_executions_of_task(test_task_name, custom_dump_task) do
- expect_next_instance_of(Gitlab::Database::CustomStructure) do |custom_structure|
- expect(custom_structure).to receive(:dump)
+ expect_multiple_executions_of_task(test_task_name, clean_rake_task, count: 2) do
+ database_count = ActiveRecord::Base.configurations.configs_for(env_name: Rails.env).size
+
+ expect_next_instances_of(Gitlab::Database::SchemaCleaner, database_count) do |cleaner|
+ expect(cleaner).to receive(:clean).with(output)
end
end
end
diff --git a/spec/tasks/gitlab/packages/composer_rake_spec.rb b/spec/tasks/gitlab/packages/composer_rake_spec.rb
index 78013714de5..f4f43bf77d8 100644
--- a/spec/tasks/gitlab/packages/composer_rake_spec.rb
+++ b/spec/tasks/gitlab/packages/composer_rake_spec.rb
@@ -10,6 +10,7 @@ RSpec.describe 'gitlab:packages:build_composer_cache namespace rake task', :sile
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, :custom_repo, files: { 'composer.json' => json.to_json }, group: group) }
let_it_be(:project2) { create(:project, :custom_repo, files: { 'composer.json' => json2.to_json }, group: group) }
+
let!(:package) { create(:composer_package, :with_metadatum, project: project, name: package_name, version: '1.0.0', json: json) }
let!(:package2) { create(:composer_package, :with_metadatum, project: project, name: package_name, version: '2.0.0', json: json) }
let!(:package3) { create(:composer_package, :with_metadatum, project: project2, name: package_name2, version: '3.0.0', json: json2) }
diff --git a/spec/tasks/gitlab/snippets_rake_spec.rb b/spec/tasks/gitlab/snippets_rake_spec.rb
index d40b784b3a0..c55bded1d5a 100644
--- a/spec/tasks/gitlab/snippets_rake_spec.rb
+++ b/spec/tasks/gitlab/snippets_rake_spec.rb
@@ -5,6 +5,7 @@ require 'rake_helper'
RSpec.describe 'gitlab:snippets namespace rake task', :silence_stdout do
let_it_be(:user) { create(:user)}
let_it_be(:migrated) { create(:personal_snippet, :repository, author: user) }
+
let(:non_migrated) { create_list(:personal_snippet, 3, author: user) }
let(:non_migrated_ids) { non_migrated.pluck(:id) }