mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
fix rubocop and spec issues
This commit is contained in:
parent
03ea03f90a
commit
3ac0a25557
2 changed files with 12 additions and 10 deletions
|
|
@ -162,8 +162,10 @@ module Vmpooler
|
||||||
def get_provisioning_trace(vm, pool, provider)
|
def get_provisioning_trace(vm, pool, provider)
|
||||||
# only call get_provisioning_trace if the provider supports it
|
# only call get_provisioning_trace if the provider supports it
|
||||||
return nil unless provider.respond_to?(:get_provisioning_trace)
|
return nil unless provider.respond_to?(:get_provisioning_trace)
|
||||||
|
|
||||||
trace = provider.get_provisioning_trace(vm, pool)
|
trace = provider.get_provisioning_trace(vm, pool)
|
||||||
return nil if trace.nil?
|
return nil if trace.nil?
|
||||||
|
|
||||||
trace
|
trace
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ EOT
|
||||||
it 'calls fail_pending_vm if host is not ready' do
|
it 'calls fail_pending_vm if host is not ready' do
|
||||||
redis_connection_pool.with do |redis|
|
redis_connection_pool.with do |redis|
|
||||||
expect(provider).to receive(:vm_ready?).with(pool, vm, redis).and_return(false)
|
expect(provider).to receive(:vm_ready?).with(pool, vm, redis).and_return(false)
|
||||||
expect(subject).to receive(:fail_pending_vm).with(vm, pool, timeout, timeout_notification, redis)
|
expect(subject).to receive(:fail_pending_vm).with(vm, pool, timeout, timeout_notification, redis, provider)
|
||||||
end
|
end
|
||||||
|
|
||||||
subject._check_pending_vm(vm, pool, timeout, timeout_notification, provider)
|
subject._check_pending_vm(vm, pool, timeout, timeout_notification, provider)
|
||||||
|
|
@ -276,7 +276,7 @@ EOT
|
||||||
it 'takes no action if VM is not cloning' do
|
it 'takes no action if VM is not cloning' do
|
||||||
redis_connection_pool.with do |redis|
|
redis_connection_pool.with do |redis|
|
||||||
expect(logger).to_not receive(:log)
|
expect(logger).to_not receive(:log)
|
||||||
expect(subject.fail_pending_vm(vm, pool, timeout, timeout_notification, redis)).to eq(true)
|
expect(subject.fail_pending_vm(vm, pool, timeout, timeout_notification, redis, provider)).to eq(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -284,7 +284,7 @@ EOT
|
||||||
redis_connection_pool.with do |redis|
|
redis_connection_pool.with do |redis|
|
||||||
redis.hset("vmpooler__vm__#{vm}", 'clone',Time.now.to_s)
|
redis.hset("vmpooler__vm__#{vm}", 'clone',Time.now.to_s)
|
||||||
expect(logger).to_not receive(:log)
|
expect(logger).to_not receive(:log)
|
||||||
expect(subject.fail_pending_vm(vm, pool, timeout, timeout_notification, redis)).to eq(true)
|
expect(subject.fail_pending_vm(vm, pool, timeout, timeout_notification, redis, provider)).to eq(true)
|
||||||
expect(redis.sismember("vmpooler__pending__#{pool}", vm)).to be(true)
|
expect(redis.sismember("vmpooler__pending__#{pool}", vm)).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -292,7 +292,7 @@ EOT
|
||||||
it 'moves VM to completed queue if VM has exceeded timeout and exists' do
|
it 'moves VM to completed queue if VM has exceeded timeout and exists' do
|
||||||
redis_connection_pool.with do |redis|
|
redis_connection_pool.with do |redis|
|
||||||
redis.hset("vmpooler__vm__#{vm}", 'clone',Date.new(2001,1,1).to_s)
|
redis.hset("vmpooler__vm__#{vm}", 'clone',Date.new(2001,1,1).to_s)
|
||||||
expect(subject.fail_pending_vm(vm, pool, timeout, timeout_notification, redis, exists: true)).to eq(true)
|
expect(subject.fail_pending_vm(vm, pool, timeout, timeout_notification, redis, provider, exists: true)).to eq(true)
|
||||||
expect(redis.sismember("vmpooler__pending__#{pool}", vm)).to be(false)
|
expect(redis.sismember("vmpooler__pending__#{pool}", vm)).to be(false)
|
||||||
expect(redis.sismember("vmpooler__completed__#{pool}", vm)).to be(true)
|
expect(redis.sismember("vmpooler__completed__#{pool}", vm)).to be(true)
|
||||||
end
|
end
|
||||||
|
|
@ -302,7 +302,7 @@ EOT
|
||||||
redis_connection_pool.with do |redis|
|
redis_connection_pool.with do |redis|
|
||||||
redis.hset("vmpooler__vm__#{vm}", 'clone',Date.new(2001,1,1).to_s)
|
redis.hset("vmpooler__vm__#{vm}", 'clone',Date.new(2001,1,1).to_s)
|
||||||
expect(logger).to receive(:log).with('d', "[!] [#{pool}] '#{vm}' marked as 'failed' after #{timeout} minutes with error: ")
|
expect(logger).to receive(:log).with('d', "[!] [#{pool}] '#{vm}' marked as 'failed' after #{timeout} minutes with error: ")
|
||||||
expect(subject.fail_pending_vm(vm, pool, timeout, timeout_notification, redis, exists: true)).to eq(true)
|
expect(subject.fail_pending_vm(vm, pool, timeout, timeout_notification, redis, provider, exists: true)).to eq(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -311,14 +311,14 @@ EOT
|
||||||
redis.hset("vmpooler__vm__#{vm}", 'clone',Date.new(2001,1,1).to_s)
|
redis.hset("vmpooler__vm__#{vm}", 'clone',Date.new(2001,1,1).to_s)
|
||||||
expect(logger).to_not receive(:log)
|
expect(logger).to_not receive(:log)
|
||||||
expect(subject).to receive(:remove_nonexistent_vm).with(vm, pool, redis)
|
expect(subject).to receive(:remove_nonexistent_vm).with(vm, pool, redis)
|
||||||
expect(subject.fail_pending_vm(vm, pool, timeout, timeout_notification, redis, exists: false)).to eq(true)
|
expect(subject.fail_pending_vm(vm, pool, timeout, timeout_notification, redis, provider, exists: false)).to eq(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'swallows error if an error is raised' do
|
it 'swallows error if an error is raised' do
|
||||||
redis_connection_pool.with do |redis|
|
redis_connection_pool.with do |redis|
|
||||||
redis.hset("vmpooler__vm__#{vm}", 'clone','iamnotparsable_asdate')
|
redis.hset("vmpooler__vm__#{vm}", 'clone','iamnotparsable_asdate')
|
||||||
expect(subject.fail_pending_vm(vm, pool, timeout, timeout_notification, redis, exists: true)).to eq(false)
|
expect(subject.fail_pending_vm(vm, pool, timeout, timeout_notification, redis, provider, exists: true)).to eq(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -327,7 +327,7 @@ EOT
|
||||||
redis.hset("vmpooler__vm__#{vm}", 'clone','iamnotparsable_asdate')
|
redis.hset("vmpooler__vm__#{vm}", 'clone','iamnotparsable_asdate')
|
||||||
expect(logger).to receive(:log).with('d', String)
|
expect(logger).to receive(:log).with('d', String)
|
||||||
|
|
||||||
subject.fail_pending_vm(vm, pool, timeout, timeout_notification, redis, exists: true)
|
subject.fail_pending_vm(vm, pool, timeout, timeout_notification, redis, provider, exists: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -338,7 +338,7 @@ EOT
|
||||||
redis.hset("vmpooler__vm__#{vm}", 'clone',(Time.now - 900).to_s)
|
redis.hset("vmpooler__vm__#{vm}", 'clone',(Time.now - 900).to_s)
|
||||||
redis.hset("vmpooler__vm__#{vm}", 'pool_alias', pool)
|
redis.hset("vmpooler__vm__#{vm}", 'pool_alias', pool)
|
||||||
redis.hset("vmpooler__vm__#{vm}", 'request_id', request_id)
|
redis.hset("vmpooler__vm__#{vm}", 'request_id', request_id)
|
||||||
subject.fail_pending_vm(vm, pool, timeout, timeout_notification, redis, exists: true)
|
subject.fail_pending_vm(vm, pool, timeout, timeout_notification, redis, provider, exists: true)
|
||||||
expect(redis.zrange('vmpooler__odcreate__task', 0, -1)).to eq(["#{pool}:#{pool}:1:#{request_id}"])
|
expect(redis.zrange('vmpooler__odcreate__task', 0, -1)).to eq(["#{pool}:#{pool}:1:#{request_id}"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -4140,7 +4140,7 @@ EOT
|
||||||
|
|
||||||
it 'should call fail_pending_vm' do
|
it 'should call fail_pending_vm' do
|
||||||
redis_connection_pool.with do |redis|
|
redis_connection_pool.with do |redis|
|
||||||
expect(subject).to receive(:fail_pending_vm).with(vm, pool, Integer, Integer, redis, exists: false)
|
expect(subject).to receive(:fail_pending_vm).with(vm, pool, Integer, Integer, redis, provider, exists: false)
|
||||||
end
|
end
|
||||||
|
|
||||||
subject.check_pending_pool_vms(pool, provider, pool_check_response, inventory, timeout, timeout_notification)
|
subject.check_pending_pool_vms(pool, provider, pool_check_response, inventory, timeout, timeout_notification)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue