ruote 2.1.11 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +60 -0
- data/CREDITS.txt +22 -4
- data/LICENSE.txt +1 -1
- data/README.rdoc +6 -7
- data/Rakefile +58 -59
- data/TODO.txt +137 -65
- data/couch_url.txt +1 -0
- data/jruby_issue.txt +32 -0
- data/lib/ruote.rb +1 -1
- data/lib/ruote/context.rb +12 -10
- data/lib/ruote/engine.rb +280 -145
- data/lib/ruote/engine/process_error.rb +5 -5
- data/lib/ruote/engine/process_status.rb +47 -28
- data/lib/ruote/exp/command.rb +7 -10
- data/lib/ruote/exp/commanded.rb +2 -2
- data/lib/ruote/exp/condition.rb +130 -43
- data/lib/ruote/exp/fe_add_branches.rb +2 -2
- data/lib/ruote/exp/fe_apply.rb +1 -1
- data/lib/ruote/exp/fe_cancel_process.rb +3 -3
- data/lib/ruote/exp/fe_command.rb +3 -3
- data/lib/ruote/exp/fe_concurrence.rb +4 -4
- data/lib/ruote/exp/fe_concurrent_iterator.rb +17 -5
- data/lib/ruote/exp/fe_cron.rb +3 -3
- data/lib/ruote/exp/fe_cursor.rb +5 -5
- data/lib/ruote/exp/fe_define.rb +3 -3
- data/lib/ruote/exp/fe_echo.rb +3 -3
- data/lib/ruote/exp/fe_equals.rb +2 -2
- data/lib/ruote/exp/fe_error.rb +2 -2
- data/lib/ruote/exp/fe_filter.rb +519 -0
- data/lib/ruote/exp/fe_forget.rb +9 -2
- data/lib/ruote/exp/fe_given.rb +154 -0
- data/lib/ruote/exp/fe_if.rb +16 -13
- data/lib/ruote/exp/fe_inc.rb +3 -3
- data/lib/ruote/exp/fe_iterator.rb +4 -4
- data/lib/ruote/exp/fe_let.rb +75 -0
- data/lib/ruote/exp/fe_listen.rb +68 -12
- data/lib/ruote/exp/fe_lose.rb +110 -0
- data/lib/ruote/exp/fe_noop.rb +1 -1
- data/lib/ruote/exp/{fe_when.rb → fe_once.rb} +25 -21
- data/lib/ruote/exp/fe_participant.rb +14 -17
- data/lib/ruote/exp/fe_redo.rb +10 -6
- data/lib/ruote/exp/fe_ref.rb +1 -1
- data/lib/ruote/exp/fe_registerp.rb +112 -0
- data/lib/ruote/exp/fe_reserve.rb +3 -3
- data/lib/ruote/exp/fe_restore.rb +2 -2
- data/lib/ruote/exp/fe_save.rb +2 -2
- data/lib/ruote/exp/fe_sequence.rb +3 -4
- data/lib/ruote/exp/fe_set.rb +16 -7
- data/lib/ruote/exp/fe_subprocess.rb +23 -1
- data/lib/ruote/exp/fe_that.rb +92 -0
- data/lib/ruote/exp/fe_undo.rb +3 -3
- data/lib/ruote/exp/fe_unregisterp.rb +71 -0
- data/lib/ruote/exp/fe_wait.rb +2 -2
- data/lib/ruote/exp/flowexpression.rb +153 -78
- data/lib/ruote/exp/iterator.rb +2 -2
- data/lib/ruote/exp/merge.rb +2 -2
- data/lib/ruote/exp/ro_attributes.rb +14 -12
- data/lib/ruote/exp/ro_filters.rb +136 -0
- data/lib/ruote/exp/ro_persist.rb +51 -35
- data/lib/ruote/exp/ro_variables.rb +18 -27
- data/lib/ruote/fei.rb +73 -33
- data/lib/ruote/id/mnemo_wfid_generator.rb +1 -1
- data/lib/ruote/id/wfid_generator.rb +11 -4
- data/lib/ruote/log/default_history.rb +122 -0
- data/lib/ruote/log/pretty.rb +36 -8
- data/lib/ruote/log/storage_history.rb +37 -5
- data/lib/ruote/log/test_logger.rb +26 -24
- data/lib/ruote/log/wait_logger.rb +5 -3
- data/lib/ruote/part/block_participant.rb +22 -11
- data/lib/ruote/part/engine_participant.rb +6 -7
- data/lib/ruote/part/local_participant.rb +6 -12
- data/lib/ruote/part/no_op_participant.rb +4 -4
- data/lib/ruote/part/null_participant.rb +4 -4
- data/lib/ruote/part/smtp_participant.rb +4 -4
- data/lib/ruote/part/storage_participant.rb +40 -20
- data/lib/ruote/part/template.rb +4 -4
- data/lib/ruote/participant.rb +0 -1
- data/lib/ruote/{parser.rb → reader.rb} +30 -25
- data/lib/ruote/{parser → reader}/ruby_dsl.rb +28 -11
- data/lib/ruote/{parser → reader}/xml.rb +6 -5
- data/lib/ruote/receiver/base.rb +35 -13
- data/lib/ruote/storage/base.rb +20 -18
- data/lib/ruote/storage/composite_storage.rb +10 -10
- data/lib/ruote/storage/fs_storage.rb +17 -10
- data/lib/ruote/storage/hash_storage.rb +29 -18
- data/lib/ruote/svc/dispatch_pool.rb +41 -14
- data/lib/ruote/svc/dollar_sub.rb +50 -17
- data/lib/ruote/svc/error_handler.rb +19 -11
- data/lib/ruote/svc/expression_map.rb +4 -4
- data/lib/ruote/svc/participant_list.rb +105 -100
- data/lib/ruote/svc/tracker.rb +58 -18
- data/lib/ruote/svc/treechecker.rb +51 -24
- data/lib/ruote/tree_dot.rb +4 -4
- data/lib/ruote/util/filter.rb +440 -0
- data/lib/ruote/util/hashdot.rb +4 -4
- data/lib/ruote/util/look.rb +2 -6
- data/lib/ruote/util/lookup.rb +9 -7
- data/lib/ruote/util/misc.rb +40 -8
- data/lib/ruote/util/ometa.rb +1 -1
- data/lib/ruote/util/serializer.rb +4 -4
- data/lib/ruote/util/subprocess.rb +29 -9
- data/lib/ruote/util/time.rb +4 -4
- data/lib/ruote/util/tree.rb +3 -3
- data/lib/ruote/version.rb +2 -2
- data/lib/ruote/worker.rb +55 -32
- data/lib/ruote/workitem.rb +64 -11
- data/ruote.gemspec +31 -302
- data/test/bm/launch_bench.rb +37 -0
- data/test/functional/base.rb +60 -18
- data/test/functional/concurrent_base.rb +2 -2
- data/test/functional/ct_0_concurrence.rb +1 -1
- data/test/functional/ct_1_iterator.rb +1 -1
- data/test/functional/ct_2_cancel.rb +1 -1
- data/test/functional/eft_0_process_definition.rb +2 -2
- data/test/functional/eft_10_cancel_process.rb +1 -1
- data/test/functional/eft_11_wait.rb +19 -11
- data/test/functional/eft_12_listen.rb +79 -13
- data/test/functional/eft_13_iterator.rb +13 -10
- data/test/functional/eft_14_cursor.rb +98 -9
- data/test/functional/eft_15_loop.rb +6 -4
- data/test/functional/eft_16_if.rb +12 -0
- data/test/functional/eft_18_concurrent_iterator.rb +31 -32
- data/test/functional/eft_19_reserve.rb +4 -4
- data/test/functional/eft_1_echo.rb +9 -0
- data/test/functional/eft_20_save.rb +4 -4
- data/test/functional/{eft_28_when.rb → eft_28_once.rb} +33 -7
- data/test/functional/eft_30_ref.rb +17 -2
- data/test/functional/eft_31_registerp.rb +130 -0
- data/test/functional/eft_32_lose.rb +93 -0
- data/test/functional/eft_33_let.rb +31 -0
- data/test/functional/eft_34_given.rb +123 -0
- data/test/functional/eft_35_filter.rb +269 -0
- data/test/functional/eft_3_participant.rb +4 -6
- data/test/functional/eft_4_set.rb +16 -2
- data/test/functional/eft_5_subprocess.rb +2 -4
- data/test/functional/eft_6_concurrence.rb +29 -29
- data/test/functional/eft_8_undo.rb +39 -3
- data/test/functional/eft_9_redo.rb +94 -2
- data/test/functional/ft_10_dollar.rb +81 -2
- data/test/functional/ft_11_recursion.rb +13 -17
- data/test/functional/ft_12_launchitem.rb +9 -5
- data/test/functional/ft_13_variables.rb +7 -9
- data/test/functional/ft_14_re_apply.rb +6 -9
- data/test/functional/ft_15_timeout.rb +18 -18
- data/test/functional/ft_16_participant_params.rb +1 -3
- data/test/functional/ft_17_conditional.rb +25 -2
- data/test/functional/ft_18_kill.rb +65 -12
- data/test/functional/ft_1_process_status.rb +147 -71
- data/test/functional/ft_20_storage_participant.rb +0 -1
- data/test/functional/ft_21_forget.rb +82 -1
- data/test/functional/{ft_24_block_participants.rb → ft_24_block_participant.rb} +42 -11
- data/test/functional/ft_25_receiver.rb +47 -17
- data/test/functional/{ft_26_participant_timeout.rb → ft_26_participant_rtimeout.rb} +56 -19
- data/test/functional/ft_29_part_template.rb +6 -5
- data/test/functional/ft_2_errors.rb +21 -37
- data/test/functional/ft_30_smtp_participant.rb +1 -1
- data/test/functional/ft_31_part_blocking.rb +8 -6
- data/test/functional/ft_34_cursor_rewind.rb +13 -10
- data/test/functional/ft_35_add_service.rb +1 -1
- data/test/functional/ft_36_storage_history.rb +24 -1
- data/test/functional/ft_37_default_history.rb +109 -0
- data/test/functional/ft_38_participant_more.rb +10 -10
- data/test/functional/ft_39_wait_for.rb +12 -9
- data/test/functional/ft_3_participant_registration.rb +111 -32
- data/test/functional/ft_40_wait_logger.rb +2 -1
- data/test/functional/ft_41_participants.rb +30 -4
- data/test/functional/ft_43_participant_on_reply.rb +6 -23
- data/test/functional/ft_45_participant_accept.rb +4 -4
- data/test/functional/ft_46_launch_single.rb +36 -2
- data/test/functional/ft_47_wfid_generator.rb +54 -0
- data/test/functional/ft_48_lose.rb +112 -0
- data/test/functional/ft_49_engine_on_error.rb +201 -0
- data/test/functional/ft_4_cancel.rb +66 -6
- data/test/functional/ft_50_engine_config.rb +22 -0
- data/test/functional/ft_51_misc.rb +67 -0
- data/test/functional/ft_52_case.rb +134 -0
- data/test/functional/ft_53_engine_on_terminate.rb +95 -0
- data/test/functional/ft_54_patterns.rb +104 -0
- data/test/functional/{ft_37_engine_participant.rb → ft_55_engine_participant.rb} +4 -5
- data/test/functional/ft_56_filter_attribute.rb +259 -0
- data/test/functional/ft_5_on_error.rb +77 -30
- data/test/functional/ft_6_on_cancel.rb +66 -11
- data/test/functional/ft_7_tags.rb +94 -5
- data/test/functional/ft_8_participant_consumption.rb +36 -5
- data/test/functional/ft_9_subprocesses.rb +10 -10
- data/test/functional/rt_1_listen.rb +3 -3
- data/test/functional/{rt_3_when.rb → rt_3_once.rb} +4 -4
- data/test/functional/storage_helper.rb +15 -13
- data/test/functional/test.rb +1 -3
- data/test/test_helper.rb +0 -8
- data/test/unit/storage.rb +154 -10
- data/test/unit/{ut_0_ruby_parser.rb → ut_0_ruby_reader.rb} +61 -11
- data/test/unit/ut_11_lookup.rb +7 -0
- data/test/unit/ut_13_serializer.rb +1 -1
- data/test/unit/ut_15_util.rb +23 -0
- data/test/unit/{ut_16_parser.rb → ut_16_reader.rb} +11 -13
- data/test/unit/ut_1_fei.rb +57 -10
- data/test/unit/ut_20_composite_storage.rb +25 -11
- data/test/unit/ut_21_participant_list.rb +47 -0
- data/test/unit/ut_22_filter.rb +903 -0
- data/test/unit/ut_3_wait_logger.rb +2 -6
- data/test/unit/ut_6_condition.rb +164 -17
- data/test/unit/ut_7_workitem.rb +28 -0
- data/test/unit/ut_8_tree_to_dot.rb +1 -1
- data/test/unit/{ut_9_xml_parser.rb → ut_9_xml_reader.rb} +5 -5
- metadata +108 -84
- data/.gitignore +0 -4
- data/examples/barley.rb +0 -391
- data/examples/flickr_report.rb +0 -107
- data/examples/pong.rb +0 -37
- data/examples/ruote_quickstart.rb +0 -43
- data/examples/web_first_page.rb +0 -68
- data/lib/ruote/part/hash_participant.rb +0 -91
- data/test/README.rdoc +0 -15
- data/test/functional/crunner.sh +0 -19
- data/test/pdef.xml +0 -7
- data/test/unit/ut_2_wfidgen.rb +0 -21
@@ -30,7 +30,7 @@ class EftIteratorTest < Test::Unit::TestCase
|
|
30
30
|
|
31
31
|
class TraceParticipant
|
32
32
|
include Ruote::LocalParticipant
|
33
|
-
def consume
|
33
|
+
def consume(wi)
|
34
34
|
context.tracer << "#{wi.participant_name}/#{wi.fei.expid}\n"
|
35
35
|
reply(wi)
|
36
36
|
end
|
@@ -110,8 +110,9 @@ class EftIteratorTest < Test::Unit::TestCase
|
|
110
110
|
|
111
111
|
@tracer << "#{workitem.participant_name}\n"
|
112
112
|
|
113
|
-
workitem.
|
114
|
-
|
113
|
+
if workitem.participant_name == 'bob'
|
114
|
+
workitem.fields['__command__'] = [ 'break', nil ]
|
115
|
+
end
|
115
116
|
end
|
116
117
|
|
117
118
|
#noisy
|
@@ -121,14 +122,14 @@ class EftIteratorTest < Test::Unit::TestCase
|
|
121
122
|
|
122
123
|
def test_rewind
|
123
124
|
|
124
|
-
rewound = false
|
125
|
+
stash[:rewound] = false
|
125
126
|
|
126
127
|
@engine.register_participant '.*' do |workitem|
|
127
128
|
|
128
129
|
@tracer << "#{workitem.participant_name}\n"
|
129
130
|
|
130
|
-
if (not rewound) and workitem.participant_name == 'bob'
|
131
|
-
rewound = true
|
131
|
+
if (not stash[:rewound]) and workitem.participant_name == 'bob'
|
132
|
+
stash[:rewound] = true
|
132
133
|
workitem.fields['__command__'] = [ 'rewind', nil ]
|
133
134
|
end
|
134
135
|
end
|
@@ -144,8 +145,9 @@ class EftIteratorTest < Test::Unit::TestCase
|
|
144
145
|
|
145
146
|
@tracer << "#{workitem.participant_name}\n"
|
146
147
|
|
147
|
-
workitem.
|
148
|
-
|
148
|
+
if workitem.participant_name == 'alice'
|
149
|
+
workitem.fields['__command__'] = [ 'skip', 1 ]
|
150
|
+
end
|
149
151
|
end
|
150
152
|
|
151
153
|
#noisy
|
@@ -159,8 +161,9 @@ class EftIteratorTest < Test::Unit::TestCase
|
|
159
161
|
|
160
162
|
@tracer << "#{workitem.participant_name}\n"
|
161
163
|
|
162
|
-
workitem.
|
163
|
-
|
164
|
+
if workitem.participant_name == 'alice'
|
165
|
+
workitem.fields['__command__'] = [ 'jump', -1 ]
|
166
|
+
end
|
164
167
|
end
|
165
168
|
|
166
169
|
#noisy
|
@@ -85,6 +85,21 @@ class EftCursorTest < Test::Unit::TestCase
|
|
85
85
|
assert_trace('a', pdef)
|
86
86
|
end
|
87
87
|
|
88
|
+
def test_over
|
89
|
+
|
90
|
+
pdef = Ruote.process_definition :name => 'test' do
|
91
|
+
cursor do
|
92
|
+
echo 'a'
|
93
|
+
over
|
94
|
+
echo 'b'
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
#noisy
|
99
|
+
|
100
|
+
assert_trace('a', pdef)
|
101
|
+
end
|
102
|
+
|
88
103
|
def test_jump_to_tag
|
89
104
|
|
90
105
|
pdef = Ruote.process_definition :name => 'test' do
|
@@ -154,16 +169,14 @@ class EftCursorTest < Test::Unit::TestCase
|
|
154
169
|
end
|
155
170
|
end
|
156
171
|
|
157
|
-
count = 0
|
158
|
-
# closures ftw
|
159
|
-
|
160
172
|
@engine.register_participant :author do |workitem|
|
161
173
|
@tracer << "a\n"
|
162
|
-
count
|
174
|
+
stash[:count] ||= 0
|
175
|
+
stash[:count] += 1
|
163
176
|
end
|
164
177
|
@engine.register_participant :reviewer do |workitem|
|
165
178
|
@tracer << "r\n"
|
166
|
-
workitem.fields['not_ok'] = (count < 3)
|
179
|
+
workitem.fields['not_ok'] = (stash[:count] < 3)
|
167
180
|
end
|
168
181
|
@engine.register_participant :publisher do |workitem|
|
169
182
|
@tracer << "p\n"
|
@@ -213,7 +226,7 @@ class EftCursorTest < Test::Unit::TestCase
|
|
213
226
|
end
|
214
227
|
end
|
215
228
|
|
216
|
-
@engine.register_participant :alpha, Ruote::NoOpParticipant
|
229
|
+
@engine.register_participant :alpha, Ruote::NoOpParticipant
|
217
230
|
|
218
231
|
#noisy
|
219
232
|
|
@@ -277,15 +290,15 @@ class EftCursorTest < Test::Unit::TestCase
|
|
277
290
|
|
278
291
|
class Alpha
|
279
292
|
include Ruote::LocalParticipant
|
280
|
-
def consume
|
293
|
+
def consume(workitem)
|
281
294
|
workitem.command = 'break'
|
282
295
|
reply_to_engine(workitem)
|
283
296
|
end
|
284
|
-
def cancel
|
297
|
+
def cancel(fei, flavour)
|
285
298
|
end
|
286
299
|
end
|
287
300
|
class Bravo < Alpha
|
288
|
-
def consume
|
301
|
+
def consume(workitem)
|
289
302
|
workitem.command = 'skip 1'
|
290
303
|
reply_to_engine(workitem)
|
291
304
|
end
|
@@ -313,5 +326,81 @@ class EftCursorTest < Test::Unit::TestCase
|
|
313
326
|
|
314
327
|
assert_trace "in\ndone.", pdef
|
315
328
|
end
|
329
|
+
|
330
|
+
def test_cursor_with_lonely_rewind
|
331
|
+
|
332
|
+
pdef = Ruote.define do
|
333
|
+
cursor do
|
334
|
+
rewind
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
#@engine.noisy = true
|
339
|
+
|
340
|
+
wfid = @engine.launch(pdef)
|
341
|
+
|
342
|
+
@engine.wait_for(9)
|
343
|
+
|
344
|
+
assert_not_nil @engine.process(wfid)
|
345
|
+
end
|
346
|
+
|
347
|
+
class Charly
|
348
|
+
include Ruote::LocalParticipant
|
349
|
+
def initialize(opts)
|
350
|
+
@opts = opts
|
351
|
+
end
|
352
|
+
def consume(workitem)
|
353
|
+
workitem.command = @opts['command']
|
354
|
+
reply_to_engine(workitem)
|
355
|
+
end
|
356
|
+
def cancel(fei, flavour)
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
JUMP_DEF = Ruote.process_definition do
|
361
|
+
cursor do
|
362
|
+
echo 'top'
|
363
|
+
charly
|
364
|
+
echo 'middle'
|
365
|
+
delta
|
366
|
+
echo 'bottom'
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
def test_workitem_command_and_jump_array
|
371
|
+
|
372
|
+
#noisy
|
373
|
+
|
374
|
+
@engine.register do
|
375
|
+
charly EftCursorTest::Charly, 'command' => [ 'jump', 'delta' ]
|
376
|
+
catchall Ruote::NoOpParticipant
|
377
|
+
end
|
378
|
+
|
379
|
+
assert_trace "top\nbottom", JUMP_DEF
|
380
|
+
end
|
381
|
+
|
382
|
+
def test_workitem_command_and_jump_string
|
383
|
+
|
384
|
+
#noisy
|
385
|
+
|
386
|
+
@engine.register do
|
387
|
+
charly EftCursorTest::Charly, 'command' => 'jump delta'
|
388
|
+
catchall Ruote::NoOpParticipant
|
389
|
+
end
|
390
|
+
|
391
|
+
assert_trace "top\nbottom", JUMP_DEF
|
392
|
+
end
|
393
|
+
|
394
|
+
def test_workitem_command_and_jump_to_string
|
395
|
+
|
396
|
+
#noisy
|
397
|
+
|
398
|
+
@engine.register do
|
399
|
+
charly EftCursorTest::Charly, 'command' => 'jump to delta'
|
400
|
+
catchall Ruote::NoOpParticipant
|
401
|
+
end
|
402
|
+
|
403
|
+
assert_trace "top\nbottom", JUMP_DEF
|
404
|
+
end
|
316
405
|
end
|
317
406
|
|
@@ -34,8 +34,9 @@ class EftLoopTest < Test::Unit::TestCase
|
|
34
34
|
@tracer << "b\n"
|
35
35
|
workitem.fields['count'] += 1
|
36
36
|
|
37
|
-
workitem.fields['
|
38
|
-
|
37
|
+
if workitem.fields['count'] > 5
|
38
|
+
workitem.fields['__command__'] = [ 'break', nil ]
|
39
|
+
end
|
39
40
|
end
|
40
41
|
|
41
42
|
assert_trace(%w[ a b a b a b ], pdef)
|
@@ -57,8 +58,9 @@ class EftLoopTest < Test::Unit::TestCase
|
|
57
58
|
(workitem.fields['count'] ||= 0)
|
58
59
|
workitem.fields['count'] += 1
|
59
60
|
|
60
|
-
workitem.fields['
|
61
|
-
|
61
|
+
if workitem.fields['count'] > 5
|
62
|
+
workitem.fields['__command__'] = [ 'break', nil ]
|
63
|
+
end
|
62
64
|
end
|
63
65
|
|
64
66
|
assert_trace(%w[ a a a a a a ], pdef)
|
@@ -167,5 +167,17 @@ class EftIfTest < Test::Unit::TestCase
|
|
167
167
|
|
168
168
|
assert_trace('alpha', { :state => 'A' }, pdef)
|
169
169
|
end
|
170
|
+
|
171
|
+
def test_t
|
172
|
+
|
173
|
+
pdef = Ruote.define do
|
174
|
+
_if :t => 'true' do
|
175
|
+
echo 'then'
|
176
|
+
end
|
177
|
+
echo 'done.'
|
178
|
+
end
|
179
|
+
|
180
|
+
assert_trace("then\ndone.", pdef)
|
181
|
+
end
|
170
182
|
end
|
171
183
|
|
@@ -7,9 +7,6 @@
|
|
7
7
|
|
8
8
|
require File.join(File.dirname(__FILE__), 'base')
|
9
9
|
|
10
|
-
require 'ruote/part/hash_participant'
|
11
|
-
require 'ruote/part/null_participant'
|
12
|
-
|
13
10
|
|
14
11
|
class EftConcurrentIteratorTest < Test::Unit::TestCase
|
15
12
|
include FunctionalBase
|
@@ -33,7 +30,7 @@ class EftConcurrentIteratorTest < Test::Unit::TestCase
|
|
33
30
|
|
34
31
|
pdef = Ruote.process_definition :name => 'test' do
|
35
32
|
sequence do
|
36
|
-
|
33
|
+
citerator :on_val => '', :to_var => 'v' do
|
37
34
|
echo 'x'
|
38
35
|
end
|
39
36
|
echo 'done.'
|
@@ -146,33 +143,36 @@ class EftConcurrentIteratorTest < Test::Unit::TestCase
|
|
146
143
|
end
|
147
144
|
end
|
148
145
|
|
149
|
-
|
150
|
-
|
151
|
-
|
146
|
+
sto = @engine.register_participant '.+', Ruote::StorageParticipant
|
147
|
+
|
148
|
+
assert_equal 0, sto.size # just to be sure
|
152
149
|
|
153
150
|
#noisy
|
154
151
|
|
155
152
|
wfid = @engine.launch(pdef)
|
156
153
|
|
154
|
+
wait_for(:participant_1)
|
157
155
|
wait_for(:participant_1)
|
158
156
|
|
159
|
-
assert_equal
|
160
|
-
|
157
|
+
assert_equal(
|
158
|
+
{ 'participant_1' => 2 },
|
159
|
+
sto.per_participant_count)
|
161
160
|
|
162
|
-
|
161
|
+
sto.reply(sto.first)
|
163
162
|
|
164
163
|
wait_for(:participant_2)
|
164
|
+
wait_for(1)
|
165
165
|
|
166
|
-
assert_equal
|
167
|
-
|
166
|
+
assert_equal(
|
167
|
+
{ 'participant_1' => 1, 'participant_2' => 1 },
|
168
|
+
sto.per_participant_count)
|
168
169
|
|
169
|
-
|
170
|
+
sto.reply(sto.per_participant['participant_2'].first)
|
170
171
|
|
171
172
|
wait_for(3)
|
172
173
|
|
173
|
-
assert_equal
|
174
|
-
assert_equal
|
175
|
-
assert_equal 0, p2.size
|
174
|
+
assert_equal 1, sto.size
|
175
|
+
assert_equal 'participant_1', sto.first.participant_name
|
176
176
|
end
|
177
177
|
|
178
178
|
def test_passing_non_array_as_thing_to_iterate
|
@@ -269,10 +269,8 @@ class EftConcurrentIteratorTest < Test::Unit::TestCase
|
|
269
269
|
bravo
|
270
270
|
end
|
271
271
|
|
272
|
-
mf = nil
|
273
|
-
|
274
272
|
@engine.register_participant :bravo do |workitem|
|
275
|
-
mf = workitem.fields
|
273
|
+
stash[:mf] = workitem.fields
|
276
274
|
nil
|
277
275
|
end
|
278
276
|
|
@@ -280,7 +278,7 @@ class EftConcurrentIteratorTest < Test::Unit::TestCase
|
|
280
278
|
|
281
279
|
assert_trace(%w[ . . . ], pdef)
|
282
280
|
|
283
|
-
mf = ('0'..'2').to_a.map { |k| mf[k]['f'] }.sort
|
281
|
+
mf = ('0'..'2').to_a.map { |k| @engine.context.stash[:mf][k]['f'] }.sort
|
284
282
|
assert_equal %w[ a b c ], mf
|
285
283
|
end
|
286
284
|
|
@@ -293,10 +291,8 @@ class EftConcurrentIteratorTest < Test::Unit::TestCase
|
|
293
291
|
bravo
|
294
292
|
end
|
295
293
|
|
296
|
-
mf = nil
|
297
|
-
|
298
294
|
@engine.register_participant :bravo do |workitem|
|
299
|
-
mf = workitem.fields
|
295
|
+
stash[:mf] = workitem.fields
|
300
296
|
nil
|
301
297
|
end
|
302
298
|
|
@@ -306,10 +302,10 @@ class EftConcurrentIteratorTest < Test::Unit::TestCase
|
|
306
302
|
|
307
303
|
assert_equal(
|
308
304
|
[["a"], ["b"]],
|
309
|
-
mf['stack'].collect { |f| f.values }.sort)
|
305
|
+
@engine.context.stash[:mf]['stack'].collect { |f| f.values }.sort)
|
310
306
|
assert_equal(
|
311
307
|
{"on"=>"a, b", "to_f"=>"f", "merge_type"=>"stack"},
|
312
|
-
mf['stack_attributes'])
|
308
|
+
@engine.context.stash[:mf]['stack_attributes'])
|
313
309
|
end
|
314
310
|
|
315
311
|
def test_cancel
|
@@ -326,8 +322,8 @@ class EftConcurrentIteratorTest < Test::Unit::TestCase
|
|
326
322
|
end
|
327
323
|
end
|
328
324
|
|
329
|
-
a_count = 0
|
330
|
-
@engine.register_participant(:alpha) { |wi| a_count += 1 }
|
325
|
+
@engine.context.stash[:a_count] = 0
|
326
|
+
@engine.register_participant(:alpha) { |wi| stash[:a_count] += 1 }
|
331
327
|
@engine.register_participant(:bravo, Ruote::NullParticipant)
|
332
328
|
|
333
329
|
#noisy
|
@@ -337,7 +333,7 @@ class EftConcurrentIteratorTest < Test::Unit::TestCase
|
|
337
333
|
wait_for(2 + n * 5)
|
338
334
|
#p "=" * 80
|
339
335
|
|
340
|
-
assert_equal n, a_count
|
336
|
+
assert_equal n, @engine.context.stash[:a_count]
|
341
337
|
|
342
338
|
@engine.cancel_process(wfid)
|
343
339
|
wait_for(wfid)
|
@@ -356,12 +352,11 @@ class EftConcurrentIteratorTest < Test::Unit::TestCase
|
|
356
352
|
end
|
357
353
|
end
|
358
354
|
|
359
|
-
@engine.register_participant 'alpha' do |
|
355
|
+
@engine.register_participant 'alpha' do |wi|
|
360
356
|
|
361
357
|
@tracer << "#{workitem.fields['f']}\n"
|
362
358
|
|
363
|
-
|
364
|
-
if workitem.fields['f'] == 2
|
359
|
+
wi.fields['__add_branches__'] = %w[ a b ] if wi.fields['f'] == 2
|
365
360
|
end
|
366
361
|
|
367
362
|
#noisy
|
@@ -377,10 +372,14 @@ class EftConcurrentIteratorTest < Test::Unit::TestCase
|
|
377
372
|
def register_catchall_participant
|
378
373
|
|
379
374
|
@subs = []
|
375
|
+
subs = @subs
|
376
|
+
@engine.context.instance_eval do
|
377
|
+
@subs = subs
|
378
|
+
end
|
380
379
|
|
381
380
|
@engine.register_participant '.*' do |workitem|
|
382
381
|
|
383
|
-
@subs << workitem.fei.
|
382
|
+
@subs << workitem.fei.subid
|
384
383
|
|
385
384
|
@tracer << [
|
386
385
|
workitem.participant_name, workitem.fei.expid
|
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
require File.join(File.dirname(__FILE__), 'base')
|
9
9
|
|
10
|
-
require 'ruote/
|
10
|
+
require 'ruote/participant'
|
11
11
|
|
12
12
|
|
13
13
|
class EftReserveTest < Test::Unit::TestCase
|
@@ -28,7 +28,7 @@ class EftReserveTest < Test::Unit::TestCase
|
|
28
28
|
|
29
29
|
#noisy
|
30
30
|
|
31
|
-
alpha = @engine.register_participant :alpha, Ruote::
|
31
|
+
alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
|
32
32
|
|
33
33
|
wfid = @engine.launch(pdef)
|
34
34
|
|
@@ -74,7 +74,7 @@ class EftReserveTest < Test::Unit::TestCase
|
|
74
74
|
|
75
75
|
#noisy
|
76
76
|
|
77
|
-
alpha = @engine.register_participant :alpha, Ruote::
|
77
|
+
alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
|
78
78
|
|
79
79
|
wfid = @engine.launch(pdef)
|
80
80
|
|
@@ -112,7 +112,7 @@ class EftReserveTest < Test::Unit::TestCase
|
|
112
112
|
|
113
113
|
#noisy
|
114
114
|
|
115
|
-
alpha = @engine.register_participant :alpha, Ruote::
|
115
|
+
alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
|
116
116
|
|
117
117
|
wfid = @engine.launch(pdef)
|
118
118
|
|