From 836ddfc35d1778675b3bd6d51f51972f36a96bbe Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 29 Sep 2022 21:08:27 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/support/database/multiple_databases.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'spec/support/database') 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 -- cgit v1.2.3