mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Raise expected Timeout to ensure retryable retries (#1241)
With the refactor to where the domain addresses are looked up, a log message was added in case of timeout, however it was missed that when this occurs still need to raise the exception to ensure that checks for this timeout can occur within the original calling function. Update tests to ensure that the code will retry the expected number of times before triggering the expected failure message and aborting the machine bring up. Additionally to allow running the wait_till_up_spec.rb separately, needed to ensure the plugin.rb which is loaded by the code pulls in the action.rb to ensure `Action.remove_libvirt_image` can be correctly resolved when the rest of the test suite is not running. Fixes: #1239
This commit is contained in:
parent
db61946828
commit
1c82be1357
@ -97,11 +97,13 @@ module VagrantPlugins
|
||||
return get_ipaddress_from_system domain.mac
|
||||
end
|
||||
|
||||
# Get IP address from arp table
|
||||
# Get IP address from dhcp leases table
|
||||
begin
|
||||
ip_address = get_ipaddress_from_domain(domain)
|
||||
rescue Fog::Errors::TimeoutError
|
||||
@logger.info('Timeout at waiting for an ip address for machine %s' % machine.name)
|
||||
|
||||
raise
|
||||
end
|
||||
|
||||
unless ip_address
|
||||
|
@ -26,6 +26,7 @@ module VagrantPlugins
|
||||
end
|
||||
|
||||
action_hook(:remove_libvirt_image) do |hook|
|
||||
require_relative 'action'
|
||||
hook.after Vagrant::Action::Builtin::BoxRemove, Action.remove_libvirt_image
|
||||
end
|
||||
|
||||
|
@ -12,7 +12,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::WaitTillUp do
|
||||
include_context 'libvirt'
|
||||
include_context 'unit'
|
||||
|
||||
let (:driver) { double('driver') }
|
||||
let (:driver) { VagrantPlugins::ProviderLibvirt::Driver.new env[:machine] }
|
||||
|
||||
describe '#call' do
|
||||
before do
|
||||
@ -47,6 +47,24 @@ describe VagrantPlugins::ProviderLibvirt::Action::WaitTillUp do
|
||||
end
|
||||
end
|
||||
|
||||
context 'multiple timeouts waiting for IP' do
|
||||
before do
|
||||
allow(env).to receive(:[]).and_call_original
|
||||
allow(env).to receive(:[]).with(:interrupted).and_return(false)
|
||||
allow(logger).to receive(:debug)
|
||||
allow(logger).to receive(:info)
|
||||
end
|
||||
|
||||
it 'should abort after hitting limit' do
|
||||
expect(domain).to receive(:wait_for).at_least(300).times.and_raise(::Fog::Errors::TimeoutError)
|
||||
expect(app).to_not receive(:call)
|
||||
expect(ui).to receive(:info).with('Waiting for domain to get an IP address...')
|
||||
expect(ui).to_not receive(:info).with('Waiting for SSH to become available...')
|
||||
expect(env[:machine].communicate).to_not receive(:ready?)
|
||||
expect {subject.call(env) }.to raise_error(::Fog::Errors::TimeoutError)
|
||||
end
|
||||
end
|
||||
|
||||
context 'if interrupted waiting for SSH' do
|
||||
before do
|
||||
allow(domain).to receive(:wait_for).and_return(true)
|
||||
|
Loading…
Reference in New Issue
Block a user