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
eab9b847
Commit
eab9b847
authored
Feb 10, 2022
by
Matt Kasa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix use of ActiveRecord::Base in DbCheck
Relates to
https://gitlab.com/gitlab-org/gitlab/-/issues/350651
parent
0cc6a229
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
3 deletions
+20
-3
lib/gitlab/health_checks/db_check.rb
lib/gitlab/health_checks/db_check.rb
+4
-2
spec/lib/gitlab/health_checks/db_check_spec.rb
spec/lib/gitlab/health_checks/db_check_spec.rb
+16
-1
No files found.
lib/gitlab/health_checks/db_check.rb
View file @
eab9b847
...
...
@@ -13,12 +13,14 @@ module Gitlab
end
def
successful?
(
result
)
result
==
'1'
result
==
Gitlab
::
Database
.
database_base_models
.
size
end
def
check
catch_timeout
10
.
seconds
do
ActiveRecord
::
Base
.
connection
.
execute
(
'SELECT 1 as ping'
)
&
.
first
&
.
[
](
'ping'
)
&
.
to_s
Gitlab
::
Database
.
database_base_models
.
sum
do
|
_
,
base
|
base
.
connection
.
select_value
(
'SELECT 1'
)
end
end
end
end
...
...
spec/lib/gitlab/health_checks/db_check_spec.rb
View file @
eab9b847
...
...
@@ -4,5 +4,20 @@ require 'spec_helper'
require_relative
'./simple_check_shared'
RSpec
.
describe
Gitlab
::
HealthChecks
::
DbCheck
do
include_examples
'simple_check'
,
'db_ping'
,
'Db'
,
'1'
include_examples
'simple_check'
,
'db_ping'
,
'Db'
,
Gitlab
::
Database
.
database_base_models
.
size
context
'with multiple databases'
do
subject
{
described_class
.
readiness
}
before
do
allow
(
Gitlab
::
Database
).
to
receive
(
:database_base_models
)
.
and_return
({
main:
ApplicationRecord
,
ci:
Ci
::
ApplicationRecord
}.
with_indifferent_access
)
end
it
'checks multiple databases'
do
expect
(
ApplicationRecord
.
connection
).
to
receive
(
:select_value
).
with
(
'SELECT 1'
).
and_call_original
expect
(
Ci
::
ApplicationRecord
.
connection
).
to
receive
(
:select_value
).
with
(
'SELECT 1'
).
and_call_original
expect
(
subject
).
to
have_attributes
(
success:
true
)
end
end
end
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