Fixing method remove_excess_vms

Before this fix, if the pool had an excessive number of 'pending' vms,
but was not full of 'ready' vms, we would end up clearing all the
'pending' vms regardless, which could bring us back under the max
pool size. This fix makes sure we only remove the excess, see
unit test for an example
This commit is contained in:
Samuel Beaulieu 2018-05-30 16:54:43 -05:00
parent 045a85183f
commit d95e486c8c
2 changed files with 14 additions and 1 deletions

View file

@ -1669,7 +1669,18 @@ EOT
subject.remove_excess_vms(config[:pools][0], provider, 2, 5)
end
it 'should remove excess pending vms, but only the excess' do
create_pending_vm(pool,'vm1')
create_pending_vm(pool,'vm2')
create_pending_vm(pool,'vm3')
create_pending_vm(pool,'vm4')
expect(subject).to receive(:move_vm_queue).exactly(3).times
subject.remove_excess_vms(config[:pools][0], provider, 1, 5)
end
end
end
describe 'prepare_template' do