Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
aa4fe6ab
Commit
aa4fe6ab
authored
Mar 11, 2022
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not set the env var globally, but use ENV.fetch
parent
1d5c9729
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
6 deletions
+4
-6
config/environments/test.rb
config/environments/test.rb
+0
-5
lib/gitlab/database/load_balancing/setup.rb
lib/gitlab/database/load_balancing/setup.rb
+2
-1
spec/lib/gitlab/database/load_balancing/setup_spec.rb
spec/lib/gitlab/database/load_balancing/setup_spec.rb
+2
-0
No files found.
config/environments/test.rb
View file @
aa4fe6ab
...
...
@@ -6,11 +6,6 @@ require 'gitlab/testing/request_inspector_middleware'
require
'gitlab/testing/clear_process_memory_cache_middleware'
require
'gitlab/utils'
# Set GITLAB_USE_MODEL_LOAD_BALANCING to a non-nil value
# CI tables consistently use the same connection
# See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/82562
ENV
[
'GITLAB_USE_MODEL_LOAD_BALANCING'
]
||=
'true'
Rails
.
application
.
configure
do
# Make sure the middleware is inserted first in middleware chain
config
.
middleware
.
insert_before
(
ActionDispatch
::
Static
,
Gitlab
::
Testing
::
RequestBlockerMiddleware
)
...
...
lib/gitlab/database/load_balancing/setup.rb
View file @
aa4fe6ab
...
...
@@ -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
...
...
spec/lib/gitlab/database/load_balancing/setup_spec.rb
View file @
aa4fe6ab
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment