mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
(maint) Raise error when ip address is not given to vm after clone.
This commit is contained in:
parent
8406247b4c
commit
eee7c4082a
2 changed files with 16 additions and 2 deletions
|
|
@ -470,6 +470,9 @@ module Vmpooler
|
||||||
ip_start = Time.now
|
ip_start = Time.now
|
||||||
ip = provider.get_vm_ip_address(new_vmname, pool_name)
|
ip = provider.get_vm_ip_address(new_vmname, pool_name)
|
||||||
ip_finish = format('%<time>.2f', time: Time.now - ip_start)
|
ip_finish = format('%<time>.2f', time: Time.now - ip_start)
|
||||||
|
|
||||||
|
raise StandardError, "failed to obtain IP after #{ip_finish} seconds" if ip.nil?
|
||||||
|
|
||||||
$logger.log('s', "[+] [#{pool_name}] Obtained IP for '#{new_vmname}' in #{ip_finish} seconds")
|
$logger.log('s', "[+] [#{pool_name}] Obtained IP for '#{new_vmname}' in #{ip_finish} seconds")
|
||||||
|
|
||||||
@redis.with_metrics do |redis|
|
@redis.with_metrics do |redis|
|
||||||
|
|
|
||||||
|
|
@ -989,7 +989,7 @@ EOT
|
||||||
allow(metrics).to receive(:timing)
|
allow(metrics).to receive(:timing)
|
||||||
expect(metrics).to receive(:timing).with(/clone\./,/0/)
|
expect(metrics).to receive(:timing).with(/clone\./,/0/)
|
||||||
expect(provider).to receive(:create_vm).with(pool, String)
|
expect(provider).to receive(:create_vm).with(pool, String)
|
||||||
allow(provider).to receive(:get_vm_ip_address)
|
allow(provider).to receive(:get_vm_ip_address).and_return(1)
|
||||||
allow(subject).to receive(:get_domain_for_pool).and_return('example.com')
|
allow(subject).to receive(:get_domain_for_pool).and_return('example.com')
|
||||||
allow(subject).to receive(:get_dns_plugin_class_name_for_pool).and_return(dns_plugin)
|
allow(subject).to receive(:get_dns_plugin_class_name_for_pool).and_return(dns_plugin)
|
||||||
allow(logger).to receive(:log)
|
allow(logger).to receive(:log)
|
||||||
|
|
@ -1035,6 +1035,17 @@ EOT
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with a failure to get ip address after cloning' do
|
||||||
|
it 'should log a message that it completed being cloned' do
|
||||||
|
allow(metrics).to receive(:timing)
|
||||||
|
expect(metrics).to receive(:timing).with(/clone\./,/0/)
|
||||||
|
expect(provider).to receive(:create_vm).with(pool, String)
|
||||||
|
allow(provider).to receive(:get_vm_ip_address).and_return(nil)
|
||||||
|
|
||||||
|
expect{subject._clone_vm(pool,provider,dns_plugin)}.to raise_error(StandardError)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'with an error during cloning' do
|
context 'with an error during cloning' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
expect(provider).to receive(:create_vm).with(pool, String).and_raise('MockError')
|
expect(provider).to receive(:create_vm).with(pool, String).and_raise('MockError')
|
||||||
|
|
@ -1088,7 +1099,7 @@ EOT
|
||||||
allow(metrics).to receive(:timing)
|
allow(metrics).to receive(:timing)
|
||||||
expect(metrics).to receive(:timing).with(/clone\./,/0/)
|
expect(metrics).to receive(:timing).with(/clone\./,/0/)
|
||||||
expect(provider).to receive(:create_vm).with(pool, String)
|
expect(provider).to receive(:create_vm).with(pool, String)
|
||||||
allow(provider).to receive(:get_vm_ip_address).with(vm,pool)
|
allow(provider).to receive(:get_vm_ip_address).with(vm,pool).and_return(1)
|
||||||
allow(subject).to receive(:get_dns_plugin_class_name_for_pool).and_return(dns_plugin)
|
allow(subject).to receive(:get_dns_plugin_class_name_for_pool).and_return(dns_plugin)
|
||||||
expect(dns_plugin).to receive(:create_or_replace_record)
|
expect(dns_plugin).to receive(:create_or_replace_record)
|
||||||
allow(logger).to receive(:log)
|
allow(logger).to receive(:log)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue