Commit edaf7e98 authored by Stan Hu's avatar Stan Hu

Merge branch...

Merge branch '8583-rails5-gitlab-database-loadbalancing-caught_up-returns-state-incorrectly' into 'master'

Raisl 5: Fix Gitlab::Database::LoadBalancing#caught_up? check

Closes #8583

See merge request gitlab-org/gitlab-ee!8595
parents 0f1e54ad b54c4b81
---
title: 'Raisl 5: Fix Gitlab::Database::LoadBalancing#caught_up? check'
merge_request: 8595
author:
type: fixed
......@@ -159,7 +159,7 @@ module Gitlab
row = query_and_release(query)
row['result'] == 't'
::Gitlab::Utils.to_boolean(row['result'])
rescue *CONNECTION_ERRORS
false
end
......
......@@ -323,6 +323,14 @@ describe Gitlab::Database::LoadBalancing::Host, :postgresql do
expect(host.caught_up?('foo')).to eq(true)
end
# TODO: remove rails5-only tag after removing rails4 tests
it 'returns true when a host has caught up', :rails5 do
allow(host).to receive(:connection).and_return(connection)
expect(connection).to receive(:select_all).and_return([{ 'result' => true }])
expect(host.caught_up?('foo')).to eq(true)
end
it 'returns false when a host has not caught up' do
allow(host).to receive(:connection).and_return(connection)
expect(connection).to receive(:select_all).and_return([{ 'result' => 'f' }])
......@@ -330,6 +338,14 @@ describe Gitlab::Database::LoadBalancing::Host, :postgresql do
expect(host.caught_up?('foo')).to eq(false)
end
# TODO: remove rails5-only tag after removing rails4 tests
it 'returns false when a host has not caught up', :rails5 do
allow(host).to receive(:connection).and_return(connection)
expect(connection).to receive(:select_all).and_return([{ 'result' => false }])
expect(host.caught_up?('foo')).to eq(false)
end
it 'returns false when the connection fails' do
wrapped_error = wrapped_exception(ActionView::Template::Error, StandardError)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment