mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-27 02:18:41 -05:00
Fixed spec testing for check_running_pool_vm
This commit is contained in:
parent
cd8a87560f
commit
b9d86c85ec
1 changed files with 11 additions and 14 deletions
|
|
@ -2665,22 +2665,15 @@ EOT
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#check_running_pool_vms' do
|
describe '#check_running_pool_vms' do
|
||||||
let(:new_vm_response) {
|
|
||||||
# Mock response from Base Provider for vms_in_pool
|
|
||||||
[{ 'name' => vm}]
|
|
||||||
}
|
|
||||||
let(:inventory) {
|
|
||||||
# mock response from create_inventory
|
|
||||||
{vm => 1}
|
|
||||||
}
|
|
||||||
let(:pool_check_response) {
|
let(:pool_check_response) {
|
||||||
{:checked_running_vms => 0}
|
{:checked_running_vms => 0}
|
||||||
}
|
}
|
||||||
|
|
||||||
context 'Running VM not in the inventory' do
|
context 'Running VM not in the inventory' do
|
||||||
|
let(:inventory) {
|
||||||
|
# mock response from create_inventory
|
||||||
|
{}
|
||||||
|
}
|
||||||
before(:each) do
|
before(:each) do
|
||||||
expect(provider).to receive(:vms_in_pool).with(pool).and_return(new_vm_response)
|
|
||||||
expect(logger).to receive(:log).with('s', "[?] [#{pool}] '#{vm}' added to 'discovered' queue")
|
|
||||||
create_running_vm(pool,vm,token)
|
create_running_vm(pool,vm,token)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -2693,13 +2686,17 @@ EOT
|
||||||
it 'should move the VM to completed queue' do
|
it 'should move the VM to completed queue' do
|
||||||
expect(subject).to receive(:move_vm_queue).with(pool,vm,'running','completed',String).and_call_original
|
expect(subject).to receive(:move_vm_queue).with(pool,vm,'running','completed',String).and_call_original
|
||||||
|
|
||||||
subject._check_pool(pool_object,provider)
|
subject.check_running_pool_vms(pool,provider, pool_check_response, inventory)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'Running VM in the inventory' do
|
context 'Running VM in the inventory' do
|
||||||
|
let(:provider) { double('provider') }
|
||||||
|
let(:inventory) {
|
||||||
|
# mock response from create_inventory
|
||||||
|
{ vm => 1 }
|
||||||
|
}
|
||||||
before(:each) do
|
before(:each) do
|
||||||
expect(provider).to receive(:vms_in_pool).with(pool).and_return(vm_response)
|
|
||||||
allow(subject).to receive(:check_running_vm)
|
allow(subject).to receive(:check_running_vm)
|
||||||
create_running_vm(pool,vm,token)
|
create_running_vm(pool,vm,token)
|
||||||
end
|
end
|
||||||
|
|
@ -2708,7 +2705,7 @@ EOT
|
||||||
expect(subject).to receive(:check_running_vm).and_raise(RuntimeError,'MockError')
|
expect(subject).to receive(:check_running_vm).and_raise(RuntimeError,'MockError')
|
||||||
expect(logger).to receive(:log).with('d', "[!] [#{pool}] _check_pool with an error while evaluating running VMs: MockError")
|
expect(logger).to receive(:log).with('d', "[!] [#{pool}] _check_pool with an error while evaluating running VMs: MockError")
|
||||||
|
|
||||||
subject._check_pool(pool_object,provider)
|
subject.check_running_pool_vms(pool, provider, pool_check_response, inventory)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return the number of checked running VMs' do
|
it 'should return the number of checked running VMs' do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue