mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
(POOLER-73) Add spec tests for execute!
Add spec tests for execute! Previously the execute! method would execute the loop indefinitely as it did not have a terminating condition. This made it impossible to test. This commit modifies the execute! method so that it can take a maxloop and delay parameter so that it can be tested.
This commit is contained in:
parent
e342cfe56a
commit
5e46ace584
2 changed files with 201 additions and 2 deletions
|
|
@ -714,7 +714,7 @@ module Vmpooler
|
|||
raise
|
||||
end
|
||||
|
||||
def execute!
|
||||
def execute!(maxloop = 0, loop_delay = 1)
|
||||
$logger.log('d', 'starting vmpooler')
|
||||
|
||||
# Clear out the tasks manager, as we don't know about any tasks at this point
|
||||
|
|
@ -722,6 +722,7 @@ module Vmpooler
|
|||
# Clear out vmpooler__migrations since stale entries may be left after a restart
|
||||
$redis.del('vmpooler__migration')
|
||||
|
||||
loop_count = 1
|
||||
loop do
|
||||
if ! $threads['disk_manager']
|
||||
check_disk_queue
|
||||
|
|
@ -746,7 +747,12 @@ module Vmpooler
|
|||
end
|
||||
end
|
||||
|
||||
sleep(1)
|
||||
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