(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:
Glenn Sarti 2017-02-17 11:17:17 -08:00
parent 47d597f68a
commit 4dd0c96a78
2 changed files with 74 additions and 3 deletions

View file

@ -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