mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
(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:
parent
5e46ace584
commit
daad5c7086
2 changed files with 116 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue