Skip to content

Always set GITLAB_USE_MODEL_LOAD_BALANCING in test env

Thong Kuah requested to merge always_set_env_var_use_model_load_balancing into master

What does this MR do and why?

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

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports