Skip to content

Commit

Permalink
Merge pull request #110 from BobbyRyterski/2.1.0_rescue_timeout
Browse files Browse the repository at this point in the history
Fail action when network info isn't available
  • Loading branch information
JJ Asghar committed Oct 7, 2015
2 parents 9870fb3 + 2287e5b commit 7f8e077
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/kitchen/driver/openstack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,12 @@ def get_ip(server)

# make sure we have the latest info
info 'Waiting for network information to be available...'
w = server.wait_for { reload && !addresses.empty? }
debug "Waited #{w[:duration]} seconds for network information."
begin
w = server.wait_for { !addresses.empty? }
debug "Waited #{w[:duration]} seconds for network information."
rescue Fog::Errors::TimeoutError
raise ActionFailed, 'Could not get network information (timed out)'
end

# should also work for private networks
if config[:openstack_network_name]
Expand Down
11 changes: 11 additions & 0 deletions spec/kitchen/driver/openstack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,17 @@
expect { driver.send(:get_ip, server) }.to raise_error(expected)
end
end

context 'when network information is not found' do
before do
allow(server).to receive(:wait_for).and_raise(Fog::Errors::TimeoutError)
end

it 'raises an exception' do
expected = Kitchen::ActionFailed
expect { driver.send(:get_ip, server) }.to raise_error(expected)
end
end
end

describe '#parse_ips' do
Expand Down

0 comments on commit 7f8e077

Please sign in to comment.