Test Failed
Push — master ( e380d0...f5671d )
by W
02:58
created

integration/orquesta/test_wiring_error_handling.py (3 issues)

Labels
Severity
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 __future__ import absolute_import
17
18
from integration.orquesta import base
19
20
from st2common.constants import action as ac_const
21
22
23
class ErrorHandlingTest(base.TestWorkflowExecution):
24
25
    def test_inspection_error(self):
26
        expected_errors = {
27
            'context': [
28
                {
29
                    'type': 'yaql',
30
                    'expression': '<% ctx().foobar %>',
31
                    'message': 'Variable "foobar" is referenced before assignment.',
32
                    'schema_path': 'properties.tasks.patternProperties.^\w+$.properties.input',
0 ignored issues
show
A suspicious escape sequence \w was found. Did you maybe forget to add an r prefix?

Escape sequences in Python are generally interpreted according to rules similar to standard C. Only if strings are prefixed with r or R are they interpreted as regular expressions.

The escape sequence that was used indicates that you might have intended to write a regular expression.

Learn more about the available escape sequences. in the Python documentation.

Loading history...
33
                    'spec_path': 'tasks.task1.input',
34
                }
35
            ],
36
            'expressions': [
37
                {
38
                    'type': 'yaql',
39
                    'expression': '<% <% succeeded() %>',
40
                    'message': (
41
                        'Parse error: unexpected \'<\' at '
42
                        'position 0 of expression \'<% succeeded()\''
43
                    ),
44
                    'schema_path': (
45
                        'properties.tasks.patternProperties.^\w+$.'
0 ignored issues
show
A suspicious escape sequence \w was found. Did you maybe forget to add an r prefix?

Escape sequences in Python are generally interpreted according to rules similar to standard C. Only if strings are prefixed with r or R are they interpreted as regular expressions.

The escape sequence that was used indicates that you might have intended to write a regular expression.

Learn more about the available escape sequences. in the Python documentation.

Loading history...
46
                        'properties.next.items.properties.when'
47
                    ),
48
                    'spec_path': 'tasks.task2.next[0].when'
49
                }
50
            ],
51
            'syntax': [
52
                {
53
                    'message': '[{\'cmd\': \'echo <% ctx().macro %>\'}] is not of type \'object\'',
54
                    'schema_path': 'properties.tasks.patternProperties.^\w+$.properties.input.type',
0 ignored issues
show
A suspicious escape sequence \w was found. Did you maybe forget to add an r prefix?

Escape sequences in Python are generally interpreted according to rules similar to standard C. Only if strings are prefixed with r or R are they interpreted as regular expressions.

The escape sequence that was used indicates that you might have intended to write a regular expression.

Learn more about the available escape sequences. in the Python documentation.

Loading history...
55
                    'spec_path': 'tasks.task2.input'
56
                }
57
            ]
58
        }
59
60
        ex = self._execute_workflow('examples.orquesta-fail-inspection')
61
        ex = self._wait_for_completion(ex)
62
        self.assertEqual(ex.status, ac_const.LIVEACTION_STATUS_FAILED)
63
        self.assertDictEqual(ex.result, {'errors': expected_errors, 'output': None})
64
65
    def test_input_error(self):
66
        expected_errors = [{'message': 'Unknown function "#property#value"'}]
67
        ex = self._execute_workflow('examples.orquesta-fail-input-rendering')
68
        ex = self._wait_for_completion(ex)
69
        self.assertEqual(ex.status, ac_const.LIVEACTION_STATUS_FAILED)
70
        self.assertDictEqual(ex.result, {'errors': expected_errors, 'output': None})
71
72
    def test_vars_error(self):
73
        expected_errors = [{'message': 'Unknown function "#property#value"'}]
74
        ex = self._execute_workflow('examples.orquesta-fail-vars-rendering')
75
        ex = self._wait_for_completion(ex)
76
        self.assertEqual(ex.status, ac_const.LIVEACTION_STATUS_FAILED)
77
        self.assertDictEqual(ex.result, {'errors': expected_errors, 'output': None})
78
79
    def test_start_task_error(self):
80
        expected_errors = [{'message': 'Unknown function "#property#value"', 'task_id': 'task1'}]
81
        ex = self._execute_workflow('examples.orquesta-fail-start-task')
82
        ex = self._wait_for_completion(ex)
83
        self.assertEqual(ex.status, ac_const.LIVEACTION_STATUS_FAILED)
84
        self.assertDictEqual(ex.result, {'errors': expected_errors, 'output': None})
85
86
    def test_task_transition_error(self):
87
        expected_errors = [
88
            {
89
                'message': (
90
                    'Unable to resolve key \'value\' in expression \''
91
                    '<% succeeded() and result().value %>\' from context.'
92
                ),
93
                'task_transition_id': 'task2__0',
94
                'task_id': 'task1'
95
            }
96
        ]
97
98
        ex = self._execute_workflow('examples.orquesta-fail-task-transition')
99
        ex = self._wait_for_completion(ex)
100
        self.assertEqual(ex.status, ac_const.LIVEACTION_STATUS_FAILED)
101
        self.assertDictEqual(ex.result, {'errors': expected_errors, 'output': None})
102
103
    def test_task_publish_error(self):
104
        expected_errors = [
105
            {
106
                'message': (
107
                    'Unable to resolve key \'value\' in expression \''
108
                    '<% result().value %>\' from context.'
109
                ),
110
                'task_transition_id': 'task2__0',
111
                'task_id': 'task1'
112
            }
113
        ]
114
115
        ex = self._execute_workflow('examples.orquesta-fail-task-publish')
116
        ex = self._wait_for_completion(ex)
117
        self.assertEqual(ex.status, ac_const.LIVEACTION_STATUS_FAILED)
118
        self.assertDictEqual(ex.result, {'errors': expected_errors, 'output': None})
119
120
    def test_output_error(self):
121
        expected_errors = [{'message': 'Unknown function "#property#value"'}]
122
        ex = self._execute_workflow('examples.orquesta-fail-output-rendering')
123
        ex = self._wait_for_completion(ex)
124
        self.assertEqual(ex.status, ac_const.LIVEACTION_STATUS_FAILED)
125
        self.assertDictEqual(ex.result, {'errors': expected_errors, 'output': None})
126