Skip to content
Snippets Groups Projects
Commit 3d5df5b0 authored by Thong Kuah's avatar Thong Kuah
Browse files

Always set GITLAB_USE_MODEL_LOAD_BALANCING in test env

Otherwise in request specs, we will create factories in one connection
(main), while trying to access records in another connection (ci) while
running in a controller. This is because SafeRequestStore is not active
in the first situation but is active in the other.

This possibly is a problem with feature specs as well. This is only a
problem when ci database is configured,

To fix this, we always set GITLAB_USE_MODEL_LOAD_BALANCING to a non-nil
value so that we consistently use the same connection. We already set
GITLAB_USE_MODEL_LOAD_BALANCING to true anyway in CI, so let's set that
for all test environments.

This env var is not used in single database setups, so it shouldn't
affect single database setups
parent ed28668b
No related branches found
No related tags found
1 merge request!82562Always set GITLAB_USE_MODEL_LOAD_BALANCING in test env
......@@ -24,10 +24,6 @@
.decomposed-database-rspec:
extends: .decomposed-database
variables:
# For decomposition phase 3, uncomment line below:
# GITLAB_LOAD_BALANCING_REUSE_PRIMARY_ci: "main"
GITLAB_USE_MODEL_LOAD_BALANCING: "true"
.rspec-base:
extends:
......
......@@ -264,7 +264,14 @@
stub_feature_flags(force_no_sharing_primary_model: false)
end
# Set GITLAB_USE_MODEL_LOAD_BALANCING to a non-nil value
# so that feature, and request specs work with multiple databases
previous_value = ENV['GITLAB_USE_MODEL_LOAD_BALANCING']
ENV['GITLAB_USE_MODEL_LOAD_BALANCING'] ||= 'true'
example.run
ENV['GITLAB_USE_MODEL_LOAD_BALANCING'] = previous_value
end
config.append_after do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment