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
f06e8de8
Commit
f06e8de8
authored
Sep 02, 2019
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enchance spec coverage
Impove DB load balancing spec coverage with regards to logger
parent
d8c8ee46
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
11 deletions
+30
-11
ee/spec/lib/gitlab/database/load_balancing/host_spec.rb
ee/spec/lib/gitlab/database/load_balancing/host_spec.rb
+30
-11
No files found.
ee/spec/lib/gitlab/database/load_balancing/host_spec.rb
View file @
f06e8de8
...
...
@@ -77,29 +77,50 @@ describe Gitlab::Database::LoadBalancing::Host do
it
'marks the host as offline'
do
expect
(
host
.
pool
).
to
receive
(
:disconnect!
)
expect
(
Gitlab
::
Database
::
LoadBalancing
::
Logger
).
to
receive
(
:warn
)
.
with
(
hash_including
(
event: :host_offline
))
.
and_call_original
host
.
offline!
end
end
describe
'#online?'
do
context
'when the replica status is recent enough'
do
before
do
expect
(
host
).
to
receive
(
:check_replica_status?
).
and_return
(
false
)
end
it
'returns the latest status'
do
Timecop
.
freeze
do
host
=
described_class
.
new
(
'localhost'
,
load_balancer
)
expect
(
host
).
not_to
receive
(
:refresh_status
)
expect
(
Gitlab
::
Database
::
LoadBalancing
::
Logger
).
not_to
receive
(
:info
)
expect
(
Gitlab
::
Database
::
LoadBalancing
::
Logger
).
not_to
receive
(
:warn
)
expect
(
host
).
not_to
receive
(
:refresh_status
)
expect
(
host
).
to
be_online
end
expect
(
host
).
to
be_online
end
end
context
'when the replica status is outdated'
do
it
'refreshes the status'
do
it
'returns an offline status'
do
host
.
offline!
expect
(
host
).
not_to
receive
(
:refresh_status
)
expect
(
Gitlab
::
Database
::
LoadBalancing
::
Logger
).
not_to
receive
(
:info
)
expect
(
Gitlab
::
Database
::
LoadBalancing
::
Logger
).
not_to
receive
(
:warn
)
expect
(
host
).
not_to
be_online
end
end
context
'when the replica status is outdated'
do
before
do
expect
(
host
)
.
to
receive
(
:check_replica_status?
)
.
and_return
(
true
)
end
it
'refreshes the status'
do
expect
(
Gitlab
::
Database
::
LoadBalancing
::
Logger
).
to
receive
(
:info
)
.
with
(
hash_including
(
event: :host_online
))
.
and_call_original
expect
(
host
).
to
be_online
end
...
...
@@ -270,9 +291,7 @@ describe Gitlab::Database::LoadBalancing::Host do
describe
'#replication_lag_size'
do
it
'returns the lag size as an Integer'
do
# On newer versions of Ruby the class is Integer, but on CI we run a
# version that still uses Fixnum.
expect
([
Fixnum
,
Integer
]).
to
include
(
host
.
replication_lag_size
.
class
)
# rubocop: disable Lint/UnifiedInteger
expect
(
host
.
replication_lag_size
).
to
be_an_instance_of
(
Integer
)
end
it
'returns nil when the database query returned no rows'
do
...
...
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