diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-23 12:10:23 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-23 12:10:23 +0300 |
commit | 946a41d182e40dd37f73c44721edc9bc9c1a0f7c (patch) | |
tree | 28f1f399faebd1bd7084522919bd8b6354c3debd /spec | |
parent | 8b4276f873461953ee5a1fc46f084779f5847e3a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/requests/api/graphql/project/merge_requests_spec.rb | 3 | ||||
-rw-r--r-- | spec/tasks/gitlab/db_rake_spec.rb | 74 |
2 files changed, 76 insertions, 1 deletions
diff --git a/spec/requests/api/graphql/project/merge_requests_spec.rb b/spec/requests/api/graphql/project/merge_requests_spec.rb index 8407faa967e..156886ca211 100644 --- a/spec/requests/api/graphql/project/merge_requests_spec.rb +++ b/spec/requests/api/graphql/project/merge_requests_spec.rb @@ -588,8 +588,9 @@ RSpec.describe 'getting merge request listings nested in a project', feature_cat end let(:query) do + # Adding a no-op `not` filter to mimic the same query as the frontend does graphql_query_for(:project, { full_path: project.full_path }, <<~QUERY) - mergeRequests(mergedAfter: "2020-01-01", mergedBefore: "2020-01-05", first: 0) { + mergeRequests(mergedAfter: "2020-01-01", mergedBefore: "2020-01-05", first: 0, not: { labels: null }) { totalTimeToMerge count } 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 |