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
1ea4b4d0
Commit
1ea4b4d0
authored
Jul 06, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove `secondary_role_enabled?` from the health_check and improve specs
parent
c808f8c5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
13 deletions
+6
-13
lib/gitlab/geo/health_check.rb
lib/gitlab/geo/health_check.rb
+0
-1
spec/lib/gitlab/geo/health_check_spec.rb
spec/lib/gitlab/geo/health_check_spec.rb
+6
-12
No files found.
lib/gitlab/geo/health_check.rb
View file @
1ea4b4d0
...
@@ -5,7 +5,6 @@ module Gitlab
...
@@ -5,7 +5,6 @@ module Gitlab
raise
NotImplementedError
.
new
(
'Geo is only compatible with PostgreSQL'
)
unless
Gitlab
::
Database
.
postgresql?
raise
NotImplementedError
.
new
(
'Geo is only compatible with PostgreSQL'
)
unless
Gitlab
::
Database
.
postgresql?
return
''
unless
Gitlab
::
Geo
.
secondary?
return
''
unless
Gitlab
::
Geo
.
secondary?
return
'The Geo secondary role is disabled.'
unless
Gitlab
::
Geo
.
secondary_role_enabled?
return
'The Geo database configuration file is missing.'
unless
Gitlab
::
Geo
.
geo_database_configured?
return
'The Geo database configuration file is missing.'
unless
Gitlab
::
Geo
.
geo_database_configured?
return
'The Geo node has a database that is not configured for streaming replication with the primary node.'
unless
self
.
database_secondary?
return
'The Geo node has a database that is not configured for streaming replication with the primary node.'
unless
self
.
database_secondary?
...
...
spec/lib/gitlab/geo/health_check_spec.rb
View file @
1ea4b4d0
...
@@ -8,7 +8,6 @@ describe Gitlab::Geo::HealthCheck, :postgresql do
...
@@ -8,7 +8,6 @@ describe Gitlab::Geo::HealthCheck, :postgresql do
describe
'.perform_checks'
do
describe
'.perform_checks'
do
it
'returns a string if database is not fully migrated'
do
it
'returns a string if database is not fully migrated'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:secondary?
)
{
true
}
allow
(
Gitlab
::
Geo
).
to
receive
(
:secondary?
)
{
true
}
allow
(
Gitlab
::
Geo
).
to
receive
(
:secondary_role_enabled?
).
and_return
(
true
)
allow
(
described_class
).
to
receive
(
:geo_database_configured?
).
and_return
(
true
)
allow
(
described_class
).
to
receive
(
:geo_database_configured?
).
and_return
(
true
)
allow
(
described_class
).
to
receive
(
:database_secondary?
).
and_return
(
true
)
allow
(
described_class
).
to
receive
(
:database_secondary?
).
and_return
(
true
)
allow
(
described_class
).
to
receive
(
:get_database_version
).
and_return
(
'20170101'
)
allow
(
described_class
).
to
receive
(
:get_database_version
).
and_return
(
'20170101'
)
...
@@ -26,37 +25,32 @@ describe Gitlab::Geo::HealthCheck, :postgresql do
...
@@ -26,37 +25,32 @@ describe Gitlab::Geo::HealthCheck, :postgresql do
expect
(
subject
.
perform_checks
).
to
be_blank
expect
(
subject
.
perform_checks
).
to
be_blank
end
end
it
'returns an error when secondary role is disabled'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:secondary?
)
{
true
}
allow
(
Gitlab
::
Geo
).
to
receive
(
:secondary_role_enabled?
).
and_return
(
false
)
expect
(
subject
.
perform_checks
).
not_to
be_blank
end
it
'returns an error when database is not configured for streaming replication'
do
it
'returns an error when database is not configured for streaming replication'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:secondary?
)
{
true
}
allow
(
Gitlab
::
Geo
).
to
receive
(
:secondary?
)
{
true
}
allow
(
Gitlab
::
Database
).
to
receive
(
:postgresql?
)
{
true
}
allow
(
Gitlab
::
Database
).
to
receive
(
:postgresql?
)
{
true
}
allow
(
ActiveRecord
::
Base
).
to
receive_message_chain
(
:connection
,
:execute
,
:first
,
:fetch
)
{
'f'
}
allow
(
ActiveRecord
::
Base
).
to
receive_message_chain
(
:connection
,
:execute
,
:first
,
:fetch
)
{
'f'
}
expect
(
subject
.
perform_checks
).
not_to
be_blank
expect
(
subject
.
perform_checks
).
to
include
(
'not configured for streaming replication'
)
end
end
it
'returns an error when configuration file is missing for tracking DB'
do
it
'returns an error when configuration file is missing for tracking DB'
do
allow
(
Rails
.
configuration
).
to
receive
(
:respond_to?
).
with
(
:geo_database
)
{
false
}
allow
(
Rails
.
configuration
).
to
receive
(
:respond_to?
).
with
(
:geo_database
)
{
false
}
expect
(
subject
.
perform_checks
).
not_to
be_blank
expect
(
subject
.
perform_checks
).
to
include
(
'database configuration file is missing'
)
end
end
it
'returns an error when Geo database version does not match the latest migration version'
do
it
'returns an error when Geo database version does not match the latest migration version'
do
allow
(
described_class
).
to
receive
(
:database_secondary?
).
and_return
(
true
)
allow
(
subject
).
to
receive
(
:get_database_version
)
{
1
}
allow
(
subject
).
to
receive
(
:get_database_version
)
{
1
}
expect
(
subject
.
perform_checks
).
not_to
be_blank
expect
(
subject
.
perform_checks
).
to
match
(
/Current Geo database version \([0-9]+\) does not match latest migration \([0-9]+\)/
)
end
end
it
'returns an error when latest migration version does not match the Geo database version'
do
it
'returns an error when latest migration version does not match the Geo database version'
do
allow
(
described_class
).
to
receive
(
:database_secondary?
).
and_return
(
true
)
allow
(
subject
).
to
receive
(
:get_migration_version
)
{
1
}
allow
(
subject
).
to
receive
(
:get_migration_version
)
{
1
}
expect
(
subject
.
perform_checks
).
not_to
be_blank
expect
(
subject
.
perform_checks
).
to
match
(
/Current Geo database version \([0-9]+\) does not match latest migration \([0-9]+\)/
)
end
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