diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-30 00:08:27 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-30 00:08:27 +0300 |
commit | 836ddfc35d1778675b3bd6d51f51972f36a96bbe (patch) | |
tree | bc1c0247c76a2cbdbab94b3884bc040b179f41fe /spec/support/database | |
parent | 488e1b59feb4314b034636990bcc4e220e61f0ce (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/database')
-rw-r--r-- | spec/support/database/multiple_databases.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/support/database/multiple_databases.rb b/spec/support/database/multiple_databases.rb index 05f26e57e9c..96bdab5171d 100644 --- a/spec/support/database/multiple_databases.rb +++ b/spec/support/database/multiple_databases.rb @@ -87,6 +87,16 @@ module Database end RSpec.configure do |config| + # Ensure database versions are memoized to prevent query counts from + # being affected by version checks. Note that + # Gitlab::Database.check_postgres_version_and_print_warning is called + # at startup, but that generates its own + # `Gitlab::Database::Reflection` so the result is not memoized by + # callers of `ApplicationRecord.database.version`, such as + # `Gitlab::Database::AsWithMaterialized.materialized_supported?`. + # TODO This can be removed once https://gitlab.com/gitlab-org/gitlab/-/issues/325639 is completed. + [ApplicationRecord, ::Ci::ApplicationRecord].each { |record| record.database.version } + config.around(:each, :reestablished_active_record_base) do |example| with_reestablished_active_record_base(reconnect: example.metadata.fetch(:reconnect, true)) do example.run |