(POOLER-73) Add spec tests for check_pool

Add spec tests for check_pool

Previously the check_pool method would execute the loop indefinitely as it did not
have a terminating condition.  This made it impossible to test.  This commit
modifies the check_pool method so that it can take a maxloop and delay parameter
so that it can be tested.
This commit is contained in:
Glenn Sarti 2017-02-10 13:18:13 -08:00
parent 5e46ace584
commit daad5c7086
2 changed files with 116 additions and 2 deletions

View file

@ -546,15 +546,21 @@ module Vmpooler
finish
end
def check_pool(pool)
def check_pool(pool,maxloop = 0, loop_delay = 5)
$logger.log('d', "[*] [#{pool['name']}] starting worker thread")
$vsphere[pool['name']] ||= Vmpooler::VsphereHelper.new $config, $metrics
$threads[pool['name']] = Thread.new do
loop_count = 1
loop do
_check_pool(pool, $vsphere[pool['name']])
sleep(5)
sleep(loop_delay)
unless maxloop.zero?
break if loop_count >= maxloop
loop_count = loop_count + 1
end
end
end
end