mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
(POOLER-73) Add spec tests for check_disk_queue
Add spec tests for check_disk_queue Previously the check_disk_queue 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_disk_queue method so that it can take a maxloop and delay parameter so that it can be tested.
This commit is contained in:
parent
47d597f68a
commit
4dd0c96a78
2 changed files with 74 additions and 3 deletions
|
|
@ -412,15 +412,20 @@ module Vmpooler
|
|||
end
|
||||
end
|
||||
|
||||
def check_disk_queue
|
||||
def check_disk_queue(maxloop = 0, loop_delay = 5)
|
||||
$logger.log('d', "[*] [disk_manager] starting worker thread")
|
||||
|
||||
$vsphere['disk_manager'] ||= Vmpooler::VsphereHelper.new $config, $metrics
|
||||
|
||||
$threads['disk_manager'] = Thread.new do
|
||||
loop_count = 1
|
||||
loop do
|
||||
_check_disk_queue $vsphere['disk_manager']
|
||||
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