예제 #1
0
 def test_when_subflow_fails_revert_running_tasks(self):
     waiting_task = utils.WaitForOneFromTask('task1', 'task2',
                                             [st.SUCCESS, st.FAILURE])
     flow = uf.Flow('flow-1', retry.Times(3, 'r', provides='x')).add(
         waiting_task,
         utils.ConditionalTask('task2')
     )
     engine = self._make_engine(flow)
     engine.task_notifier.register('*', waiting_task.callback)
     engine.storage.inject({'y': 2})
     with utils.CaptureListener(engine, capture_flow=False) as capturer:
         engine.run()
     self.assertEqual(engine.storage.fetch_all(), {'y': 2, 'x': 2})
     expected = ['r.r RUNNING',
                 'r.r SUCCESS(1)',
                 'task1.t RUNNING',
                 'task2.t RUNNING',
                 'task2.t FAILURE(Failure: RuntimeError: Woot!)',
                 'task2.t REVERTING',
                 'task2.t REVERTED',
                 'task1.t SUCCESS(5)',
                 'task1.t REVERTING',
                 'task1.t REVERTED',
                 'r.r RETRYING',
                 'task1.t PENDING',
                 'task2.t PENDING',
                 'r.r RUNNING',
                 'r.r SUCCESS(2)',
                 'task1.t RUNNING',
                 'task2.t RUNNING',
                 'task2.t SUCCESS(None)',
                 'task1.t SUCCESS(5)']
     self.assertItemsEqual(capturer.values, expected)
예제 #2
0
 def test_when_subflow_fails_revert_running_tasks(self):
     waiting_task = utils.WaitForOneFromTask('task1', 'task2',
                                             [st.SUCCESS, st.FAILURE])
     flow = uf.Flow('flow-1', retry.Times(3, 'r', provides='x')).add(
         waiting_task, utils.ConditionalTask('task2'))
     engine = self._make_engine(flow)
     engine.task_notifier.register('*', waiting_task.callback)
     engine.storage.inject({'y': 2})
     engine.run()
     self.assertEqual(engine.storage.fetch_all(), {'y': 2, 'x': 2})
     expected = [
         'task2', 'task1', u'task2 reverted(Failure: RuntimeError: Woot!)',
         'task1 reverted(5)', 'task2', 'task1'
     ]
     self.assertItemsEqual(self.values, expected)