Test Failed
Push — master ( f5671d...de3728 )
by W
01:28
created

integration/orquesta/test_wiring_error_handling.py (9 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
            {
28
                'type': 'content',
29
                'message': 'The action "std.noop" is not registered in the database.',
30
                'schema_path': 'properties.tasks.patternProperties.^\w+$.properties.action',
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...
31
                'spec_path': 'tasks.task3.action'
32
            },
33
            {
34
                'type': 'context',
35
                'language': 'yaql',
36
                'expression': '<% ctx().foobar %>',
37
                'message': 'Variable "foobar" is referenced before assignment.',
38
                '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...
39
                'spec_path': 'tasks.task1.input',
40
            },
41
            {
42
                'type': 'expression',
43
                'language': 'yaql',
44
                'expression': '<% <% succeeded() %>',
45
                'message': (
46
                    'Parse error: unexpected \'<\' at '
47
                    'position 0 of expression \'<% succeeded()\''
48
                ),
49
                'schema_path': (
50
                    '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...
51
                    'properties.next.items.properties.when'
52
                ),
53
                'spec_path': 'tasks.task2.next[0].when'
54
            },
55
            {
56
                'type': 'syntax',
57
                'message': '[{\'cmd\': \'echo <% ctx().macro %>\'}] is not of type \'object\'',
58
                '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...
59
                'spec_path': 'tasks.task2.input'
60
            }
61
        ]
62
63
        ex = self._execute_workflow('examples.orquesta-fail-inspection')
64
        ex = self._wait_for_completion(ex)
65
        self.assertEqual(ex.status, ac_const.LIVEACTION_STATUS_FAILED)
66
        self.assertDictEqual(ex.result, {'errors': expected_errors, 'output': None})
67
68
    def test_input_error(self):
69
        expected_errors = [{'message': 'Unknown function "#property#value"'}]
70
        ex = self._execute_workflow('examples.orquesta-fail-input-rendering')
71
        ex = self._wait_for_completion(ex)
72
        self.assertEqual(ex.status, ac_const.LIVEACTION_STATUS_FAILED)
73
        self.assertDictEqual(ex.result, {'errors': expected_errors, 'output': None})
74
75
    def test_vars_error(self):
76
        expected_errors = [{'message': 'Unknown function "#property#value"'}]
77
        ex = self._execute_workflow('examples.orquesta-fail-vars-rendering')
78
        ex = self._wait_for_completion(ex)
79
        self.assertEqual(ex.status, ac_const.LIVEACTION_STATUS_FAILED)
80
        self.assertDictEqual(ex.result, {'errors': expected_errors, 'output': None})
81
82
    def test_start_task_error(self):
83
        expected_errors = [{'message': 'Unknown function "#property#value"', 'task_id': 'task1'}]
84
        ex = self._execute_workflow('examples.orquesta-fail-start-task')
85
        ex = self._wait_for_completion(ex)
86
        self.assertEqual(ex.status, ac_const.LIVEACTION_STATUS_FAILED)
87
        self.assertDictEqual(ex.result, {'errors': expected_errors, 'output': None})
88
89
    def test_task_transition_error(self):
90
        expected_errors = [
91
            {
92
                'message': (
93
                    'Unable to resolve key \'value\' in expression \''
94
                    '<% succeeded() and result().value %>\' from context.'
95
                ),
96
                'task_transition_id': 'task2__0',
97
                'task_id': 'task1'
98
            }
99
        ]
100
101
        ex = self._execute_workflow('examples.orquesta-fail-task-transition')
102
        ex = self._wait_for_completion(ex)
103
        self.assertEqual(ex.status, ac_const.LIVEACTION_STATUS_FAILED)
104
        self.assertDictEqual(ex.result, {'errors': expected_errors, 'output': None})
105
106
    def test_task_publish_error(self):
107
        expected_errors = [
108
            {
109
                'message': (
110
                    'Unable to resolve key \'value\' in expression \''
111
                    '<% result().value %>\' from context.'
112
                ),
113
                'task_transition_id': 'task2__0',
114
                'task_id': 'task1'
115
            }
116
        ]
117
118
        ex = self._execute_workflow('examples.orquesta-fail-task-publish')
119
        ex = self._wait_for_completion(ex)
120
        self.assertEqual(ex.status, ac_const.LIVEACTION_STATUS_FAILED)
121
        self.assertDictEqual(ex.result, {'errors': expected_errors, 'output': None})
122
123
    def test_output_error(self):
124
        expected_errors = [{'message': 'Unknown function "#property#value"'}]
125
        ex = self._execute_workflow('examples.orquesta-fail-output-rendering')
126
        ex = self._wait_for_completion(ex)
127
        self.assertEqual(ex.status, ac_const.LIVEACTION_STATUS_FAILED)
128
        self.assertDictEqual(ex.result, {'errors': expected_errors, 'output': None})
129
130
    def test_task_content_errors(self):
131
        expected_errors = [
132
            {
133
                'type': 'content',
134
                'message': 'The action reference "echo" is not formatted correctly.',
135
                'schema_path': 'properties.tasks.patternProperties.^\w+$.properties.action',
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...
136
                'spec_path': 'tasks.task1.action'
137
            },
138
            {
139
                'type': 'content',
140
                'message': 'The action "core.echoz" is not registered in the database.',
141
                'schema_path': 'properties.tasks.patternProperties.^\w+$.properties.action',
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...
142
                'spec_path': 'tasks.task2.action'
143
            },
144
            {
145
                'type': 'content',
146
                'message': 'Action "core.echo" is missing required input "message".',
147
                '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...
148
                'spec_path': 'tasks.task3.input'
149
            },
150
            {
151
                'type': 'content',
152
                'message': 'Action "core.echo" has unexpected input "messages".',
153
                'schema_path': (
154
                    '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...
155
                    '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...
156
                ),
157
                'spec_path': 'tasks.task3.input.messages'
158
            }
159
        ]
160
161
        ex = self._execute_workflow('examples.orquesta-fail-inspection-task-contents')
162
        ex = self._wait_for_completion(ex)
163
        self.assertEqual(ex.status, ac_const.LIVEACTION_STATUS_FAILED)
164
        self.assertDictEqual(ex.result, {'errors': expected_errors, 'output': None})
165