Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-10-task-retries feacd9f66 -> f3df22048


add support for infinite retries


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/f3df2204
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/f3df2204
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/f3df2204

Branch: refs/heads/ARIA-10-task-retries
Commit: f3df22048e364c7788a8835cdcc6c0ef48aae9fa
Parents: feacd9f
Author: Dan Kilman <[email protected]>
Authored: Tue Nov 8 17:12:19 2016 +0200
Committer: Dan Kilman <[email protected]>
Committed: Tue Nov 8 17:12:19 2016 +0200

----------------------------------------------------------------------
 aria/events/builtin_event_handler.py      |  2 +-
 aria/storage/models.py                    |  1 +
 tests/workflows/core/test_engine.py       | 16 ++++++++++++++++
 tests/workflows/executor/test_executor.py |  2 ++
 4 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f3df2204/aria/events/builtin_event_handler.py
----------------------------------------------------------------------
diff --git a/aria/events/builtin_event_handler.py 
b/aria/events/builtin_event_handler.py
index 280785e..3072ba5 100644
--- a/aria/events/builtin_event_handler.py
+++ b/aria/events/builtin_event_handler.py
@@ -53,7 +53,7 @@ def _task_started(task, *args, **kwargs):
 @on_failure_task_signal.connect
 def _task_failed(task, *args, **kwargs):
     with task.update():
-        if task.retry_count < task.max_retries:
+        if task.retry_count < task.max_retries or task.max_retries == 
task.INFINITE_RETRIES:
             task.status = task.RETRYING
             task.retry_count += 1
             task.eta = datetime.utcnow() + 
timedelta(seconds=task.retry_interval)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f3df2204/aria/storage/models.py
----------------------------------------------------------------------
diff --git a/aria/storage/models.py b/aria/storage/models.py
index e74d733..47b5cb7 100644
--- a/aria/storage/models.py
+++ b/aria/storage/models.py
@@ -391,6 +391,7 @@ class Task(Model):
     )
     WAIT_STATES = [PENDING, RETRYING]
     END_STATES = [SUCCESS, FAILED]
+    INFINITE_RETRIES = -1
 
     id = Field(type=basestring, default=uuid_generator)
     status = Field(type=basestring, choices=STATES, default=PENDING)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f3df2204/tests/workflows/core/test_engine.py
----------------------------------------------------------------------
diff --git a/tests/workflows/core/test_engine.py 
b/tests/workflows/core/test_engine.py
index 39c9cb2..40072c0 100644
--- a/tests/workflows/core/test_engine.py
+++ b/tests/workflows/core/test_engine.py
@@ -269,6 +269,22 @@ class TestRetries(BaseTest):
         assert len(global_test_holder.get('invocations', [])) == 3
         assert global_test_holder.get('sent_task_signal_calls') == 3
 
+    def test_infinite_retries(self, workflow_context, executor):
+        @workflow
+        def mock_workflow(ctx, graph):
+            op = self._op(mock_conditional_failure_task, ctx,
+                          inputs={'fail_on_invocations_less_than': 1},
+                          max_retries=-1)
+            graph.add_tasks(op)
+        self._execute(
+            workflow_func=mock_workflow,
+            workflow_context=workflow_context,
+            executor=executor)
+        assert workflow_context.states == ['start', 'success']
+        assert workflow_context.exception is None
+        assert len(global_test_holder.get('invocations', [])) == 2
+        assert global_test_holder.get('sent_task_signal_calls') == 2
+
     def test_retry_interval_float(self, workflow_context, executor):
         self._test_retry_interval(retry_interval=0.3,
                                   workflow_context=workflow_context,

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f3df2204/tests/workflows/executor/test_executor.py
----------------------------------------------------------------------
diff --git a/tests/workflows/executor/test_executor.py 
b/tests/workflows/executor/test_executor.py
index bbbfbc7..1318485 100644
--- a/tests/workflows/executor/test_executor.py
+++ b/tests/workflows/executor/test_executor.py
@@ -104,6 +104,8 @@ class MockException(Exception):
 
 class MockTask(object):
 
+    INFINITE_RETRIES = models.Task.INFINITE_RETRIES
+
     def __init__(self, func, inputs=None):
         self.states = []
         self.exception = None

Reply via email to