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