Fixed wait skipped after 1st step of task

The first step of a generator type task is executed by the start
method and subsequent steps are executed by run_to_completion.
The TaskRunner skips the wait between the first step and second
step.
Added the sleep between transition from first step to second step.
Updated corresponding unit tests.

Change-Id: Iff30073ea0c060c6e2c89d7d9df8d0d03e816455
Closes-Bug: #1218187
This commit is contained in:
Unmesh Gurjar 2014-07-02 08:21:29 -07:00 committed by unmesh-gurjar
parent f8e3a4bcf1
commit dfdfb5b8d7
2 changed files with 13 additions and 6 deletions

View File

@ -139,6 +139,9 @@ class TaskRunner(object):
sleeping, pass `None` for `wait_time`.
"""
self.start(timeout=timeout)
# ensure that wait is applied only if task has not completed.
if not self.done():
self._sleep(wait_time)
self.run_to_completion(wait_time=wait_time)
def start(self, timeout=None):

View File

@ -14,7 +14,6 @@
import contextlib
import eventlet
import mox
from heat.engine import dependencies
from heat.engine import scheduler
@ -46,13 +45,14 @@ class PollingTaskGroupTest(HeatTestCase):
self.m.StubOutWithMock(t, 'do_step')
self.m.StubOutWithMock(scheduler.TaskRunner, '_sleep')
scheduler.TaskRunner._sleep(1).AndReturn(None)
for t in tasks:
t.do_step(1).AndReturn(None)
for t in tasks:
scheduler.TaskRunner._sleep(mox.IsA(int)).AndReturn(None)
scheduler.TaskRunner._sleep(1).AndReturn(None)
t.do_step(2).AndReturn(None)
scheduler.TaskRunner._sleep(mox.IsA(int)).AndReturn(None)
scheduler.TaskRunner._sleep(1).AndReturn(None)
t.do_step(3).AndReturn(None)
self.m.ReplayAll()
@ -219,6 +219,7 @@ class DependencyTaskGroupTest(HeatTestCase):
self.m.StubOutWithMock(scheduler.TaskRunner, '_sleep')
with self._dep_test(('second', 'first')):
scheduler.TaskRunner._sleep(None).AndReturn(None)
scheduler.TaskRunner._sleep(None).AndReturn(None)
def test_single_node(self):
with self._dep_test(('only', None)) as dummy:
@ -416,6 +417,7 @@ class TaskTest(HeatTestCase):
task.do_step(2).AndReturn(None)
scheduler.TaskRunner._sleep(1).AndReturn(None)
task.do_step(3).AndReturn(None)
scheduler.TaskRunner._sleep(1).AndReturn(None)
self.m.ReplayAll()
@ -431,6 +433,7 @@ class TaskTest(HeatTestCase):
task.do_step(2).AndReturn(None)
scheduler.TaskRunner._sleep(42).AndReturn(None)
task.do_step(3).AndReturn(None)
scheduler.TaskRunner._sleep(42).AndReturn(None)
self.m.ReplayAll()
@ -732,13 +735,14 @@ class WrapperTaskTest(HeatTestCase):
self.m.StubOutWithMock(child_task, 'do_step')
self.m.StubOutWithMock(scheduler.TaskRunner, '_sleep')
scheduler.TaskRunner._sleep(1).AndReturn(None)
for child_task in child_tasks:
child_task.do_step(1).AndReturn(None)
scheduler.TaskRunner._sleep(mox.IsA(int)).AndReturn(None)
scheduler.TaskRunner._sleep(1).AndReturn(None)
child_task.do_step(2).AndReturn(None)
scheduler.TaskRunner._sleep(mox.IsA(int)).AndReturn(None)
scheduler.TaskRunner._sleep(1).AndReturn(None)
child_task.do_step(3).AndReturn(None)
scheduler.TaskRunner._sleep(mox.IsA(int)).AndReturn(None)
scheduler.TaskRunner._sleep(1).AndReturn(None)
self.m.ReplayAll()