(POOLER-52) Add recovery to vSphere connections

The generic connection pooler is only responsible for managing the connection
objects, however the providers themselves are responsible for ensuring that the
connection is alive/healthy etc.  Previously, the older vSphere helper would
reconnect however this was lost when the connection pooler was introduced.  This
commit adds a method that checks the connection before use, and then reconnects
if the connection is in a bad state.
This commit is contained in:
Glenn Sarti 2017-05-12 14:54:30 -07:00
parent df783f0ed0
commit 85b0f035aa
3 changed files with 148 additions and 12 deletions

View file

@ -16,6 +16,47 @@ describe 'GenericConnectionPool' do
) { connection_object }
}
describe "When consuming a pool object" do
let(:pool_size) { 1 }
let(:pool_timeout) { 1 }
let(:connection_object) {{
connection: 'connection'
}}
it 'should return a connection object when grabbing one from the pool' do
subject.with_metrics do |conn_pool_object|
expect(conn_pool_object).to be(connection_object)
end
end
it 'should return the same connection object when calling the pool multiple times' do
subject.with_metrics do |conn_pool_object|
expect(conn_pool_object).to be(connection_object)
end
subject.with_metrics do |conn_pool_object|
expect(conn_pool_object).to be(connection_object)
end
subject.with_metrics do |conn_pool_object|
expect(conn_pool_object).to be(connection_object)
end
end
it 'should preserve connection state across mulitple pool calls' do
new_connection = 'new_connection'
# Ensure the connection is not modified
subject.with_metrics do |conn_pool_object|
expect(conn_pool_object).to be(connection_object)
expect(conn_pool_object[:connection]).to_not eq(new_connection)
# Change the connection
conn_pool_object[:connection] = new_connection
end
# Ensure the connection is modified
subject.with_metrics do |conn_pool_object|
expect(conn_pool_object).to be(connection_object)
expect(conn_pool_object[:connection]).to eq(new_connection)
end
end
end
describe "#with_metrics" do
before(:each) do