mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
Merge pull request #273 from mattkirby/pooler_124
(POOLER-124) Fix evaluation of max_tries
This commit is contained in:
commit
6f4f3cc4e7
2 changed files with 3 additions and 10 deletions
|
|
@ -404,10 +404,10 @@ module Vmpooler
|
||||||
metrics.increment('connect.open')
|
metrics.increment('connect.open')
|
||||||
return connection
|
return connection
|
||||||
rescue => err
|
rescue => err
|
||||||
try += 1
|
|
||||||
metrics.increment('connect.fail')
|
metrics.increment('connect.fail')
|
||||||
raise err if try == max_tries
|
raise err if try >= max_tries
|
||||||
sleep(try * retry_factor)
|
sleep(try * retry_factor)
|
||||||
|
try += 1
|
||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -923,13 +923,8 @@ EOT
|
||||||
allow(subject).to receive(:sleep)
|
allow(subject).to receive(:sleep)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should raise an error' do
|
|
||||||
expect{subject.connect_to_vsphere}.to raise_error(RuntimeError,'MockError')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should retry the connection attempt config.max_tries times' do
|
it 'should retry the connection attempt config.max_tries times' do
|
||||||
pending('Resolution of issue https://github.com/puppetlabs/vmpooler/issues/199')
|
expect(RbVmomi::VIM).to receive(:connect).exactly(config[:config]['max_tries']).times
|
||||||
expect(RbVmomi::VIM).to receive(:connect).exactly(config[:config]['max_tries']).times.and_raise(RuntimeError,'MockError')
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
# Swallow any errors
|
# Swallow any errors
|
||||||
|
|
@ -939,7 +934,6 @@ EOT
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should increment the connect.fail counter config.max_tries times' do
|
it 'should increment the connect.fail counter config.max_tries times' do
|
||||||
pending('Resolution of issue https://github.com/puppetlabs/vmpooler/issues/199')
|
|
||||||
expect(metrics).to receive(:increment).with('connect.fail').exactly(config[:config]['max_tries']).times
|
expect(metrics).to receive(:increment).with('connect.fail').exactly(config[:config]['max_tries']).times
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|
@ -954,7 +948,6 @@ EOT
|
||||||
].each do |testcase|
|
].each do |testcase|
|
||||||
context "Configuration set for max_tries of #{testcase[:max_tries]} and retry_facter of #{testcase[:retry_factor]}" do
|
context "Configuration set for max_tries of #{testcase[:max_tries]} and retry_facter of #{testcase[:retry_factor]}" do
|
||||||
it "should sleep #{testcase[:max_tries] - 1} times between attempts with increasing timeout" do
|
it "should sleep #{testcase[:max_tries] - 1} times between attempts with increasing timeout" do
|
||||||
pending('Resolution of issue https://github.com/puppetlabs/vmpooler/issues/199')
|
|
||||||
config[:config]['max_tries'] = testcase[:max_tries]
|
config[:config]['max_tries'] = testcase[:max_tries]
|
||||||
config[:config]['retry_factor'] = testcase[:retry_factor]
|
config[:config]['retry_factor'] = testcase[:retry_factor]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue