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
@@ -0,0 +1,54 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Sat Oct 23 14:22:15 JST 2010
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
|
11
|
+
class FtWfidGeneratorTest < Test::Unit::TestCase
|
12
|
+
include FunctionalBase
|
13
|
+
|
14
|
+
# an old test, brought back
|
15
|
+
#
|
16
|
+
def test_generate_unique_ids
|
17
|
+
|
18
|
+
n = 147
|
19
|
+
|
20
|
+
wfids = []
|
21
|
+
n.times { wfids << @engine.context.wfidgen.generate }
|
22
|
+
|
23
|
+
assert_equal n, wfids.uniq.size
|
24
|
+
end
|
25
|
+
|
26
|
+
# making a purge! doesn't incapacitate wfid generation
|
27
|
+
# (had a false alert when working with @hassox)
|
28
|
+
#
|
29
|
+
def test_generate_even_after_a_purge
|
30
|
+
|
31
|
+
assert_not_nil @engine.context.wfidgen.generate
|
32
|
+
|
33
|
+
@engine.storage.purge!
|
34
|
+
#@engine.context.wfidgen.instance_eval { @last = nil }
|
35
|
+
|
36
|
+
assert_not_nil @engine.context.wfidgen.generate
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_generate_after_a_put_failed
|
40
|
+
|
41
|
+
assert_not_nil @engine.context.wfidgen.generate
|
42
|
+
|
43
|
+
@engine.context.wfidgen.instance_eval do
|
44
|
+
if @last['_rev'].is_a?(String)
|
45
|
+
@last['_rev'] = '1-cc9bc774f00b65ee28a6c0e4f26474de'
|
46
|
+
else # integer
|
47
|
+
@last['_rev'] = 123456789
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
assert_not_nil @engine.context.wfidgen.generate
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
@@ -0,0 +1,112 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Thu Nov 25 11:20:04 JST 2010
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
#require 'ruote/part/storage_participant'
|
11
|
+
|
12
|
+
|
13
|
+
class FtLoseTest < Test::Unit::TestCase
|
14
|
+
include FunctionalBase
|
15
|
+
|
16
|
+
def test_lose_participiant
|
17
|
+
|
18
|
+
pdef = Ruote.process_definition do
|
19
|
+
sequence do
|
20
|
+
alpha :lose => true
|
21
|
+
alpha
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
@engine.register_participant '.+' do |wi|
|
26
|
+
@tracer << wi.participant_name + "\n"
|
27
|
+
end
|
28
|
+
|
29
|
+
#@engine.noisy = true
|
30
|
+
|
31
|
+
wfid = @engine.launch(pdef)
|
32
|
+
|
33
|
+
@engine.wait_for(6)
|
34
|
+
|
35
|
+
#sleep 0.500
|
36
|
+
|
37
|
+
assert_equal 'alpha', @tracer.to_s
|
38
|
+
|
39
|
+
ps = @engine.process(wfid)
|
40
|
+
|
41
|
+
assert_equal 3, ps.expressions.size
|
42
|
+
assert_equal 0, ps.errors.size
|
43
|
+
# the sequence is stuck, the lost alpha is not replying
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_lose_sequence
|
47
|
+
|
48
|
+
pdef = Ruote.process_definition do
|
49
|
+
concurrence do
|
50
|
+
alpha
|
51
|
+
sequence :lose => 'true' do
|
52
|
+
bravo
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
@engine.register_participant '.+' do |wi|
|
58
|
+
@tracer << wi.participant_name + "\n"
|
59
|
+
end
|
60
|
+
|
61
|
+
#@engine.noisy = true
|
62
|
+
|
63
|
+
wfid = @engine.launch(pdef)
|
64
|
+
|
65
|
+
@engine.wait_for(12)
|
66
|
+
|
67
|
+
assert_match /alpha/, @tracer.to_s
|
68
|
+
assert_match /bravo/, @tracer.to_s
|
69
|
+
|
70
|
+
ps = @engine.process(wfid)
|
71
|
+
|
72
|
+
assert_equal 3, ps.expressions.size
|
73
|
+
assert_equal 0, ps.errors.size
|
74
|
+
# the concurrence is stuck, the lost sequence won't reply
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_cancel_lost_expression
|
78
|
+
|
79
|
+
pdef = Ruote.define do
|
80
|
+
sequence do
|
81
|
+
alpha
|
82
|
+
bravo :lose => true
|
83
|
+
charly
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
@engine.register_participant '.+' do |wi|
|
88
|
+
@tracer << wi.participant_name + "\n"
|
89
|
+
end
|
90
|
+
|
91
|
+
#@engine.noisy = true
|
92
|
+
|
93
|
+
wfid = @engine.launch(pdef)
|
94
|
+
|
95
|
+
@engine.wait_for(12)
|
96
|
+
# until bravo is reached
|
97
|
+
|
98
|
+
#sleep 0.500
|
99
|
+
|
100
|
+
assert_equal "alpha\nbravo", @tracer.to_s
|
101
|
+
|
102
|
+
bravo = @engine.process(wfid).expressions.last
|
103
|
+
|
104
|
+
@engine.cancel_expression(bravo.fei)
|
105
|
+
|
106
|
+
@engine.wait_for(wfid)
|
107
|
+
|
108
|
+
assert_equal "alpha\nbravo\ncharly", @tracer.to_s
|
109
|
+
assert_nil @engine.process(wfid)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
@@ -0,0 +1,201 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Mon Dec 6 10:02:56 JST 2010
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
require 'ruote/participant'
|
11
|
+
|
12
|
+
|
13
|
+
class FtEngineOnErrorTest < Test::Unit::TestCase
|
14
|
+
include FunctionalBase
|
15
|
+
|
16
|
+
def setup
|
17
|
+
super
|
18
|
+
@engine.context.stash[:seen] = []
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_no_on_error
|
22
|
+
|
23
|
+
assert_nil @engine.on_error
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_on_error
|
27
|
+
|
28
|
+
@engine.on_error = 'supervisor'
|
29
|
+
|
30
|
+
assert_equal(
|
31
|
+
[ 'define', {}, [ [ 'supervisor', {}, [] ] ] ],
|
32
|
+
@engine.on_error)
|
33
|
+
end
|
34
|
+
|
35
|
+
class Supervisor
|
36
|
+
include Ruote::LocalParticipant
|
37
|
+
def initialize(opts)
|
38
|
+
@opts = opts
|
39
|
+
end
|
40
|
+
def consume(workitem)
|
41
|
+
workitem.fields['flavour'] = @opts['flavour']
|
42
|
+
@context.stash[:seen] << workitem
|
43
|
+
reply(workitem)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
WRONGY = Ruote.process_definition do
|
48
|
+
error "something went wrong"
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_on_error_participant
|
52
|
+
|
53
|
+
@engine.register 'supervisor', Supervisor, 'flavour' => 'vanilla'
|
54
|
+
@engine.on_error = 'supervisor'
|
55
|
+
|
56
|
+
#@engine.noisy = true
|
57
|
+
|
58
|
+
wfid = @engine.launch(WRONGY, 'colour' => 'yellow')
|
59
|
+
|
60
|
+
@engine.wait_for(wfid)
|
61
|
+
@engine.wait_for(:supervisor)
|
62
|
+
|
63
|
+
sleep 0.350
|
64
|
+
# unfortunately waiting for a participant triggers right
|
65
|
+
# before the consume
|
66
|
+
|
67
|
+
assert_equal 1, @engine.context.stash[:seen].size
|
68
|
+
assert_equal 'yellow', @engine.context.stash[:seen].first.fields['colour']
|
69
|
+
assert_equal 'vanilla', @engine.context.stash[:seen].first.fields['flavour']
|
70
|
+
assert_not_nil @engine.context.stash[:seen].first.fei.subid
|
71
|
+
|
72
|
+
# TODO : look for error message and such
|
73
|
+
|
74
|
+
@engine.wait_for(@engine.context.stash[:seen].first.wfid)
|
75
|
+
|
76
|
+
assert_equal 1, @engine.processes.size
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_on_error_engine_subprocess_name
|
80
|
+
|
81
|
+
@engine.variables['trigger_alarm'] = Ruote.define do
|
82
|
+
echo '${colour} seen'
|
83
|
+
end
|
84
|
+
@engine.on_error = 'trigger_alarm'
|
85
|
+
|
86
|
+
#@engine.noisy = true
|
87
|
+
|
88
|
+
wfid = @engine.launch(WRONGY, 'colour' => 'red')
|
89
|
+
|
90
|
+
@engine.wait_for(wfid)
|
91
|
+
|
92
|
+
sleep 0.700
|
93
|
+
# letting the subprocess getting triggered
|
94
|
+
|
95
|
+
assert_equal 'red seen', @tracer.to_s
|
96
|
+
assert_equal 1, @engine.processes.size
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_on_error_local_subprocess_name
|
100
|
+
|
101
|
+
@engine.variables['trigger_alarm'] = Ruote.define do
|
102
|
+
echo '${colour} seen'
|
103
|
+
end
|
104
|
+
@engine.on_error = 'trigger_alarm'
|
105
|
+
|
106
|
+
pdef = Ruote.define do
|
107
|
+
error 'still wrong'
|
108
|
+
define 'trigger_alarm' do
|
109
|
+
echo 'saw ${colour}'
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
wfid = @engine.launch(pdef, 'colour' => 'green')
|
114
|
+
|
115
|
+
@engine.wait_for(wfid)
|
116
|
+
|
117
|
+
sleep 0.700
|
118
|
+
# letting the subprocess getting triggered
|
119
|
+
|
120
|
+
assert_equal 'saw green', @tracer.to_s
|
121
|
+
assert_equal 1, @engine.processes.size
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_on_error_subprocess_tree
|
125
|
+
|
126
|
+
@engine.on_error = Ruote.define do
|
127
|
+
echo 'case ${colour}'
|
128
|
+
end
|
129
|
+
|
130
|
+
wfid = @engine.launch(WRONGY, 'colour' => 'blue')
|
131
|
+
|
132
|
+
@engine.wait_for(wfid)
|
133
|
+
|
134
|
+
sleep 0.700
|
135
|
+
# letting the subprocess getting triggered
|
136
|
+
|
137
|
+
assert_equal 'case blue', @tracer.to_s
|
138
|
+
assert_equal 1, @engine.processes.size
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_on_error_workitem
|
142
|
+
|
143
|
+
@engine.register 'supervisor', Supervisor
|
144
|
+
@engine.on_error = 'supervisor'
|
145
|
+
|
146
|
+
#@engine.noisy = true
|
147
|
+
|
148
|
+
wfid = @engine.launch(WRONGY, 'colour' => 'crimson')
|
149
|
+
|
150
|
+
@engine.wait_for(wfid)
|
151
|
+
@engine.wait_for(:supervisor)
|
152
|
+
|
153
|
+
sleep 0.350
|
154
|
+
# unfortunately waiting for a participant triggers right
|
155
|
+
# before the consume
|
156
|
+
|
157
|
+
wi = @engine.context.stash[:seen].first
|
158
|
+
|
159
|
+
assert_not_nil wi.error
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_cascade_prevention
|
163
|
+
|
164
|
+
@engine.on_error = Ruote.define { error "nada" }
|
165
|
+
|
166
|
+
#@engine.noisy = true
|
167
|
+
|
168
|
+
wfid = @engine.launch(WRONGY, 'colour' => 'purple')
|
169
|
+
|
170
|
+
@engine.wait_for(wfid)
|
171
|
+
@engine.wait_for(wfid)
|
172
|
+
|
173
|
+
sleep 0.700
|
174
|
+
# give it a bit of time, to make sure no supplementary errors crop up
|
175
|
+
|
176
|
+
assert_equal 2, @engine.process(wfid).errors.size
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_doesnt_trigger_for_checked_error
|
180
|
+
|
181
|
+
pdef = Ruote.define do
|
182
|
+
nemo :on_error => 'pass'
|
183
|
+
end
|
184
|
+
|
185
|
+
@engine.on_error = Ruote.define do
|
186
|
+
echo 'seen'
|
187
|
+
end
|
188
|
+
|
189
|
+
wfid = @engine.launch(pdef)
|
190
|
+
|
191
|
+
#noisy
|
192
|
+
|
193
|
+
@engine.wait_for(wfid)
|
194
|
+
|
195
|
+
sleep 0.700
|
196
|
+
# give it a bit of time, to make sure no supplementary errors crop up
|
197
|
+
|
198
|
+
assert_equal '', @tracer.to_s
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
@@ -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 FtCancelTest < Test::Unit::TestCase
|
@@ -19,7 +19,7 @@ class FtCancelTest < Test::Unit::TestCase
|
|
19
19
|
alpha
|
20
20
|
end
|
21
21
|
|
22
|
-
alpha = @engine.register_participant :alpha, Ruote::
|
22
|
+
alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
|
23
23
|
|
24
24
|
#noisy
|
25
25
|
|
@@ -53,20 +53,80 @@ class FtCancelTest < Test::Unit::TestCase
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
|
57
|
-
|
56
|
+
@engine.register_participant :alpha, Ruote::StorageParticipant
|
57
|
+
sto = @engine.register_participant :bravo, Ruote::StorageParticipant
|
58
58
|
|
59
59
|
#noisy
|
60
60
|
|
61
61
|
wfid = @engine.launch(pdef)
|
62
62
|
wait_for(:alpha)
|
63
63
|
|
64
|
-
|
64
|
+
assert_equal 1, sto.size
|
65
|
+
|
66
|
+
wi = sto.first
|
65
67
|
|
66
68
|
@engine.cancel_expression(wi.fei)
|
67
69
|
wait_for(:bravo)
|
68
70
|
|
69
|
-
|
71
|
+
assert_equal 1, sto.size
|
72
|
+
assert_equal 'bravo', sto.first.participant_name
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_cancel__process
|
76
|
+
|
77
|
+
pdef = Ruote.process_definition do
|
78
|
+
alpha
|
79
|
+
end
|
80
|
+
|
81
|
+
@engine.register_participant :alpha, Ruote::NullParticipant
|
82
|
+
|
83
|
+
#noisy
|
84
|
+
|
85
|
+
wfid = @engine.launch(pdef)
|
86
|
+
|
87
|
+
@engine.wait_for(:alpha)
|
88
|
+
|
89
|
+
@engine.cancel(wfid)
|
90
|
+
|
91
|
+
@engine.wait_for(wfid)
|
92
|
+
|
93
|
+
assert_nil @engine.process(wfid)
|
94
|
+
|
95
|
+
assert_equal 1, logger.log.select { |e| e['action'] == 'cancel_process' }.size
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_cancel__expression
|
99
|
+
|
100
|
+
pdef = Ruote.process_definition do
|
101
|
+
alpha
|
102
|
+
echo '0'
|
103
|
+
alpha
|
104
|
+
echo '1'
|
105
|
+
alpha
|
106
|
+
echo '2'
|
107
|
+
end
|
108
|
+
|
109
|
+
@engine.register_participant :alpha, Ruote::NullParticipant
|
110
|
+
|
111
|
+
wfid = @engine.launch(pdef)
|
112
|
+
|
113
|
+
r = @engine.wait_for(:alpha)
|
114
|
+
|
115
|
+
@engine.cancel(r['fei']) # fei as a Hash
|
116
|
+
|
117
|
+
r = @engine.wait_for(:alpha)
|
118
|
+
|
119
|
+
@engine.cancel(Ruote.sid(r['fei'])) # fei as a String
|
120
|
+
|
121
|
+
r = @engine.wait_for(:alpha)
|
122
|
+
|
123
|
+
@engine.cancel(Ruote::Workitem.new(r['workitem'])) # fei as workitem
|
124
|
+
|
125
|
+
@engine.wait_for(wfid)
|
126
|
+
|
127
|
+
assert_equal %w[ 0 1 2 ], @tracer.to_a
|
128
|
+
|
129
|
+
assert_equal 3, logger.log.select { |e| e['action'] == 'cancel' }.size
|
70
130
|
end
|
71
131
|
end
|
72
132
|
|