ruote-maestrodev 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +290 -0
- data/CREDITS.txt +99 -0
- data/LICENSE.txt +21 -0
- data/README.rdoc +88 -0
- data/Rakefile +108 -0
- data/TODO.txt +488 -0
- data/lib/ruote.rb +7 -0
- data/lib/ruote/context.rb +194 -0
- data/lib/ruote/engine.rb +1062 -0
- data/lib/ruote/engine/process_error.rb +122 -0
- data/lib/ruote/engine/process_status.rb +448 -0
- data/lib/ruote/exp/command.rb +87 -0
- data/lib/ruote/exp/commanded.rb +69 -0
- data/lib/ruote/exp/condition.rb +227 -0
- data/lib/ruote/exp/fe_add_branches.rb +138 -0
- data/lib/ruote/exp/fe_apply.rb +154 -0
- data/lib/ruote/exp/fe_cancel_process.rb +78 -0
- data/lib/ruote/exp/fe_command.rb +156 -0
- data/lib/ruote/exp/fe_concurrence.rb +321 -0
- data/lib/ruote/exp/fe_concurrent_iterator.rb +219 -0
- data/lib/ruote/exp/fe_cron.rb +141 -0
- data/lib/ruote/exp/fe_cursor.rb +324 -0
- data/lib/ruote/exp/fe_define.rb +112 -0
- data/lib/ruote/exp/fe_echo.rb +60 -0
- data/lib/ruote/exp/fe_equals.rb +115 -0
- data/lib/ruote/exp/fe_error.rb +82 -0
- data/lib/ruote/exp/fe_filter.rb +648 -0
- data/lib/ruote/exp/fe_forget.rb +88 -0
- data/lib/ruote/exp/fe_given.rb +154 -0
- data/lib/ruote/exp/fe_if.rb +127 -0
- data/lib/ruote/exp/fe_inc.rb +205 -0
- data/lib/ruote/exp/fe_iterator.rb +234 -0
- data/lib/ruote/exp/fe_let.rb +75 -0
- data/lib/ruote/exp/fe_listen.rb +304 -0
- data/lib/ruote/exp/fe_lose.rb +110 -0
- data/lib/ruote/exp/fe_noop.rb +45 -0
- data/lib/ruote/exp/fe_once.rb +215 -0
- data/lib/ruote/exp/fe_participant.rb +287 -0
- data/lib/ruote/exp/fe_read.rb +69 -0
- data/lib/ruote/exp/fe_redo.rb +82 -0
- data/lib/ruote/exp/fe_ref.rb +152 -0
- data/lib/ruote/exp/fe_registerp.rb +110 -0
- data/lib/ruote/exp/fe_reserve.rb +126 -0
- data/lib/ruote/exp/fe_restore.rb +102 -0
- data/lib/ruote/exp/fe_save.rb +72 -0
- data/lib/ruote/exp/fe_sequence.rb +59 -0
- data/lib/ruote/exp/fe_set.rb +154 -0
- data/lib/ruote/exp/fe_subprocess.rb +211 -0
- data/lib/ruote/exp/fe_that.rb +92 -0
- data/lib/ruote/exp/fe_undo.rb +67 -0
- data/lib/ruote/exp/fe_unregisterp.rb +69 -0
- data/lib/ruote/exp/fe_wait.rb +95 -0
- data/lib/ruote/exp/flowexpression.rb +886 -0
- data/lib/ruote/exp/iterator.rb +81 -0
- data/lib/ruote/exp/merge.rb +118 -0
- data/lib/ruote/exp/ro_attributes.rb +212 -0
- data/lib/ruote/exp/ro_filters.rb +136 -0
- data/lib/ruote/exp/ro_persist.rb +154 -0
- data/lib/ruote/exp/ro_variables.rb +189 -0
- data/lib/ruote/exp/ro_vf.rb +68 -0
- data/lib/ruote/fei.rb +260 -0
- data/lib/ruote/id/mnemo_wfid_generator.rb +43 -0
- data/lib/ruote/id/wfid_generator.rb +81 -0
- data/lib/ruote/log/default_history.rb +122 -0
- data/lib/ruote/log/pretty.rb +176 -0
- data/lib/ruote/log/storage_history.rb +159 -0
- data/lib/ruote/log/test_logger.rb +208 -0
- data/lib/ruote/log/wait_logger.rb +64 -0
- data/lib/ruote/part/block_participant.rb +137 -0
- data/lib/ruote/part/code_participant.rb +81 -0
- data/lib/ruote/part/engine_participant.rb +189 -0
- data/lib/ruote/part/local_participant.rb +138 -0
- data/lib/ruote/part/no_op_participant.rb +60 -0
- data/lib/ruote/part/null_participant.rb +54 -0
- data/lib/ruote/part/rev_participant.rb +169 -0
- data/lib/ruote/part/smtp_participant.rb +116 -0
- data/lib/ruote/part/storage_participant.rb +392 -0
- data/lib/ruote/part/template.rb +84 -0
- data/lib/ruote/participant.rb +7 -0
- data/lib/ruote/reader.rb +278 -0
- data/lib/ruote/reader/json.rb +49 -0
- data/lib/ruote/reader/radial.rb +290 -0
- data/lib/ruote/reader/ruby_dsl.rb +186 -0
- data/lib/ruote/reader/xml.rb +99 -0
- data/lib/ruote/receiver/base.rb +212 -0
- data/lib/ruote/storage/base.rb +364 -0
- data/lib/ruote/storage/composite_storage.rb +121 -0
- data/lib/ruote/storage/fs_storage.rb +139 -0
- data/lib/ruote/storage/hash_storage.rb +211 -0
- data/lib/ruote/svc/dispatch_pool.rb +158 -0
- data/lib/ruote/svc/dollar_sub.rb +298 -0
- data/lib/ruote/svc/error_handler.rb +138 -0
- data/lib/ruote/svc/expression_map.rb +97 -0
- data/lib/ruote/svc/participant_list.rb +397 -0
- data/lib/ruote/svc/tracker.rb +172 -0
- data/lib/ruote/svc/treechecker.rb +141 -0
- data/lib/ruote/tree_dot.rb +85 -0
- data/lib/ruote/util/filter.rb +525 -0
- data/lib/ruote/util/hashdot.rb +79 -0
- data/lib/ruote/util/look.rb +128 -0
- data/lib/ruote/util/lookup.rb +127 -0
- data/lib/ruote/util/misc.rb +167 -0
- data/lib/ruote/util/ometa.rb +71 -0
- data/lib/ruote/util/serializer.rb +103 -0
- data/lib/ruote/util/subprocess.rb +88 -0
- data/lib/ruote/util/time.rb +100 -0
- data/lib/ruote/util/tree.rb +58 -0
- data/lib/ruote/version.rb +29 -0
- data/lib/ruote/worker.rb +386 -0
- data/lib/ruote/workitem.rb +394 -0
- data/phil.txt +14 -0
- data/ruote.gemspec +44 -0
- data/test/bm/ci.rb +55 -0
- data/test/bm/ici.rb +71 -0
- data/test/bm/juuman.rb +54 -0
- data/test/bm/launch_bench.rb +37 -0
- data/test/bm/load_26c.rb +97 -0
- data/test/bm/mega.rb +64 -0
- data/test/bm/seq_thousand.rb +31 -0
- data/test/bm/t.rb +35 -0
- data/test/functional/base.rb +247 -0
- data/test/functional/concurrent_base.rb +98 -0
- data/test/functional/crunner.rb +31 -0
- data/test/functional/ct_0_concurrence.rb +65 -0
- data/test/functional/ct_1_iterator.rb +67 -0
- data/test/functional/ct_2_cancel.rb +81 -0
- data/test/functional/eft_0_process_definition.rb +65 -0
- data/test/functional/eft_10_cancel_process.rb +46 -0
- data/test/functional/eft_11_wait.rb +109 -0
- data/test/functional/eft_12_listen.rb +500 -0
- data/test/functional/eft_13_iterator.rb +342 -0
- data/test/functional/eft_14_cursor.rb +456 -0
- data/test/functional/eft_15_loop.rb +69 -0
- data/test/functional/eft_16_if.rb +183 -0
- data/test/functional/eft_17_equals.rb +55 -0
- data/test/functional/eft_18_concurrent_iterator.rb +410 -0
- data/test/functional/eft_19_reserve.rb +136 -0
- data/test/functional/eft_1_echo.rb +68 -0
- data/test/functional/eft_20_save.rb +116 -0
- data/test/functional/eft_21_restore.rb +61 -0
- data/test/functional/eft_22_noop.rb +28 -0
- data/test/functional/eft_23_apply.rb +168 -0
- data/test/functional/eft_24_add_branches.rb +98 -0
- data/test/functional/eft_25_command.rb +28 -0
- data/test/functional/eft_26_error.rb +77 -0
- data/test/functional/eft_27_inc.rb +280 -0
- data/test/functional/eft_28_once.rb +135 -0
- data/test/functional/eft_29_cron.rb +64 -0
- data/test/functional/eft_2_sequence.rb +58 -0
- data/test/functional/eft_30_ref.rb +155 -0
- 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 +375 -0
- data/test/functional/eft_36_read.rb +95 -0
- data/test/functional/eft_3_participant.rb +149 -0
- data/test/functional/eft_4_set.rb +296 -0
- data/test/functional/eft_5_subprocess.rb +163 -0
- data/test/functional/eft_6_concurrence.rb +304 -0
- data/test/functional/eft_7_forget.rb +61 -0
- data/test/functional/eft_8_undo.rb +114 -0
- data/test/functional/eft_9_redo.rb +138 -0
- data/test/functional/ft_0_worker.rb +65 -0
- data/test/functional/ft_10_dollar.rb +304 -0
- data/test/functional/ft_11_recursion.rb +109 -0
- data/test/functional/ft_12_launchitem.rb +43 -0
- data/test/functional/ft_13_variables.rb +151 -0
- data/test/functional/ft_14_re_apply.rb +324 -0
- data/test/functional/ft_15_timeout.rb +226 -0
- data/test/functional/ft_16_participant_params.rb +98 -0
- data/test/functional/ft_17_conditional.rb +102 -0
- data/test/functional/ft_18_kill.rb +138 -0
- data/test/functional/ft_19_participant_code.rb +67 -0
- data/test/functional/ft_1_process_status.rb +796 -0
- data/test/functional/ft_20_storage_participant.rb +543 -0
- data/test/functional/ft_21_forget.rb +153 -0
- data/test/functional/ft_22_process_definitions.rb +90 -0
- data/test/functional/ft_23_load_defs.rb +79 -0
- data/test/functional/ft_24_block_participant.rb +235 -0
- data/test/functional/ft_25_receiver.rb +207 -0
- data/test/functional/ft_26_participant_rtimeout.rb +179 -0
- data/test/functional/ft_27_var_indirection.rb +128 -0
- data/test/functional/ft_28_null_noop_participants.rb +51 -0
- data/test/functional/ft_29_part_template.rb +60 -0
- data/test/functional/ft_2_errors.rb +380 -0
- data/test/functional/ft_30_smtp_participant.rb +122 -0
- data/test/functional/ft_31_part_blocking.rb +72 -0
- data/test/functional/ft_33_participant_subprocess_priority.rb +32 -0
- data/test/functional/ft_34_cursor_rewind.rb +101 -0
- data/test/functional/ft_35_add_service.rb +56 -0
- data/test/functional/ft_36_storage_history.rb +150 -0
- data/test/functional/ft_37_default_history.rb +109 -0
- data/test/functional/ft_38_participant_more.rb +193 -0
- data/test/functional/ft_39_wait_for.rb +136 -0
- data/test/functional/ft_3_participant_registration.rb +574 -0
- data/test/functional/ft_40_wait_logger.rb +62 -0
- data/test/functional/ft_41_participants.rb +91 -0
- data/test/functional/ft_42_storage_copy.rb +71 -0
- data/test/functional/ft_43_participant_on_reply.rb +87 -0
- data/test/functional/ft_44_var_participant.rb +35 -0
- data/test/functional/ft_45_participant_accept.rb +64 -0
- data/test/functional/ft_46_launch_single.rb +83 -0
- 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 +132 -0
- 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_55_engine_participant.rb +303 -0
- data/test/functional/ft_56_filter_attribute.rb +259 -0
- data/test/functional/ft_57_rev_participant.rb +252 -0
- data/test/functional/ft_58_workitem.rb +69 -0
- data/test/functional/ft_59_pause.rb +343 -0
- data/test/functional/ft_5_on_error.rb +384 -0
- data/test/functional/ft_60_code_participant.rb +45 -0
- data/test/functional/ft_61_trailing_fields.rb +34 -0
- data/test/functional/ft_62_exp_name_and_dollar_substitution.rb +35 -0
- data/test/functional/ft_6_on_cancel.rb +221 -0
- data/test/functional/ft_7_tags.rb +177 -0
- data/test/functional/ft_8_participant_consumption.rb +124 -0
- data/test/functional/ft_9_subprocesses.rb +146 -0
- data/test/functional/restart_base.rb +34 -0
- data/test/functional/rt_0_wait.rb +55 -0
- data/test/functional/rt_1_listen.rb +56 -0
- data/test/functional/rt_2_errors.rb +56 -0
- data/test/functional/rt_3_once.rb +70 -0
- data/test/functional/rt_4_cron.rb +64 -0
- data/test/functional/rt_5_timeout.rb +60 -0
- data/test/functional/rtest.rb +8 -0
- data/test/functional/storage_helper.rb +93 -0
- data/test/functional/test.rb +44 -0
- data/test/functional/vertical.rb +46 -0
- data/test/path_helper.rb +15 -0
- data/test/test.rb +13 -0
- data/test/test_helper.rb +28 -0
- data/test/unit/storage.rb +428 -0
- data/test/unit/storages.rb +37 -0
- data/test/unit/test.rb +28 -0
- data/test/unit/ut_0_ruby_reader.rb +223 -0
- data/test/unit/ut_11_lookup.rb +122 -0
- data/test/unit/ut_13_serializer.rb +65 -0
- data/test/unit/ut_14_is_uri.rb +28 -0
- data/test/unit/ut_15_util.rb +57 -0
- data/test/unit/ut_16_reader.rb +225 -0
- data/test/unit/ut_18_engine.rb +47 -0
- data/test/unit/ut_19_part_template.rb +86 -0
- data/test/unit/ut_1_fei.rb +165 -0
- data/test/unit/ut_20_composite_storage.rb +74 -0
- data/test/unit/ut_21_svc_participant_list.rb +46 -0
- data/test/unit/ut_22_filter.rb +1094 -0
- data/test/unit/ut_23_svc_tracker.rb +48 -0
- data/test/unit/ut_24_radial_reader.rb +332 -0
- data/test/unit/ut_25_merge.rb +113 -0
- data/test/unit/ut_3_wait_logger.rb +39 -0
- data/test/unit/ut_4_expmap.rb +20 -0
- data/test/unit/ut_5_tree.rb +54 -0
- data/test/unit/ut_6_condition.rb +303 -0
- data/test/unit/ut_7_workitem.rb +99 -0
- data/test/unit/ut_8_tree_to_dot.rb +72 -0
- data/test/unit/ut_9_xml_reader.rb +61 -0
- metadata +504 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Mon Dec 6 10:40:29 JST 2010
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
|
11
|
+
class FtEngineConfigTest < Test::Unit::TestCase
|
12
|
+
include FunctionalBase
|
13
|
+
|
14
|
+
def test_engine_config
|
15
|
+
|
16
|
+
@engine.configure('a', 'b')
|
17
|
+
|
18
|
+
assert_equal 'b', @engine.configuration('a')
|
19
|
+
assert_equal 'b', @engine.storage.get_configuration('engine')['a']
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,67 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Thu Dec 9 16:39:54 JST 2010
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'stringio'
|
9
|
+
require File.join(File.dirname(__FILE__), 'base')
|
10
|
+
|
11
|
+
|
12
|
+
class FtMiscTest < Test::Unit::TestCase
|
13
|
+
include FunctionalBase
|
14
|
+
|
15
|
+
def test_noisy
|
16
|
+
|
17
|
+
result = String.new
|
18
|
+
out = StringIO.new(result, 'w+')
|
19
|
+
|
20
|
+
prev = $stdout
|
21
|
+
$stdout = out
|
22
|
+
|
23
|
+
@engine.noisy = true
|
24
|
+
|
25
|
+
wfid = @engine.launch(Ruote.define do
|
26
|
+
echo 'nada'
|
27
|
+
end)
|
28
|
+
|
29
|
+
@engine.wait_for(wfid)
|
30
|
+
|
31
|
+
out.close
|
32
|
+
$stdout = prev
|
33
|
+
|
34
|
+
assert_not_nil result
|
35
|
+
end
|
36
|
+
|
37
|
+
class NoCancel
|
38
|
+
def consume(workitem)
|
39
|
+
# do nothing
|
40
|
+
end
|
41
|
+
# no cancel method implementation
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_participant_missing_cancel_method
|
45
|
+
|
46
|
+
pdef = Ruote.define do
|
47
|
+
participant 'no_cancel'
|
48
|
+
end
|
49
|
+
|
50
|
+
@engine.register 'no_cancel', NoCancel
|
51
|
+
|
52
|
+
#noisy
|
53
|
+
|
54
|
+
wfid = @engine.launch(pdef)
|
55
|
+
|
56
|
+
@engine.wait_for(:no_cancel)
|
57
|
+
|
58
|
+
@engine.cancel(wfid)
|
59
|
+
|
60
|
+
@engine.wait_for(wfid)
|
61
|
+
|
62
|
+
assert_match(
|
63
|
+
/undefined method `cancel' for/,
|
64
|
+
@engine.ps(wfid).errors.first.message)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
@@ -0,0 +1,134 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Fri Dec 24 14:53:30 JST 2010
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
|
11
|
+
#
|
12
|
+
# Tests about replacement for case x when 'y' and switch(x) constructs.
|
13
|
+
#
|
14
|
+
class FtCaseTest < Test::Unit::TestCase
|
15
|
+
include FunctionalBase
|
16
|
+
|
17
|
+
# The alternatives are bound at the process level
|
18
|
+
#
|
19
|
+
def test_open_lambda
|
20
|
+
|
21
|
+
pdef = Ruote.define do
|
22
|
+
|
23
|
+
define 'a' do
|
24
|
+
set 'f:result' => 'a'
|
25
|
+
end
|
26
|
+
define 'b' do
|
27
|
+
set 'f:result' => 'b'
|
28
|
+
end
|
29
|
+
|
30
|
+
subprocess '${the_case}'
|
31
|
+
end
|
32
|
+
|
33
|
+
wfid = @engine.launch(pdef, 'the_case' => 'a')
|
34
|
+
r = @engine.wait_for(wfid)
|
35
|
+
assert_equal 'a', r['workitem']['fields']['result']
|
36
|
+
|
37
|
+
wfid = @engine.launch(pdef, 'the_case' => 'b')
|
38
|
+
r = @engine.wait_for(wfid)
|
39
|
+
assert_equal 'b', r['workitem']['fields']['result']
|
40
|
+
end
|
41
|
+
|
42
|
+
# The alternatives are bound inside of the case subprocess (definition)
|
43
|
+
#
|
44
|
+
def test_nested_lambda
|
45
|
+
|
46
|
+
pdef = Ruote.define do
|
47
|
+
|
48
|
+
define 'case' do
|
49
|
+
define 'a' do
|
50
|
+
set 'f:result' => 'a'
|
51
|
+
end
|
52
|
+
define 'b' do
|
53
|
+
set 'f:result' => 'b'
|
54
|
+
end
|
55
|
+
subprocess '${the_case}'
|
56
|
+
end
|
57
|
+
|
58
|
+
subprocess 'case'
|
59
|
+
end
|
60
|
+
|
61
|
+
wfid = @engine.launch(pdef, 'the_case' => 'a')
|
62
|
+
r = @engine.wait_for(wfid)
|
63
|
+
assert_equal 'a', r['workitem']['fields']['result']
|
64
|
+
|
65
|
+
wfid = @engine.launch(pdef, 'the_case' => 'b')
|
66
|
+
r = @engine.wait_for(wfid)
|
67
|
+
assert_equal 'b', r['workitem']['fields']['result']
|
68
|
+
end
|
69
|
+
|
70
|
+
# /!\
|
71
|
+
#
|
72
|
+
# Works as well, but the cases are bound in the global/process scope
|
73
|
+
#
|
74
|
+
def test_local_lambda
|
75
|
+
|
76
|
+
pdef = Ruote.define do
|
77
|
+
|
78
|
+
sequence do
|
79
|
+
define 'a' do
|
80
|
+
set 'f:result' => 'a'
|
81
|
+
end
|
82
|
+
define 'b' do
|
83
|
+
set 'f:result' => 'b'
|
84
|
+
end
|
85
|
+
subprocess '${the_case}'
|
86
|
+
end
|
87
|
+
|
88
|
+
subprocess 'a' # /!\
|
89
|
+
end
|
90
|
+
|
91
|
+
wfid = @engine.launch(pdef, 'the_case' => 'a')
|
92
|
+
r = @engine.wait_for(wfid)
|
93
|
+
assert_equal 'a', r['workitem']['fields']['result']
|
94
|
+
|
95
|
+
wfid = @engine.launch(pdef, 'the_case' => 'b')
|
96
|
+
r = @engine.wait_for(wfid)
|
97
|
+
assert_equal 'a', r['workitem']['fields']['result']
|
98
|
+
end
|
99
|
+
|
100
|
+
# Works as well, but the cases are bound in the global/process scope
|
101
|
+
#
|
102
|
+
def test_let_lambda
|
103
|
+
|
104
|
+
pdef = Ruote.define do
|
105
|
+
|
106
|
+
define 'a' do
|
107
|
+
echo 'global_a'
|
108
|
+
end
|
109
|
+
|
110
|
+
let do
|
111
|
+
define 'a' do
|
112
|
+
echo 'a'
|
113
|
+
end
|
114
|
+
define 'b' do
|
115
|
+
echo 'b'
|
116
|
+
end
|
117
|
+
subprocess '${the_case}'
|
118
|
+
end
|
119
|
+
|
120
|
+
subprocess 'a'
|
121
|
+
end
|
122
|
+
|
123
|
+
wfid = @engine.launch(pdef, 'the_case' => 'a')
|
124
|
+
@engine.wait_for(wfid)
|
125
|
+
assert_equal %w[ a global_a ], @tracer.to_a
|
126
|
+
|
127
|
+
@tracer.clear
|
128
|
+
|
129
|
+
wfid = @engine.launch(pdef, 'the_case' => 'b')
|
130
|
+
@engine.wait_for(wfid)
|
131
|
+
assert_equal %w[ b global_a ], @tracer.to_a
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Thu Jan 6 21:49:01 JST 2011
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
#require 'ruote/participant'
|
11
|
+
|
12
|
+
|
13
|
+
class FtEngineOnTerminateTest < Test::Unit::TestCase
|
14
|
+
include FunctionalBase
|
15
|
+
|
16
|
+
def test_no_on_terminate
|
17
|
+
|
18
|
+
assert_nil @engine.on_terminate
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_on_terminate
|
22
|
+
|
23
|
+
@engine.on_terminate = 'supervisor'
|
24
|
+
|
25
|
+
assert_equal(
|
26
|
+
[ 'define', {}, [ [ 'supervisor', {}, [] ] ] ],
|
27
|
+
@engine.on_terminate)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_on_terminate_tree
|
31
|
+
|
32
|
+
@engine.on_terminate = Ruote.define do
|
33
|
+
echo '${__terminate__.wfid} terminated'
|
34
|
+
end
|
35
|
+
|
36
|
+
#@engine.noisy = true
|
37
|
+
|
38
|
+
wfid = @engine.launch(Ruote.define do
|
39
|
+
echo 'main'
|
40
|
+
end)
|
41
|
+
|
42
|
+
@engine.wait_for(wfid)
|
43
|
+
sleep 1
|
44
|
+
|
45
|
+
assert_equal [ 'main', "#{wfid} terminated" ], @tracer.to_a
|
46
|
+
end
|
47
|
+
|
48
|
+
# on_terminate processes are not triggered for on_error processes.
|
49
|
+
#
|
50
|
+
def test_no_on_terminate_when_on_error
|
51
|
+
|
52
|
+
@engine.on_error = Ruote.define do
|
53
|
+
echo 'on_error'
|
54
|
+
end
|
55
|
+
@engine.on_terminate = Ruote.define do
|
56
|
+
echo 'on_terminate'
|
57
|
+
end
|
58
|
+
|
59
|
+
#noisy
|
60
|
+
|
61
|
+
wfid = @engine.launch(Ruote.define do
|
62
|
+
echo 'main'
|
63
|
+
error 'in main'
|
64
|
+
end)
|
65
|
+
|
66
|
+
@engine.wait_for(wfid)
|
67
|
+
sleep 1
|
68
|
+
|
69
|
+
assert_equal [ 'main', 'on_error' ], @tracer.to_a
|
70
|
+
end
|
71
|
+
|
72
|
+
# on_error processes are triggered for on_terminate processes as well.
|
73
|
+
#
|
74
|
+
def test_on_error_when_on_terminate
|
75
|
+
|
76
|
+
@engine.on_error = Ruote.define do
|
77
|
+
echo 'on_error'
|
78
|
+
end
|
79
|
+
@engine.on_terminate = Ruote.define do
|
80
|
+
error 'in on_terminate'
|
81
|
+
end
|
82
|
+
|
83
|
+
#noisy
|
84
|
+
|
85
|
+
wfid = @engine.launch(Ruote.define do
|
86
|
+
echo 'main'
|
87
|
+
end)
|
88
|
+
|
89
|
+
@engine.wait_for(wfid)
|
90
|
+
sleep 1
|
91
|
+
|
92
|
+
assert_equal [ 'main', 'on_error' ], @tracer.to_a
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
@@ -0,0 +1,104 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Fri Jan 7 15:13:28 JST 2011
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
#require 'ruote/participant'
|
11
|
+
|
12
|
+
|
13
|
+
class FtPatternsTest < Test::Unit::TestCase
|
14
|
+
include FunctionalBase
|
15
|
+
|
16
|
+
|
17
|
+
# A task is only enabled when the process instance (of which it is part) is
|
18
|
+
# in a specific state (typically a parallel branch). The state is assumed to
|
19
|
+
# be a specific execution point (also known as a milestone) in the process
|
20
|
+
# model. When this execution point is reached the nominated task can be
|
21
|
+
# enabled. If the process instance has progressed beyond this state, then the
|
22
|
+
# task cannot be enabled now or at any future time (i.e. the deadline has
|
23
|
+
# expired). Note that the execution does not influence the state itself, i.e.
|
24
|
+
# unlike normal control-flow dependencies it is a test rather than a trigger.
|
25
|
+
|
26
|
+
#MILESTONE = Ruote.define do
|
27
|
+
#
|
28
|
+
# concurrence :count => 1 do
|
29
|
+
#
|
30
|
+
# sequence do
|
31
|
+
# participant 'a'
|
32
|
+
# participant 'b', :tag => 'milestone'
|
33
|
+
# participant 'c'
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# listen :to => 'milestone', :upon => 'entering', :wfid => true do
|
37
|
+
# concurrence :count => 1 do
|
38
|
+
# listen :to => 'milestone', :upon => 'leaving', :wfid => true
|
39
|
+
# participant 'd'
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
# end
|
43
|
+
#end
|
44
|
+
# this works, but, if the participant d implementation is 'fast', the
|
45
|
+
# milestone could be left before the inner listen is reached.
|
46
|
+
# This listen could thus listen for an event that already occurred and
|
47
|
+
# thus be locked...
|
48
|
+
#
|
49
|
+
# the revised version makes sure the milestone is listened to (bot#
|
50
|
+
# entering and leaving) before participant b is reached.
|
51
|
+
|
52
|
+
MILESTONE = Ruote.define do
|
53
|
+
|
54
|
+
concurrence do
|
55
|
+
|
56
|
+
sequence do
|
57
|
+
participant 'a'
|
58
|
+
participant 'b', :tag => 'milestone'
|
59
|
+
participant 'c'
|
60
|
+
end
|
61
|
+
|
62
|
+
concurrence :count => 1 do
|
63
|
+
sequence do
|
64
|
+
listen :to => 'milestone', :upon => 'entering', :wfid => true
|
65
|
+
participant 'd'
|
66
|
+
end
|
67
|
+
listen :to => 'milestone', :upon => 'leaving', :wfid => true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_18_milestone
|
73
|
+
|
74
|
+
@engine.register do
|
75
|
+
catchall Ruote::StorageParticipant
|
76
|
+
end
|
77
|
+
|
78
|
+
#@engine.noisy = true
|
79
|
+
|
80
|
+
wfid = @engine.launch(MILESTONE)
|
81
|
+
|
82
|
+
@engine.wait_for(:a)
|
83
|
+
|
84
|
+
assert_equal({}, @engine.ps(wfid).tags)
|
85
|
+
|
86
|
+
@engine.storage_participant.proceed(@engine.storage_participant.first)
|
87
|
+
|
88
|
+
@engine.wait_for(:d)
|
89
|
+
|
90
|
+
assert_equal %w[ milestone ], @engine.ps(wfid).tags.collect { |t| t.first }
|
91
|
+
assert_equal %w[ b d ], @engine.ps(wfid).position.collect { |pos| pos[1] }
|
92
|
+
|
93
|
+
wi = @engine.storage_participant.by_participant('b').first
|
94
|
+
@engine.storage_participant.proceed(wi)
|
95
|
+
|
96
|
+
@engine.wait_for(:c)
|
97
|
+
|
98
|
+
sleep 0.7 # give some time for the task d to get removed
|
99
|
+
|
100
|
+
assert_equal({}, @engine.ps(wfid).tags)
|
101
|
+
assert_equal %w[ c ], @engine.ps(wfid).position.collect { |pos| pos[1] }
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
@@ -0,0 +1,303 @@
|
|
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_json
|
13
|
+
Rufus::Json.detect_backend
|
14
|
+
require 'ruote'
|
15
|
+
require 'ruote/storage/fs_storage'
|
16
|
+
require 'ruote/participant'
|
17
|
+
|
18
|
+
|
19
|
+
class FtEngineParticipantTest < Test::Unit::TestCase
|
20
|
+
#include FunctionalBase
|
21
|
+
|
22
|
+
def setup
|
23
|
+
|
24
|
+
@dir0 = "work_0_#{$$}_#{self.object_id}_#{Time.now.to_f}"
|
25
|
+
@dir1 = "work_1_#{$$}_#{self.object_id}_#{Time.now.to_f}"
|
26
|
+
|
27
|
+
@engine0 =
|
28
|
+
Ruote::Engine.new(
|
29
|
+
Ruote::Worker.new(
|
30
|
+
Ruote::FsStorage.new(
|
31
|
+
@dir0,
|
32
|
+
'engine_id' => 'engine0',
|
33
|
+
's_logger' => [ 'ruote/log/test_logger', 'Ruote::TestLogger' ])))
|
34
|
+
@engine1 =
|
35
|
+
Ruote::Engine.new(
|
36
|
+
Ruote::Worker.new(
|
37
|
+
Ruote::FsStorage.new(
|
38
|
+
@dir1,
|
39
|
+
'engine_id' => 'engine1',
|
40
|
+
's_logger' => [ 'ruote/log/test_logger', 'Ruote::TestLogger' ])))
|
41
|
+
|
42
|
+
@tracer0 = Tracer.new
|
43
|
+
@engine0.add_service('tracer', @tracer0)
|
44
|
+
|
45
|
+
@tracer1 = Tracer.new
|
46
|
+
@engine1.add_service('tracer', @tracer1)
|
47
|
+
|
48
|
+
@engine0.register_participant(
|
49
|
+
'engine1',
|
50
|
+
Ruote::EngineParticipant,
|
51
|
+
'storage_class' => Ruote::FsStorage,
|
52
|
+
'storage_path' => 'ruote/storage/fs_storage',
|
53
|
+
'storage_args' => @dir1)
|
54
|
+
@engine1.register_participant(
|
55
|
+
'engine0',
|
56
|
+
Ruote::EngineParticipant,
|
57
|
+
'storage_class' => Ruote::FsStorage,
|
58
|
+
'storage_path' => 'ruote/storage/fs_storage',
|
59
|
+
'storage_args' => @dir0)
|
60
|
+
end
|
61
|
+
|
62
|
+
def teardown
|
63
|
+
|
64
|
+
@engine0.shutdown
|
65
|
+
@engine1.shutdown
|
66
|
+
|
67
|
+
ensure
|
68
|
+
FileUtils.rm_rf(@dir0)
|
69
|
+
FileUtils.rm_rf(@dir1)
|
70
|
+
end
|
71
|
+
|
72
|
+
def noisy
|
73
|
+
|
74
|
+
@engine0.context.logger.noisy = true
|
75
|
+
@engine1.context.logger.noisy = true
|
76
|
+
@engine1.context.logger.color = '32' # green
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_as_participant
|
80
|
+
|
81
|
+
pdef = Ruote.process_definition do
|
82
|
+
sequence do
|
83
|
+
echo 'a'
|
84
|
+
participant :ref => 'engine1', :pdef => 'subp'
|
85
|
+
echo 'c'
|
86
|
+
end
|
87
|
+
define 'subp' do
|
88
|
+
echo 'b'
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
#noisy
|
93
|
+
|
94
|
+
wfid = @engine0.launch(pdef)
|
95
|
+
@engine0.wait_for(wfid)
|
96
|
+
|
97
|
+
assert_equal "a\nc", @tracer0.to_s
|
98
|
+
assert_equal "b", @tracer1.to_s
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_as_subprocess
|
102
|
+
|
103
|
+
pdef = Ruote.process_definition do
|
104
|
+
sequence do
|
105
|
+
echo 'a'
|
106
|
+
subprocess 'subp', :engine => 'engine1'
|
107
|
+
echo 'c'
|
108
|
+
end
|
109
|
+
define 'subp' do
|
110
|
+
echo 'b'
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
#noisy
|
115
|
+
|
116
|
+
wfid = @engine0.launch(pdef)
|
117
|
+
@engine0.wait_for(wfid)
|
118
|
+
|
119
|
+
assert_equal "a\nc", @tracer0.to_s
|
120
|
+
assert_equal "b", @tracer1.to_s
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_as_subprocess_2
|
124
|
+
|
125
|
+
pdef = Ruote.process_definition do
|
126
|
+
sequence do
|
127
|
+
echo 'a'
|
128
|
+
subp :engine => 'engine1'
|
129
|
+
echo 'c'
|
130
|
+
end
|
131
|
+
define 'subp' do
|
132
|
+
echo 'b'
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
#noisy
|
137
|
+
|
138
|
+
wfid = @engine0.launch(pdef)
|
139
|
+
@engine0.wait_for(wfid)
|
140
|
+
|
141
|
+
assert_equal "a\nc", @tracer0.to_s
|
142
|
+
assert_equal "b", @tracer1.to_s
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_cancel_process
|
146
|
+
|
147
|
+
pdef = Ruote.process_definition do
|
148
|
+
sequence do
|
149
|
+
echo 'a'
|
150
|
+
subp :engine => 'engine1'
|
151
|
+
echo 'c'
|
152
|
+
end
|
153
|
+
define 'subp' do
|
154
|
+
alpha
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
#noisy
|
159
|
+
|
160
|
+
alpha = @engine1.register_participant :alpha, Ruote::StorageParticipant
|
161
|
+
|
162
|
+
wfid = @engine0.launch(pdef)
|
163
|
+
|
164
|
+
@engine1.wait_for(:alpha)
|
165
|
+
|
166
|
+
assert_equal 1, alpha.size
|
167
|
+
assert_not_nil alpha.first.fei.subid
|
168
|
+
|
169
|
+
@engine0.cancel_process(wfid)
|
170
|
+
@engine0.wait_for(wfid)
|
171
|
+
|
172
|
+
#@engine0.wait_for(1) # since dispatch_cancel is asynchronous now
|
173
|
+
sleep 0.777 # but well sometimes the dispatch is too fast
|
174
|
+
|
175
|
+
assert_equal 0, alpha.size
|
176
|
+
|
177
|
+
assert_equal 'a', @tracer0.to_s
|
178
|
+
assert_equal '', @tracer1.to_s
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_with_variables
|
182
|
+
|
183
|
+
pdef = Ruote.process_definition do
|
184
|
+
sequence do
|
185
|
+
set 'v:v0' => 'b'
|
186
|
+
echo 'a'
|
187
|
+
subp :engine => 'engine1'
|
188
|
+
echo 'c'
|
189
|
+
end
|
190
|
+
define 'subp' do
|
191
|
+
echo '${r:engine_id}:${v:v0}'
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
@engine1.context['ruby_eval_allowed'] = true
|
196
|
+
# just for ${r:engine_id}
|
197
|
+
|
198
|
+
#noisy
|
199
|
+
|
200
|
+
wfid = @engine0.launch(pdef)
|
201
|
+
@engine0.wait_for(wfid)
|
202
|
+
|
203
|
+
assert_equal "a\nc", @tracer0.to_s
|
204
|
+
assert_equal "engine1:b", @tracer1.to_s
|
205
|
+
|
206
|
+
assert_nil @engine0.process(wfid)
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_with_uri
|
210
|
+
|
211
|
+
path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'pdef.xml'))
|
212
|
+
|
213
|
+
pdef = Ruote.process_definition do
|
214
|
+
participant :ref => 'engine1', :pdef => path
|
215
|
+
end
|
216
|
+
|
217
|
+
#noisy
|
218
|
+
|
219
|
+
wfid = @engine0.launch(pdef)
|
220
|
+
@engine0.wait_for(wfid)
|
221
|
+
|
222
|
+
assert_equal "", @tracer0.to_s
|
223
|
+
assert_equal "a\nb", @tracer1.to_s
|
224
|
+
|
225
|
+
assert_nil @engine0.process(wfid)
|
226
|
+
end
|
227
|
+
|
228
|
+
def test_forget
|
229
|
+
|
230
|
+
pdef = Ruote.process_definition do
|
231
|
+
sequence do
|
232
|
+
echo 'a'
|
233
|
+
participant :ref => 'engine1', :pdef => 'subp', :forget => true
|
234
|
+
echo 'c'
|
235
|
+
end
|
236
|
+
define 'subp' do
|
237
|
+
bravo
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
bravo = @engine1.register_participant :bravo, Ruote::StorageParticipant
|
242
|
+
|
243
|
+
#noisy
|
244
|
+
|
245
|
+
wfid = @engine0.launch(pdef)
|
246
|
+
@engine0.wait_for(wfid) # terminated
|
247
|
+
|
248
|
+
assert_equal [], @engine0.processes
|
249
|
+
|
250
|
+
@engine1.wait_for(:bravo)
|
251
|
+
|
252
|
+
bravo.proceed(bravo.first)
|
253
|
+
|
254
|
+
@engine1.wait_for(wfid) # ceased
|
255
|
+
|
256
|
+
assert_equal [], @engine0.processes
|
257
|
+
assert_equal [], @engine1.processes
|
258
|
+
end
|
259
|
+
|
260
|
+
def test_replay_gone_engine_participant
|
261
|
+
|
262
|
+
@engine1.unregister_participant('engine0')
|
263
|
+
|
264
|
+
pdef = Ruote.process_definition do
|
265
|
+
sequence do
|
266
|
+
echo 'a'
|
267
|
+
participant :ref => 'engine1', :pdef => 'subp'
|
268
|
+
echo 'c'
|
269
|
+
end
|
270
|
+
define 'subp' do
|
271
|
+
echo 'b'
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
#noisy
|
276
|
+
|
277
|
+
wfid = @engine0.launch(pdef)
|
278
|
+
@engine1.wait_for(wfid) # error
|
279
|
+
|
280
|
+
errs = @engine1.process(wfid).errors
|
281
|
+
|
282
|
+
assert_equal 1, errs.size
|
283
|
+
|
284
|
+
# fix error cause
|
285
|
+
|
286
|
+
@engine1.register_participant(
|
287
|
+
'engine0',
|
288
|
+
Ruote::EngineParticipant,
|
289
|
+
'storage_class' => Ruote::FsStorage,
|
290
|
+
'storage_path' => 'ruote/storage/fs_storage',
|
291
|
+
'storage_args' => @dir0)
|
292
|
+
|
293
|
+
# replay
|
294
|
+
|
295
|
+
@engine1.replay_at_error(errs.first)
|
296
|
+
|
297
|
+
@engine0.wait_for(wfid)
|
298
|
+
|
299
|
+
assert_equal "a\nc", @tracer0.to_s
|
300
|
+
assert_equal "b", @tracer1.to_s
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|