|
1
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
|
|
|
|
3
|
|
|
# Licensed to the StackStorm, Inc ('StackStorm') under one or more |
|
4
|
|
|
# contributor license agreements. See the NOTICE file distributed with |
|
5
|
|
|
# this work for additional information regarding copyright ownership. |
|
6
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0 |
|
7
|
|
|
# (the "License"); you may not use this file except in compliance with |
|
8
|
|
|
# the License. You may obtain a copy of the License at |
|
9
|
|
|
# |
|
10
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
|
|
# |
|
12
|
|
|
# Unless required by applicable law or agreed to in writing, software |
|
13
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15
|
|
|
# See the License for the specific language governing permissions and |
|
16
|
|
|
# limitations under the License. |
|
17
|
|
|
|
|
18
|
|
|
from __future__ import absolute_import |
|
19
|
|
|
|
|
20
|
|
|
from integration.orchestra import base |
|
21
|
|
|
|
|
22
|
|
|
from st2common.constants import action as ac_const |
|
23
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
class WiringTest(base.TestWorkflowExecution): |
|
26
|
|
|
|
|
27
|
|
|
def test_sequential(self): |
|
28
|
|
|
wf_name = 'examples.orchestra-sequential' |
|
29
|
|
|
wf_input = {'name': 'Thanos'} |
|
30
|
|
|
|
|
31
|
|
|
expected_output = {'greeting': 'Thanos, All your base are belong to us!'} |
|
32
|
|
|
expected_result = {'output': expected_output} |
|
33
|
|
|
|
|
34
|
|
|
ex = self._execute_workflow(wf_name, wf_input) |
|
35
|
|
|
ex = self._wait_for_completion(ex) |
|
36
|
|
|
|
|
37
|
|
|
self.assertEqual(ex.status, ac_const.LIVEACTION_STATUS_SUCCEEDED) |
|
38
|
|
|
self.assertDictEqual(ex.result, expected_result) |
|
39
|
|
|
|
|
40
|
|
|
def test_join(self): |
|
41
|
|
|
wf_name = 'examples.orchestra-join' |
|
42
|
|
|
|
|
43
|
|
|
expected_output = { |
|
44
|
|
|
'messages': [ |
|
45
|
|
|
'Fee fi fo fum', |
|
46
|
|
|
'I smell the blood of an English man', |
|
47
|
|
|
'Be alive, or be he dead', |
|
48
|
|
|
'I\'ll grind his bones to make my bread' |
|
49
|
|
|
] |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
expected_result = {'output': expected_output} |
|
53
|
|
|
|
|
54
|
|
|
ex = self._execute_workflow(wf_name) |
|
55
|
|
|
ex = self._wait_for_completion(ex) |
|
56
|
|
|
|
|
57
|
|
|
self.assertEqual(ex.status, ac_const.LIVEACTION_STATUS_SUCCEEDED) |
|
58
|
|
|
self.assertDictEqual(ex.result, expected_result) |
|
59
|
|
|
|
|
60
|
|
|
def test_cycle(self): |
|
61
|
|
|
wf_name = 'examples.orchestra-rollback-retry' |
|
62
|
|
|
|
|
63
|
|
|
expected_output = None |
|
64
|
|
|
expected_result = {'output': expected_output} |
|
65
|
|
|
|
|
66
|
|
|
ex = self._execute_workflow(wf_name) |
|
67
|
|
|
ex = self._wait_for_completion(ex) |
|
68
|
|
|
|
|
69
|
|
|
self.assertEqual(ex.status, ac_const.LIVEACTION_STATUS_SUCCEEDED) |
|
70
|
|
|
self.assertDictEqual(ex.result, expected_result) |
|
71
|
|
|
|
|
72
|
|
|
def test_action_less(self): |
|
73
|
|
|
wf_name = 'examples.orchestra-test-action-less-tasks' |
|
74
|
|
|
wf_input = {'name': 'Thanos'} |
|
75
|
|
|
|
|
76
|
|
|
message = 'Thanos, All your base are belong to us!' |
|
77
|
|
|
expected_output = {'greeting': message.upper()} |
|
78
|
|
|
expected_result = {'output': expected_output} |
|
79
|
|
|
|
|
80
|
|
|
ex = self._execute_workflow(wf_name, wf_input) |
|
81
|
|
|
ex = self._wait_for_completion(ex) |
|
82
|
|
|
|
|
83
|
|
|
self.assertEqual(ex.status, ac_const.LIVEACTION_STATUS_SUCCEEDED) |
|
84
|
|
|
self.assertDictEqual(ex.result, expected_result) |
|
85
|
|
|
|
|
86
|
|
|
def test_st2_runtime_context(self): |
|
87
|
|
|
wf_name = 'examples.orchestra-st2-ctx' |
|
88
|
|
|
|
|
89
|
|
|
ex = self._execute_workflow(wf_name) |
|
90
|
|
|
ex = self._wait_for_completion(ex) |
|
91
|
|
|
|
|
92
|
|
|
expected_output = {'callback': 'http://127.0.0.1:9101/v1/executions/%s' % str(ex.id)} |
|
93
|
|
|
expected_result = {'output': expected_output} |
|
94
|
|
|
|
|
95
|
|
|
self.assertEqual(ex.status, ac_const.LIVEACTION_STATUS_SUCCEEDED) |
|
96
|
|
|
self.assertDictEqual(ex.result, expected_result) |
|
97
|
|
|
|