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
e725aab2
Commit
e725aab2
authored
Mar 17, 2021
by
Quang-Minh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more database load balancing testss
parent
bf2670a1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
ee/spec/lib/gitlab/database/load_balancing_spec.rb
ee/spec/lib/gitlab/database/load_balancing_spec.rb
+23
-0
spec/models/application_record_spec.rb
spec/models/application_record_spec.rb
+1
-1
No files found.
ee/spec/lib/gitlab/database/load_balancing_spec.rb
View file @
e725aab2
...
@@ -583,6 +583,29 @@ RSpec.describe Gitlab::Database::LoadBalancing do
...
@@ -583,6 +583,29 @@ RSpec.describe Gitlab::Database::LoadBalancing do
false
,
[
:replica
,
:replica
]
false
,
[
:replica
,
:replica
]
],
],
# A custom read query inside use_replica_if_possible
[
->
{
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
.
use_replica_if_possible
do
model
.
connection
.
exec_query
(
"SELECT 1"
)
end
},
false
,
[
:replica
]
],
# A custom read query inside a transaction use_replica_if_possible
[
->
{
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
.
use_replica_if_possible
do
model
.
transaction
do
model
.
connection
.
exec_query
(
"SET LOCAL statement_timeout = 5000"
)
model
.
count
end
end
},
true
,
[
:replica
,
:replica
,
:replica
,
:replica
]
],
# use_replica_if_possible after a write
# use_replica_if_possible after a write
[
[
->
{
->
{
...
...
spec/models/application_record_spec.rb
View file @
e725aab2
...
@@ -120,7 +120,7 @@ RSpec.describe ApplicationRecord do
...
@@ -120,7 +120,7 @@ RSpec.describe ApplicationRecord do
# other way to test the timeout for sure, 10ms of waiting seems to be
# other way to test the timeout for sure, 10ms of waiting seems to be
# reasonable!
# reasonable!
context
'when the query runs longer than configured timeout'
do
context
'when the query runs longer than configured timeout'
do
it
'cancels the query and raiss an exception'
do
it
'cancels the query and rais
e
s an exception'
do
expect
do
expect
do
described_class
.
with_fast_read_statement_timeout
(
10
)
do
described_class
.
with_fast_read_statement_timeout
(
10
)
do
described_class
.
connection
.
exec_query
(
'SELECT pg_sleep(0.1)'
)
described_class
.
connection
.
exec_query
(
'SELECT pg_sleep(0.1)'
)
...
...
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