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:
parent
f8e3a4bcf1
commit
dfdfb5b8d7
@ -139,6 +139,9 @@ class TaskRunner(object):
|
|||||||
sleeping, pass `None` for `wait_time`.
|
sleeping, pass `None` for `wait_time`.
|
||||||
"""
|
"""
|
||||||
self.start(timeout=timeout)
|
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)
|
self.run_to_completion(wait_time=wait_time)
|
||||||
|
|
||||||
def start(self, timeout=None):
|
def start(self, timeout=None):
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
import contextlib
|
import contextlib
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
import mox
|
|
||||||
|
|
||||||
from heat.engine import dependencies
|
from heat.engine import dependencies
|
||||||
from heat.engine import scheduler
|
from heat.engine import scheduler
|
||||||
@ -46,13 +45,14 @@ class PollingTaskGroupTest(HeatTestCase):
|
|||||||
self.m.StubOutWithMock(t, 'do_step')
|
self.m.StubOutWithMock(t, 'do_step')
|
||||||
|
|
||||||
self.m.StubOutWithMock(scheduler.TaskRunner, '_sleep')
|
self.m.StubOutWithMock(scheduler.TaskRunner, '_sleep')
|
||||||
|
scheduler.TaskRunner._sleep(1).AndReturn(None)
|
||||||
|
|
||||||
for t in tasks:
|
for t in tasks:
|
||||||
t.do_step(1).AndReturn(None)
|
t.do_step(1).AndReturn(None)
|
||||||
for t in tasks:
|
for t in tasks:
|
||||||
scheduler.TaskRunner._sleep(mox.IsA(int)).AndReturn(None)
|
scheduler.TaskRunner._sleep(1).AndReturn(None)
|
||||||
t.do_step(2).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)
|
t.do_step(3).AndReturn(None)
|
||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
@ -219,6 +219,7 @@ class DependencyTaskGroupTest(HeatTestCase):
|
|||||||
self.m.StubOutWithMock(scheduler.TaskRunner, '_sleep')
|
self.m.StubOutWithMock(scheduler.TaskRunner, '_sleep')
|
||||||
with self._dep_test(('second', 'first')):
|
with self._dep_test(('second', 'first')):
|
||||||
scheduler.TaskRunner._sleep(None).AndReturn(None)
|
scheduler.TaskRunner._sleep(None).AndReturn(None)
|
||||||
|
scheduler.TaskRunner._sleep(None).AndReturn(None)
|
||||||
|
|
||||||
def test_single_node(self):
|
def test_single_node(self):
|
||||||
with self._dep_test(('only', None)) as dummy:
|
with self._dep_test(('only', None)) as dummy:
|
||||||
@ -416,6 +417,7 @@ class TaskTest(HeatTestCase):
|
|||||||
task.do_step(2).AndReturn(None)
|
task.do_step(2).AndReturn(None)
|
||||||
scheduler.TaskRunner._sleep(1).AndReturn(None)
|
scheduler.TaskRunner._sleep(1).AndReturn(None)
|
||||||
task.do_step(3).AndReturn(None)
|
task.do_step(3).AndReturn(None)
|
||||||
|
scheduler.TaskRunner._sleep(1).AndReturn(None)
|
||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
@ -431,6 +433,7 @@ class TaskTest(HeatTestCase):
|
|||||||
task.do_step(2).AndReturn(None)
|
task.do_step(2).AndReturn(None)
|
||||||
scheduler.TaskRunner._sleep(42).AndReturn(None)
|
scheduler.TaskRunner._sleep(42).AndReturn(None)
|
||||||
task.do_step(3).AndReturn(None)
|
task.do_step(3).AndReturn(None)
|
||||||
|
scheduler.TaskRunner._sleep(42).AndReturn(None)
|
||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
@ -732,13 +735,14 @@ class WrapperTaskTest(HeatTestCase):
|
|||||||
self.m.StubOutWithMock(child_task, 'do_step')
|
self.m.StubOutWithMock(child_task, 'do_step')
|
||||||
self.m.StubOutWithMock(scheduler.TaskRunner, '_sleep')
|
self.m.StubOutWithMock(scheduler.TaskRunner, '_sleep')
|
||||||
|
|
||||||
|
scheduler.TaskRunner._sleep(1).AndReturn(None)
|
||||||
for child_task in child_tasks:
|
for child_task in child_tasks:
|
||||||
child_task.do_step(1).AndReturn(None)
|
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)
|
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)
|
child_task.do_step(3).AndReturn(None)
|
||||||
scheduler.TaskRunner._sleep(mox.IsA(int)).AndReturn(None)
|
scheduler.TaskRunner._sleep(1).AndReturn(None)
|
||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user