|
1
|
|
|
# Licensed to the StackStorm, Inc ('StackStorm') under one or more |
|
2
|
|
|
# contributor license agreements. See the NOTICE file distributed with |
|
3
|
|
|
# this work for additional information regarding copyright ownership. |
|
4
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0 |
|
5
|
|
|
# (the "License"); you may not use this file except in compliance with |
|
6
|
|
|
# the License. You may obtain a copy of the License at |
|
7
|
|
|
# |
|
8
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
|
9
|
|
|
# |
|
10
|
|
|
# Unless required by applicable law or agreed to in writing, software |
|
11
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
|
12
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13
|
|
|
# See the License for the specific language governing permissions and |
|
14
|
|
|
# limitations under the License. |
|
15
|
|
|
|
|
16
|
|
|
from integration.mistral import base |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
class ExceptionHandlingTest(base.TestWorkflowExecution): |
|
20
|
|
|
|
|
21
|
|
|
def test_bad_workflow(self): |
|
22
|
|
|
with self.assertRaises(Exception) as t: |
|
23
|
|
|
self._execute_workflow('examples.mistral-foobar', {}) |
|
24
|
|
|
|
|
25
|
|
|
self.assertIn('Action "examples.mistral-foobar" cannot be found', t.exception.message) |
|
26
|
|
|
|
|
27
|
|
|
def test_bad_action(self): |
|
28
|
|
|
execution = self._execute_workflow('examples.mistral-error-bad-action', {}) |
|
29
|
|
|
execution = self._wait_for_completion(execution) |
|
30
|
|
|
self._assert_failure(execution) |
|
31
|
|
|
self.assertIn('Failed to find action', execution.result['extra']['state_info']) |
|
32
|
|
|
|
|
33
|
|
|
def test_bad_wf_arg(self): |
|
34
|
|
|
execution = self._execute_workflow('examples.mistral-error-bad-wf-arg', {}) |
|
35
|
|
|
|
|
36
|
|
|
execution = self._wait_for_completion( |
|
37
|
|
|
execution, |
|
38
|
|
|
expect_tasks=False, |
|
39
|
|
|
expect_tasks_completed=False |
|
40
|
|
|
) |
|
41
|
|
|
|
|
42
|
|
|
self._assert_failure(execution, expect_tasks_failure=False) |
|
43
|
|
|
self.assertIn('Invalid input', execution.result['extra']['state_info']) |
|
44
|
|
|
|
|
45
|
|
|
def test_bad_wf_input_yaql(self): |
|
46
|
|
|
execution = self._execute_workflow('examples.mistral-error-bad-wf-input-yaql', {}) |
|
47
|
|
|
execution = self._wait_for_completion(execution) |
|
48
|
|
|
self._assert_failure(execution, expect_tasks_failure=False) |
|
49
|
|
|
self.assertIn('Can not evaluate YAQL expression', execution.result['extra']['state_info']) |
|
50
|
|
|
|
|
51
|
|
|
def test_bad_task_transition(self): |
|
52
|
|
|
execution = self._execute_workflow('examples.mistral-error-bad-task-transition', {}) |
|
53
|
|
|
|
|
54
|
|
|
execution = self._wait_for_completion( |
|
55
|
|
|
execution, |
|
56
|
|
|
expect_tasks=False, |
|
57
|
|
|
expect_tasks_completed=False |
|
58
|
|
|
) |
|
59
|
|
|
|
|
60
|
|
|
self._assert_failure(execution, expect_tasks_failure=False) |
|
61
|
|
|
self.assertIn("Task 'task3' not found", execution.result['error']) |
|
62
|
|
|
|
|
63
|
|
|
def test_bad_task_transition_yaql(self): |
|
64
|
|
|
execution = self._execute_workflow('examples.mistral-error-bad-task-transition-yaql', {}) |
|
65
|
|
|
execution = self._wait_for_completion(execution) |
|
66
|
|
|
self._assert_failure(execution, expect_tasks_failure=False) |
|
67
|
|
|
self.assertIn('Can not evaluate YAQL expression', execution.result['extra']['state_info']) |
|
68
|
|
|
|
|
69
|
|
|
def test_bad_with_items(self): |
|
70
|
|
|
execution = self._execute_workflow('examples.mistral-error-bad-with-items', {}) |
|
71
|
|
|
execution = self._wait_for_completion(execution) |
|
72
|
|
|
self._assert_failure(execution, expect_tasks_failure=False) |
|
73
|
|
|
self.assertIn('Wrong input format', execution.result['extra']['state_info']) |
|
74
|
|
|
|
|
75
|
|
|
def test_bad_with_items_yaql(self): |
|
76
|
|
|
execution = self._execute_workflow('examples.mistral-error-bad-with-items-yaql', {}) |
|
77
|
|
|
execution = self._wait_for_completion(execution) |
|
78
|
|
|
self._assert_failure(execution, expect_tasks_failure=False) |
|
79
|
|
|
self.assertIn('Can not evaluate YAQL expression', execution.result['extra']['state_info']) |
|
80
|
|
|
|