ruote 2.1.4 → 2.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +26 -6
- data/CREDITS.txt +1 -1
- data/TODO.txt +20 -9
- data/examples/ruote_quickstart.rb +3 -2
- data/lib/ruote.rb +1 -0
- data/lib/ruote/context.rb +5 -0
- data/lib/ruote/engine.rb +5 -12
- data/lib/ruote/engine/process_error.rb +13 -0
- data/lib/ruote/engine/process_status.rb +18 -1
- data/lib/ruote/exp/condition.rb +0 -5
- data/lib/ruote/exp/fe_participant.rb +12 -6
- data/lib/ruote/exp/fe_subprocess.rb +4 -37
- data/lib/ruote/exp/fe_when.rb +1 -1
- data/lib/ruote/exp/flowexpression.rb +59 -28
- data/lib/ruote/exp/ro_persist.rb +4 -7
- data/lib/ruote/exp/ro_variables.rb +6 -2
- data/lib/ruote/fei.rb +9 -0
- data/lib/ruote/log/wait_logger.rb +1 -0
- data/lib/ruote/part/engine_participant.rb +185 -0
- data/lib/ruote/part/storage_participant.rb +69 -13
- data/lib/ruote/participant.rb +1 -0
- data/lib/ruote/storage/base.rb +1 -1
- data/lib/ruote/subprocess.rb +68 -0
- data/lib/ruote/util/dollar.rb +23 -5
- data/lib/ruote/worker.rb +30 -9
- data/ruote.gemspec +5 -2
- data/test/functional/eft_27_inc.rb +6 -6
- data/test/functional/ft_10_dollar.rb +84 -1
- data/test/functional/ft_1_process_status.rb +43 -0
- data/test/functional/ft_20_storage_participant.rb +124 -5
- data/test/functional/ft_2_errors.rb +11 -4
- data/test/functional/ft_37_engine_participant.rb +295 -0
- metadata +5 -2
@@ -226,7 +226,7 @@ class FtErrorsTest < Test::Unit::TestCase
|
|
226
226
|
|
227
227
|
@engine.register_participant 'alpha', WeakCancelParticipant
|
228
228
|
|
229
|
-
noisy
|
229
|
+
#noisy
|
230
230
|
|
231
231
|
wfid = @engine.launch(pdef)
|
232
232
|
|
@@ -238,8 +238,15 @@ class FtErrorsTest < Test::Unit::TestCase
|
|
238
238
|
|
239
239
|
ps = @engine.process(wfid)
|
240
240
|
|
241
|
-
puts ps.errors.first.trace
|
242
|
-
|
241
|
+
#puts ps.errors.first.trace
|
242
|
+
assert_equal 1, ps.errors.size
|
243
|
+
assert_equal 2, ps.expressions.size
|
244
|
+
|
245
|
+
@engine.kill_process(wfid)
|
246
|
+
|
247
|
+
wait_for(wfid)
|
248
|
+
|
249
|
+
assert_nil @engine.process(wfid)
|
243
250
|
end
|
244
251
|
|
245
252
|
def test_errors_and_subprocesses
|
@@ -354,7 +361,7 @@ class FtErrorsTest < Test::Unit::TestCase
|
|
354
361
|
assert_equal 1, es.size
|
355
362
|
assert_equal 'reply', e['msg']['action']
|
356
363
|
assert_equal wfid, e['msg']['fei']['wfid']
|
357
|
-
assert_equal
|
364
|
+
assert_equal 8, e.size
|
358
365
|
end
|
359
366
|
end
|
360
367
|
|
@@ -0,0 +1,295 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Wed Jan 20 22:35:20 JST 2010
|
6
|
+
#
|
7
|
+
# between Denpasar and Singapore
|
8
|
+
#
|
9
|
+
|
10
|
+
require File.join(File.dirname(__FILE__), 'base')
|
11
|
+
|
12
|
+
require 'ruote'
|
13
|
+
require 'ruote/storage/fs_storage'
|
14
|
+
require 'ruote/part/hash_participant'
|
15
|
+
require 'ruote/part/engine_participant'
|
16
|
+
|
17
|
+
|
18
|
+
class FtEngineParticipantTest < Test::Unit::TestCase
|
19
|
+
#include FunctionalBase
|
20
|
+
|
21
|
+
def setup
|
22
|
+
|
23
|
+
@engine0 =
|
24
|
+
Ruote::Engine.new(
|
25
|
+
Ruote::Worker.new(
|
26
|
+
Ruote::FsStorage.new(
|
27
|
+
'work0',
|
28
|
+
'engine_id' => 'engine0',
|
29
|
+
's_logger' => [ 'ruote/log/test_logger', 'Ruote::TestLogger' ])))
|
30
|
+
@engine1 =
|
31
|
+
Ruote::Engine.new(
|
32
|
+
Ruote::Worker.new(
|
33
|
+
Ruote::FsStorage.new(
|
34
|
+
'work1',
|
35
|
+
'engine_id' => 'engine1',
|
36
|
+
's_logger' => [ 'ruote/log/test_logger', 'Ruote::TestLogger' ])))
|
37
|
+
|
38
|
+
@tracer0 = Tracer.new
|
39
|
+
@engine0.add_service('tracer', @tracer0)
|
40
|
+
|
41
|
+
@tracer1 = Tracer.new
|
42
|
+
@engine1.add_service('tracer', @tracer1)
|
43
|
+
|
44
|
+
@engine0.register_participant(
|
45
|
+
'engine1',
|
46
|
+
Ruote::EngineParticipant,
|
47
|
+
'storage_class' => Ruote::FsStorage,
|
48
|
+
'storage_path' => 'ruote/storage/fs_storage',
|
49
|
+
'storage_args' => 'work1')
|
50
|
+
@engine1.register_participant(
|
51
|
+
'engine0',
|
52
|
+
Ruote::EngineParticipant,
|
53
|
+
'storage_class' => Ruote::FsStorage,
|
54
|
+
'storage_path' => 'ruote/storage/fs_storage',
|
55
|
+
'storage_args' => 'work0')
|
56
|
+
end
|
57
|
+
|
58
|
+
def teardown
|
59
|
+
|
60
|
+
@engine0.shutdown
|
61
|
+
@engine1.shutdown
|
62
|
+
|
63
|
+
FileUtils.rm_rf('work0')
|
64
|
+
FileUtils.rm_rf('work1')
|
65
|
+
end
|
66
|
+
|
67
|
+
def noisy
|
68
|
+
|
69
|
+
@engine0.context.logger.noisy = true
|
70
|
+
@engine1.context.logger.noisy = true
|
71
|
+
@engine1.context.logger.color = '32' # green
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_as_participant
|
75
|
+
|
76
|
+
pdef = Ruote.process_definition do
|
77
|
+
sequence do
|
78
|
+
echo 'a'
|
79
|
+
participant :ref => 'engine1', :pdef => 'subp'
|
80
|
+
echo 'c'
|
81
|
+
end
|
82
|
+
define 'subp' do
|
83
|
+
echo 'b'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
#noisy
|
88
|
+
|
89
|
+
wfid = @engine0.launch(pdef)
|
90
|
+
@engine0.wait_for(wfid)
|
91
|
+
|
92
|
+
assert_equal "a\nc", @tracer0.to_s
|
93
|
+
assert_equal "b", @tracer1.to_s
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_as_subprocess
|
97
|
+
|
98
|
+
pdef = Ruote.process_definition do
|
99
|
+
sequence do
|
100
|
+
echo 'a'
|
101
|
+
subprocess 'subp', :engine => 'engine1'
|
102
|
+
echo 'c'
|
103
|
+
end
|
104
|
+
define 'subp' do
|
105
|
+
echo 'b'
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
#noisy
|
110
|
+
|
111
|
+
wfid = @engine0.launch(pdef)
|
112
|
+
@engine0.wait_for(wfid)
|
113
|
+
|
114
|
+
assert_equal "a\nc", @tracer0.to_s
|
115
|
+
assert_equal "b", @tracer1.to_s
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_as_subprocess_2
|
119
|
+
|
120
|
+
pdef = Ruote.process_definition do
|
121
|
+
sequence do
|
122
|
+
echo 'a'
|
123
|
+
subp :engine => 'engine1'
|
124
|
+
echo 'c'
|
125
|
+
end
|
126
|
+
define 'subp' do
|
127
|
+
echo 'b'
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
#noisy
|
132
|
+
|
133
|
+
wfid = @engine0.launch(pdef)
|
134
|
+
@engine0.wait_for(wfid)
|
135
|
+
|
136
|
+
assert_equal "a\nc", @tracer0.to_s
|
137
|
+
assert_equal "b", @tracer1.to_s
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_cancel_process
|
141
|
+
|
142
|
+
pdef = Ruote.process_definition do
|
143
|
+
sequence do
|
144
|
+
echo 'a'
|
145
|
+
subp :engine => 'engine1'
|
146
|
+
echo 'c'
|
147
|
+
end
|
148
|
+
define 'subp' do
|
149
|
+
alpha
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
#noisy
|
154
|
+
|
155
|
+
alpha = @engine1.register_participant :alpha, Ruote::HashParticipant.new
|
156
|
+
|
157
|
+
wfid = @engine0.launch(pdef)
|
158
|
+
|
159
|
+
@engine1.wait_for(:alpha)
|
160
|
+
|
161
|
+
assert_equal 1, alpha.size
|
162
|
+
assert_not_nil alpha.first.fei.sub_wfid
|
163
|
+
|
164
|
+
@engine0.cancel_process(wfid)
|
165
|
+
@engine0.wait_for(wfid)
|
166
|
+
|
167
|
+
assert_equal 0, alpha.size
|
168
|
+
|
169
|
+
assert_equal "a", @tracer0.to_s
|
170
|
+
assert_equal "", @tracer1.to_s
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_with_variables
|
174
|
+
|
175
|
+
pdef = Ruote.process_definition do
|
176
|
+
sequence do
|
177
|
+
set 'v:v0' => 'b'
|
178
|
+
echo 'a'
|
179
|
+
subp :engine => 'engine1'
|
180
|
+
echo 'c'
|
181
|
+
end
|
182
|
+
define 'subp' do
|
183
|
+
echo '${r:engine_id}:${v:v0}'
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
@engine1.context['ruby_eval_allowed'] = true
|
188
|
+
# just for ${r:engine_id}
|
189
|
+
|
190
|
+
#noisy
|
191
|
+
|
192
|
+
wfid = @engine0.launch(pdef)
|
193
|
+
@engine0.wait_for(wfid)
|
194
|
+
|
195
|
+
assert_equal "a\nc", @tracer0.to_s
|
196
|
+
assert_equal "engine1:b", @tracer1.to_s
|
197
|
+
|
198
|
+
assert_nil @engine0.process(wfid)
|
199
|
+
end
|
200
|
+
|
201
|
+
def test_with_uri
|
202
|
+
|
203
|
+
path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'pdef.xml'))
|
204
|
+
|
205
|
+
pdef = Ruote.process_definition do
|
206
|
+
participant :ref => 'engine1', :pdef => path
|
207
|
+
end
|
208
|
+
|
209
|
+
#noisy
|
210
|
+
|
211
|
+
wfid = @engine0.launch(pdef)
|
212
|
+
@engine0.wait_for(wfid)
|
213
|
+
|
214
|
+
assert_equal "", @tracer0.to_s
|
215
|
+
assert_equal "a\nb", @tracer1.to_s
|
216
|
+
|
217
|
+
assert_nil @engine0.process(wfid)
|
218
|
+
end
|
219
|
+
|
220
|
+
def test_forget
|
221
|
+
|
222
|
+
pdef = Ruote.process_definition do
|
223
|
+
sequence do
|
224
|
+
echo 'a'
|
225
|
+
participant :ref => 'engine1', :pdef => 'subp', :forget => true
|
226
|
+
echo 'c'
|
227
|
+
end
|
228
|
+
define 'subp' do
|
229
|
+
bravo
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
bravo = @engine1.register_participant :bravo, Ruote::HashParticipant.new
|
234
|
+
|
235
|
+
#noisy
|
236
|
+
|
237
|
+
wfid = @engine0.launch(pdef)
|
238
|
+
@engine0.wait_for(wfid) # terminated
|
239
|
+
|
240
|
+
assert_equal [], @engine0.processes
|
241
|
+
|
242
|
+
@engine1.wait_for(:bravo)
|
243
|
+
|
244
|
+
bravo.reply(bravo.first)
|
245
|
+
|
246
|
+
@engine1.wait_for(wfid) # ceased
|
247
|
+
|
248
|
+
assert_equal [], @engine0.processes
|
249
|
+
assert_equal [], @engine1.processes
|
250
|
+
end
|
251
|
+
|
252
|
+
def test_replay_gone_engine_participant
|
253
|
+
|
254
|
+
@engine1.unregister_participant('engine0')
|
255
|
+
|
256
|
+
pdef = Ruote.process_definition do
|
257
|
+
sequence do
|
258
|
+
echo 'a'
|
259
|
+
participant :ref => 'engine1', :pdef => 'subp'
|
260
|
+
echo 'c'
|
261
|
+
end
|
262
|
+
define 'subp' do
|
263
|
+
echo 'b'
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
#noisy
|
268
|
+
|
269
|
+
wfid = @engine0.launch(pdef)
|
270
|
+
@engine1.wait_for(wfid) # error
|
271
|
+
|
272
|
+
errs = @engine1.process(wfid).errors
|
273
|
+
|
274
|
+
assert_equal 1, errs.size
|
275
|
+
|
276
|
+
# fix error cause
|
277
|
+
|
278
|
+
@engine1.register_participant(
|
279
|
+
'engine0',
|
280
|
+
Ruote::EngineParticipant,
|
281
|
+
'storage_class' => Ruote::FsStorage,
|
282
|
+
'storage_path' => 'ruote/storage/fs_storage',
|
283
|
+
'storage_args' => 'work0')
|
284
|
+
|
285
|
+
# replay
|
286
|
+
|
287
|
+
@engine1.replay_at_error(errs.first)
|
288
|
+
|
289
|
+
@engine0.wait_for(wfid)
|
290
|
+
|
291
|
+
assert_equal "a\nc", @tracer0.to_s
|
292
|
+
assert_equal "b", @tracer1.to_s
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Mettraux
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2010-01-
|
13
|
+
date: 2010-01-28 00:00:00 +09:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -202,6 +202,7 @@ files:
|
|
202
202
|
- lib/ruote/parser/xml.rb
|
203
203
|
- lib/ruote/part/block_participant.rb
|
204
204
|
- lib/ruote/part/dispatch_pool.rb
|
205
|
+
- lib/ruote/part/engine_participant.rb
|
205
206
|
- lib/ruote/part/hash_participant.rb
|
206
207
|
- lib/ruote/part/local_participant.rb
|
207
208
|
- lib/ruote/part/no_op_participant.rb
|
@@ -215,6 +216,7 @@ files:
|
|
215
216
|
- lib/ruote/storage/base.rb
|
216
217
|
- lib/ruote/storage/fs_storage.rb
|
217
218
|
- lib/ruote/storage/hash_storage.rb
|
219
|
+
- lib/ruote/subprocess.rb
|
218
220
|
- lib/ruote/tree_dot.rb
|
219
221
|
- lib/ruote/util/dollar.rb
|
220
222
|
- lib/ruote/util/hashdot.rb
|
@@ -304,6 +306,7 @@ files:
|
|
304
306
|
- test/functional/ft_34_cursor_rewind.rb
|
305
307
|
- test/functional/ft_35_add_service.rb
|
306
308
|
- test/functional/ft_36_storage_history.rb
|
309
|
+
- test/functional/ft_37_engine_participant.rb
|
307
310
|
- test/functional/ft_3_participant_registration.rb
|
308
311
|
- test/functional/ft_4_cancel.rb
|
309
312
|
- test/functional/ft_5_on_error.rb
|