From a477fe49cdccb4ce34f665b26127e96565da285f Mon Sep 17 00:00:00 2001 From: Renat Akhmerov Date: Tue, 21 May 2019 17:18:25 +0700 Subject: [PATCH] Fix how "has_next_tasks" is calculated for task executions * There was a weird typo in the list generator expression made in https://review.opendev.org/#/c/652575 that led to calculating a field value in the wrong way. Fixed. The added test was previously failing. Closes-Bug: #1829841 Change-Id: I6b8ea8dfa623acbb56f649630ddee62e43d484eb --- mistral/engine/tasks.py | 2 +- .../tests/unit/engine/test_direct_workflow.py | 19 +++++++++++++++++++ ...ks_field_calculation-5717f93d7adcd9b0.yaml | 7 +++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix_has_next_tasks_field_calculation-5717f93d7adcd9b0.yaml diff --git a/mistral/engine/tasks.py b/mistral/engine/tasks.py index ffe7103ad..6e8c89d57 100644 --- a/mistral/engine/tasks.py +++ b/mistral/engine/tasks.py @@ -274,7 +274,7 @@ class Task(object): cmds = wf_ctrl.continue_workflow(task_ex=self.task_ex) # Check whether the task generated any next tasks. - if any([not commands.is_engine_command(c)] for c in cmds): + if any([not commands.is_engine_command(c) for c in cmds]): self.task_ex.has_next_tasks = True # Check whether the error is handled. diff --git a/mistral/tests/unit/engine/test_direct_workflow.py b/mistral/tests/unit/engine/test_direct_workflow.py index 0d8d9994d..f26891143 100644 --- a/mistral/tests/unit/engine/test_direct_workflow.py +++ b/mistral/tests/unit/engine/test_direct_workflow.py @@ -1133,3 +1133,22 @@ class DirectWorkflowEngineTest(base.EngineTestCase): # converted into a string no matter what we tried to assign. But # that didn't happen on Python 2.7 which caused an SQL exception. self.assertIsInstance(task_ex.state_info, six.string_types) + + def test_single_fail_with_next_noop(self): + wf_text = """--- + version: '2.0' + + wf: + tasks: + task1: + action: std.fail + on-error: + - noop + """ + + wf_service.create_workflows(wf_text) + + # Start workflow. + wf_ex = self.engine.start_workflow('wf') + + self.await_workflow_success(wf_ex.id) diff --git a/releasenotes/notes/fix_has_next_tasks_field_calculation-5717f93d7adcd9b0.yaml b/releasenotes/notes/fix_has_next_tasks_field_calculation-5717f93d7adcd9b0.yaml new file mode 100644 index 000000000..baf77a7ef --- /dev/null +++ b/releasenotes/notes/fix_has_next_tasks_field_calculation-5717f93d7adcd9b0.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + There was a weird typo in the list generator expression made in + https://review.opendev.org/#/c/652575 that led to calculating + a field value in the wrong way. Fixed. The added test was + previously failing.