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
5c92e031
Commit
5c92e031
authored
Mar 13, 2018
by
Valery Sizov
Committed by
Nick Thomas
Mar 13, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "gitlab:geo:check should check connections to the Geo tracking DB"
parent
4cfe5293
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
111 additions
and
7 deletions
+111
-7
ee/changelogs/unreleased/4849-gitlab-geo-check-should-check-connections-to-the-geo-tracking-db.yml
...check-should-check-connections-to-the-geo-tracking-db.yml
+5
-0
ee/lib/system_check/geo/geo_database_configured_check.rb
ee/lib/system_check/geo/geo_database_configured_check.rb
+44
-7
ee/spec/lib/system_check/geo/geo_database_configured_check_spec.rb
...ib/system_check/geo/geo_database_configured_check_spec.rb
+62
-0
No files found.
ee/changelogs/unreleased/4849-gitlab-geo-check-should-check-connections-to-the-geo-tracking-db.yml
0 → 100644
View file @
5c92e031
---
title
:
gitlab:geo:check checks connection to the Geo tracking DB
merge_request
:
author
:
type
:
added
ee/lib/system_check/geo/geo_database_configured_check.rb
View file @
5c92e031
...
...
@@ -4,20 +4,57 @@ module SystemCheck
set_name
'GitLab Geo secondary database is correctly configured'
set_skip_reason
'not a secondary node'
WRONG_CONFIGURATION_MESSAGE
=
'Check if you enabled the `geo_secondary_role` or `geo_postgresql` in the gitlab.rb config file.'
.
freeze
UNHEALTHY_CONNECTION_MESSAGE
=
'Check the tracking database configuration as the connection could not be established'
.
freeze
NO_TABLES_MESSAGE
=
'Run the tracking database migrations: gitlab-rake geo:db:migrate'
.
freeze
def
skip?
!
Gitlab
::
Geo
.
secondary?
end
def
check?
Gitlab
::
Geo
.
geo_database_configured?
def
multi_check
unless
Gitlab
::
Geo
.
geo_database_configured?
$stdout
.
puts
'no'
.
color
(
:red
)
try_fixing_it
(
WRONG_CONFIGURATION_MESSAGE
)
for_more_information
(
'doc/gitlab-geo/database.md'
)
return
false
end
unless
connection_healthy?
$stdout
.
puts
'no'
.
color
(
:red
)
try_fixing_it
(
UNHEALTHY_CONNECTION_MESSAGE
)
for_more_information
(
'doc/gitlab-geo/database.md'
)
return
false
end
unless
tables_present?
$stdout
.
puts
'no'
.
color
(
:red
)
try_fixing_it
(
NO_TABLES_MESSAGE
)
for_more_information
(
'doc/gitlab-geo/database.md'
)
return
false
end
$stdout
.
puts
'yes'
.
color
(
:green
)
true
end
def
show_error
try_fixing_it
(
'Check if you enabled the `geo_secondary_role` or `geo_postgresql` in the gitlab.rb config file.'
)
private
def
connection_healthy?
::
Geo
::
TrackingBase
.
connection
.
active?
end
for_more_information
(
'doc/gitlab-geo/database.md'
)
def
tables_present?
Gitlab
::
Geo
::
DatabaseTasks
.
with_geo_db
{
!
ActiveRecord
::
Migrator
.
needs_migration?
}
end
end
end
...
...
ee/spec/lib/system_check/geo/geo_database_configured_check_spec.rb
0 → 100644
View file @
5c92e031
require
'spec_helper'
require
'rake_helper'
describe
SystemCheck
::
Geo
::
GeoDatabaseConfiguredCheck
do
before
do
silence_output
end
subject
{
described_class
.
new
}
describe
'#multi_check'
do
it
"checks database configuration"
do
stub_configuration_check
(
false
)
expect
(
subject
).
to
receive
(
:try_fixing_it
).
with
(
described_class
::
WRONG_CONFIGURATION_MESSAGE
)
expect
(
subject
.
multi_check
).
to
be_falsey
end
it
"checks database configuration"
do
stub_configuration_check
(
true
)
stub_connection_state
(
false
)
expect
(
subject
).
to
receive
(
:try_fixing_it
).
with
(
described_class
::
UNHEALTHY_CONNECTION_MESSAGE
)
expect
(
subject
.
multi_check
).
to
be_falsey
end
it
"checks table existence"
do
stub_configuration_check
(
true
)
stub_connection_state
(
true
)
stub_tables_existence
(
false
)
expect
(
subject
).
to
receive
(
:try_fixing_it
).
with
(
described_class
::
NO_TABLES_MESSAGE
)
expect
(
subject
.
multi_check
).
to
be_falsey
end
it
"returns true when all checks passed"
do
stub_configuration_check
(
true
)
stub_connection_state
(
true
)
stub_tables_existence
(
true
)
expect
(
subject
).
not_to
receive
(
:try_fixing_it
)
expect
(
subject
.
multi_check
).
to
be_truthy
end
end
def
stub_configuration_check
(
state
)
expect
(
Gitlab
::
Geo
).
to
receive
(
:geo_database_configured?
).
and_return
(
state
)
end
def
stub_connection_state
(
state
)
connection
=
double
expect
(
connection
).
to
receive
(
:active?
).
and_return
(
state
)
expect
(
::
Geo
::
TrackingBase
).
to
receive
(
:connection
).
and_return
(
connection
)
end
def
stub_tables_existence
(
state
)
expect
(
ActiveRecord
::
Migrator
).
to
receive
(
:needs_migration?
).
and_return
(
!
state
)
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