Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(POOLER-124) Fix evaluation of max_tries #273

Merged
merged 1 commit into from
Jul 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/vmpooler/providers/vsphere.rb
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,10 @@ def connect_to_vsphere
metrics.increment('connect.open')
return connection
rescue => err
try += 1
metrics.increment('connect.fail')
raise err if try == max_tries
raise err if try >= max_tries
sleep(try * retry_factor)
try += 1
retry
end
end
Expand Down
9 changes: 1 addition & 8 deletions spec/unit/providers/vsphere_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -897,13 +897,8 @@
allow(subject).to receive(:sleep)
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
pending('Resolution of issue https://github.com/puppetlabs/vmpooler/issues/199')
expect(RbVmomi::VIM).to receive(:connect).exactly(config[:config]['max_tries']).times.and_raise(RuntimeError,'MockError')
expect(RbVmomi::VIM).to receive(:connect).exactly(config[:config]['max_tries']).times

begin
# Swallow any errors
Expand All @@ -913,7 +908,6 @@
end

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

begin
Expand All @@ -928,7 +922,6 @@
].each do |testcase|
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
pending('Resolution of issue https://github.com/puppetlabs/vmpooler/issues/199')
config[:config]['max_tries'] = testcase[:max_tries]
config[:config]['retry_factor'] = testcase[:retry_factor]

Expand Down