diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-23 09:10:23 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-23 09:10:23 +0000 |
commit | 946a41d182e40dd37f73c44721edc9bc9c1a0f7c (patch) | |
tree | 28f1f399faebd1bd7084522919bd8b6354c3debd /spec/tasks | |
parent | 8b4276f873461953ee5a1fc46f084779f5847e3a (diff) | |
download | gitlab-ce-946a41d182e40dd37f73c44721edc9bc9c1a0f7c.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/tasks')
-rw-r--r-- | spec/tasks/gitlab/db_rake_spec.rb | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/spec/tasks/gitlab/db_rake_spec.rb b/spec/tasks/gitlab/db_rake_spec.rb index 933eba40719..a9977e07feb 100644 --- a/spec/tasks/gitlab/db_rake_spec.rb +++ b/spec/tasks/gitlab/db_rake_spec.rb @@ -805,6 +805,80 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout, feature_categor end end + describe 'execute_async_fk_validations' do + before do + skip_if_multiple_databases_not_setup + end + + it 'delegates ci task to Gitlab::Database::AsyncForeignKeys' do + expect(Gitlab::Database::AsyncForeignKeys).to receive(:validate_pending_entries!).with(how_many: 2) + + run_rake_task('gitlab:db:execute_async_fk_validations:ci') + end + + it 'delegates ci task to Gitlab::Database::AsyncForeignKeys with specified argument' do + expect(Gitlab::Database::AsyncForeignKeys).to receive(:validate_pending_entries!).with(how_many: 5) + + run_rake_task('gitlab:db:execute_async_fk_validations:ci', '[5]') + end + + it 'delegates main task to Gitlab::Database::AsyncForeignKeys' do + expect(Gitlab::Database::AsyncForeignKeys).to receive(:validate_pending_entries!).with(how_many: 2) + + run_rake_task('gitlab:db:execute_async_fk_validations:main') + end + + it 'delegates main task to Gitlab::Database::AsyncForeignKeys with specified argument' do + expect(Gitlab::Database::AsyncForeignKeys).to receive(:validate_pending_entries!).with(how_many: 7) + + run_rake_task('gitlab:db:execute_async_fk_validations:main', '[7]') + end + + it 'delegates all task to every database with higher default for dev' do + expect(Rake::Task['gitlab:db:execute_async_fk_validations:ci']).to receive(:invoke).with(1000) + expect(Rake::Task['gitlab:db:execute_async_fk_validations:main']).to receive(:invoke).with(1000) + + run_rake_task('gitlab:db:execute_async_fk_validations:all') + end + + it 'delegates all task to every database with lower default for prod' do + allow(Gitlab).to receive(:dev_or_test_env?).and_return(false) + + expect(Rake::Task['gitlab:db:execute_async_fk_validations:ci']).to receive(:invoke).with(2) + expect(Rake::Task['gitlab:db:execute_async_fk_validations:main']).to receive(:invoke).with(2) + + run_rake_task('gitlab:db:execute_async_fk_validations:all') + end + + it 'delegates all task to every database with specified argument' do + expect(Rake::Task['gitlab:db:execute_async_fk_validations:ci']).to receive(:invoke).with('50') + expect(Rake::Task['gitlab:db:execute_async_fk_validations:main']).to receive(:invoke).with('50') + + run_rake_task('gitlab:db:execute_async_fk_validations:all', '[50]') + end + + context 'when feature is not enabled' do + it 'is a no-op' do + stub_feature_flags(database_async_foreign_key_validation: false) + + expect(Gitlab::Database::AsyncForeignKeys).not_to receive(:validate_pending_entries!) + + expect { run_rake_task('gitlab:db:execute_async_fk_validations:main') }.to raise_error(SystemExit) + end + end + + context 'with geo configured' do + before do + skip_unless_geo_configured + end + + it 'does not create a task for the geo database' do + expect { run_rake_task('gitlab:db:execute_async_fk_validations:geo') } + .to raise_error(/Don't know how to build task 'gitlab:db:execute_async_fk_validations:geo'/) + end + end + end + describe 'active' do using RSpec::Parameterized::TableSyntax |