Commit 106795c6 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'always_set_env_var_use_model_load_balancing' into 'master'

Always set GITLAB_USE_MODEL_LOAD_BALANCING in test env

See merge request gitlab-org/gitlab!82562
parents f9551502 71bd0575
......@@ -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:
......@@ -381,6 +377,8 @@ db:migrate:reset decomposed:
- db:migrate:reset
- .decomposed-database
- .rails:rules:decomposed-databases
variables:
GITLAB_USE_MODEL_LOAD_BALANCING: "false"
db:migrate-from-previous-major-version:
extends: .db-job-base
......@@ -389,6 +387,7 @@ db:migrate-from-previous-major-version:
SETUP_DB: "false"
PROJECT_TO_CHECKOUT: "gitlab-foss"
TAG_TO_CHECKOUT: "v13.12.9"
GITLAB_USE_MODEL_LOAD_BALANCING: "false"
before_script:
- !reference [.default-before_script, before_script]
- '[[ -d "ee/" ]] || export PROJECT_TO_CHECKOUT="gitlab"'
......
......@@ -90,7 +90,8 @@ module Gitlab
def use_model_load_balancing?
# Cache environment variable and return env variable first if defined
use_model_load_balancing_env = Gitlab::Utils.to_boolean(ENV["GITLAB_USE_MODEL_LOAD_BALANCING"])
default_use_model_load_balancing_env = Gitlab.dev_or_test_env? || nil
use_model_load_balancing_env = Gitlab::Utils.to_boolean(ENV.fetch('GITLAB_USE_MODEL_LOAD_BALANCING', default_use_model_load_balancing_env))
unless use_model_load_balancing_env.nil?
return use_model_load_balancing_env
......
......@@ -274,6 +274,8 @@ RSpec.describe Gitlab::Database::LoadBalancing::Setup do
end
before do
allow(Gitlab).to receive(:dev_or_test_env?).and_return(false)
# Rewrite `class_attribute` to use rspec mocking and prevent modifying the objects
allow_next_instance_of(described_class) do |setup|
allow(setup).to receive(:configure_connection)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment