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,226 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Sun Jun 28 16:45:57 JST 2009
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
|
11
|
+
class FtTimeoutTest < Test::Unit::TestCase
|
12
|
+
include FunctionalBase
|
13
|
+
|
14
|
+
def test_timeout
|
15
|
+
|
16
|
+
pdef = Ruote.process_definition do
|
17
|
+
sequence do
|
18
|
+
alpha :timeout => '1.1'
|
19
|
+
bravo
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
@engine.register_participant :alpha, Ruote::StorageParticipant
|
24
|
+
sto = @engine.register_participant :bravo, Ruote::StorageParticipant
|
25
|
+
|
26
|
+
#noisy
|
27
|
+
|
28
|
+
wfid = @engine.launch(pdef)
|
29
|
+
wait_for(:bravo)
|
30
|
+
|
31
|
+
assert_equal 1, sto.size
|
32
|
+
assert_equal 'bravo', sto.first.participant_name
|
33
|
+
|
34
|
+
assert_equal 2, logger.log.select { |e| e['flavour'] == 'timeout' }.size
|
35
|
+
assert_equal 0, @engine.storage.get_many('schedules').size
|
36
|
+
|
37
|
+
assert_equal wfid, sto.first.fields['__timed_out__'][0]['wfid']
|
38
|
+
assert_equal '0_0_0', sto.first.fields['__timed_out__'][0]['expid']
|
39
|
+
assert_equal 'participant', sto.first.fields['__timed_out__'][2]
|
40
|
+
|
41
|
+
assert_equal(
|
42
|
+
{ 'timeout' => '1.1', 'ref' => 'alpha' },
|
43
|
+
sto.first.fields['__timed_out__'][3])
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_cancel_timeout
|
47
|
+
|
48
|
+
pdef = Ruote.process_definition do
|
49
|
+
sequence do
|
50
|
+
alpha :timeout => '1.1'
|
51
|
+
bravo
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
@engine.register_participant :alpha, Ruote::StorageParticipant
|
56
|
+
sto = @engine.register_participant :bravo, Ruote::StorageParticipant
|
57
|
+
|
58
|
+
#noisy
|
59
|
+
|
60
|
+
wfid = @engine.launch(pdef)
|
61
|
+
wait_for(6)
|
62
|
+
|
63
|
+
assert_equal 1, sto.size
|
64
|
+
assert_equal 'alpha', sto.first.participant_name
|
65
|
+
|
66
|
+
@engine.cancel_expression(sto.first.fei)
|
67
|
+
|
68
|
+
wait_for(:bravo)
|
69
|
+
|
70
|
+
assert_equal 1, sto.size
|
71
|
+
assert_equal 'bravo', sto.first.participant_name
|
72
|
+
assert_equal 0, @engine.storage.get_many('schedules').size
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_on_timeout_redo
|
76
|
+
|
77
|
+
# with ruote-couch the 'cancel-process' operation gets overriden by
|
78
|
+
# the timeout cancel...
|
79
|
+
#
|
80
|
+
# 0 20 ca * 20100320-bipopimita {}
|
81
|
+
# 1 20 ca * 20100320-bipopimita 0 {"flavour"=>nil}
|
82
|
+
# 2 20 ca * 20100320-bipopimita 0_0 {"flavour"=>"timeout"}
|
83
|
+
# 3 20 ca * 20100320-bipopimita 0_0 {"flavour"=>nil, :pi=>"0!!20100320-bipopimita"}
|
84
|
+
#
|
85
|
+
# hence the multiple cancel at the end of the test
|
86
|
+
|
87
|
+
pdef = Ruote.process_definition do
|
88
|
+
alpha :timeout => '1.1', :on_timeout => 'redo'
|
89
|
+
end
|
90
|
+
|
91
|
+
alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
|
92
|
+
|
93
|
+
#noisy
|
94
|
+
|
95
|
+
wfid = @engine.launch(pdef)
|
96
|
+
wait_for(8)
|
97
|
+
|
98
|
+
#logger.log.each { |e| p e['flavour'] }
|
99
|
+
assert logger.log.select { |e| e['flavour'] == 'timeout' }.size >= 2
|
100
|
+
|
101
|
+
3.times do
|
102
|
+
Thread.pass
|
103
|
+
@engine.cancel_process(wfid)
|
104
|
+
end
|
105
|
+
|
106
|
+
wait_for(wfid)
|
107
|
+
|
108
|
+
assert_nil @engine.process(wfid)
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_on_timeout_cancel_nested
|
112
|
+
|
113
|
+
pdef = Ruote.process_definition do
|
114
|
+
sequence :timeout => '1.1', :on_timeout => 'timedout' do
|
115
|
+
alpha
|
116
|
+
end
|
117
|
+
define 'timedout' do
|
118
|
+
echo 'timed out'
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
|
123
|
+
|
124
|
+
#noisy
|
125
|
+
|
126
|
+
wfid = @engine.launch(pdef)
|
127
|
+
wait_for(wfid)
|
128
|
+
|
129
|
+
assert_nil @engine.process(wfid)
|
130
|
+
assert_equal 'timed out', @tracer.to_s
|
131
|
+
assert_equal 0, @engine.context.storage.get_many('expressions').size
|
132
|
+
assert_equal 0, alpha.size
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_on_timeout_error
|
136
|
+
|
137
|
+
pdef = Ruote.process_definition do
|
138
|
+
alpha :timeout => '1.1', :on_timeout => 'error'
|
139
|
+
end
|
140
|
+
|
141
|
+
alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
|
142
|
+
|
143
|
+
#noisy
|
144
|
+
|
145
|
+
wfid = @engine.launch(pdef)
|
146
|
+
wait_for(wfid)
|
147
|
+
|
148
|
+
ps = @engine.process(wfid)
|
149
|
+
|
150
|
+
assert_equal 1, ps.errors.size
|
151
|
+
|
152
|
+
err = ps.errors.first
|
153
|
+
err.tree = [ 'alpha', {}, [] ]
|
154
|
+
|
155
|
+
@engine.replay_at_error(err)
|
156
|
+
wait_for(:alpha)
|
157
|
+
|
158
|
+
assert_equal 1, alpha.size
|
159
|
+
assert_not_nil alpha.first.fields['__timed_out__']
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_deep_on_timeout_error
|
163
|
+
|
164
|
+
pdef = Ruote.process_definition do
|
165
|
+
sequence :timeout => '1.1', :on_timeout => 'error' do
|
166
|
+
alpha
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
|
171
|
+
|
172
|
+
wfid = @engine.launch(pdef)
|
173
|
+
wait_for(wfid)
|
174
|
+
|
175
|
+
ps = @engine.process(wfid)
|
176
|
+
|
177
|
+
assert_equal 1, ps.errors.size
|
178
|
+
assert_equal 0, alpha.size
|
179
|
+
assert_equal 2, ps.expressions.size
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_timeout_then_error
|
183
|
+
|
184
|
+
pdef = Ruote.process_definition do
|
185
|
+
sequence :timeout => '1.3' do
|
186
|
+
toto
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
#noisy
|
191
|
+
|
192
|
+
wfid = @engine.launch(pdef)
|
193
|
+
|
194
|
+
wait_for(4)
|
195
|
+
|
196
|
+
ps = @engine.process(wfid)
|
197
|
+
|
198
|
+
assert_equal 1, ps.errors.size
|
199
|
+
assert_equal 0, @engine.storage.get_many('schedules').size
|
200
|
+
end
|
201
|
+
|
202
|
+
def test_timeout_at
|
203
|
+
|
204
|
+
t = (Time.now + 2).to_s
|
205
|
+
|
206
|
+
pdef = Ruote.process_definition do
|
207
|
+
sequence :timeout => t do
|
208
|
+
alpha
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
|
213
|
+
|
214
|
+
#noisy
|
215
|
+
|
216
|
+
wfid = @engine.launch(pdef)
|
217
|
+
|
218
|
+
#wait_for(9)
|
219
|
+
wait_for(wfid)
|
220
|
+
|
221
|
+
assert_nil @engine.process(wfid)
|
222
|
+
assert_equal 0, alpha.size
|
223
|
+
assert_equal 0, @engine.storage.get_many('schedules').size
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
@@ -0,0 +1,98 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Wed Jul 1 09:51:30 JST 2009
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
|
11
|
+
class FtParticipantParamsTest < Test::Unit::TestCase
|
12
|
+
include FunctionalBase
|
13
|
+
|
14
|
+
def test_params
|
15
|
+
|
16
|
+
pdef = Ruote.process_definition do
|
17
|
+
sequence do
|
18
|
+
alpha
|
19
|
+
alpha :activity => 'buy groceries'
|
20
|
+
alpha
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
|
25
|
+
|
26
|
+
#noisy
|
27
|
+
|
28
|
+
wfid = @engine.launch(pdef)
|
29
|
+
|
30
|
+
wait_for(:alpha)
|
31
|
+
assert_equal({ 'ref' => 'alpha' }, alpha.first.fields['params'])
|
32
|
+
alpha.proceed(alpha.first)
|
33
|
+
|
34
|
+
wait_for(:alpha)
|
35
|
+
assert_equal('buy groceries', alpha.first.fields['params']['activity'])
|
36
|
+
alpha.proceed(alpha.first)
|
37
|
+
|
38
|
+
wait_for(:alpha)
|
39
|
+
assert_equal({ 'ref' => 'alpha' }, alpha.first.fields['params'])
|
40
|
+
alpha.proceed(alpha.first)
|
41
|
+
|
42
|
+
wait_for(wfid)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_attribute_text_param
|
46
|
+
|
47
|
+
pdef = Ruote.process_definition do
|
48
|
+
alpha 'nemo', :action => 'nada'
|
49
|
+
bravo
|
50
|
+
end
|
51
|
+
|
52
|
+
@engine.register { catchall }
|
53
|
+
|
54
|
+
#@engine.noisy = true
|
55
|
+
|
56
|
+
@engine.launch(pdef)
|
57
|
+
|
58
|
+
@engine.wait_for(:alpha)
|
59
|
+
workitem = @engine.storage_participant.first
|
60
|
+
|
61
|
+
assert_equal(
|
62
|
+
{ 'nemo' => nil, 'action' => 'nada', 'ref' => 'alpha' }, workitem.params)
|
63
|
+
assert_equal(
|
64
|
+
'nemo', workitem.param_text)
|
65
|
+
|
66
|
+
@engine.storage_participant.proceed(workitem)
|
67
|
+
|
68
|
+
@engine.wait_for(:bravo)
|
69
|
+
workitem = @engine.storage_participant.first
|
70
|
+
|
71
|
+
assert_equal(
|
72
|
+
nil, workitem.param_text)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_param_or_field
|
76
|
+
|
77
|
+
pdef = Ruote.process_definition do
|
78
|
+
alpha
|
79
|
+
alpha :theme => :wagner
|
80
|
+
end
|
81
|
+
|
82
|
+
@engine.register :alpha do |workitem|
|
83
|
+
context.tracer << "pof_theme:#{workitem.param_or_field(:theme)}\n"
|
84
|
+
context.tracer << "fop_theme:#{workitem.field_or_param(:theme)}\n"
|
85
|
+
end
|
86
|
+
|
87
|
+
#@engine.noisy = true
|
88
|
+
|
89
|
+
wfid = @engine.launch(pdef, 'theme' => 'mozart')
|
90
|
+
@engine.wait_for(wfid)
|
91
|
+
|
92
|
+
assert_equal %w[
|
93
|
+
pof_theme:mozart fop_theme:mozart
|
94
|
+
pof_theme:wagner fop_theme:mozart
|
95
|
+
], @tracer.to_a
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
@@ -0,0 +1,102 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Fri Jul 3 19:46:22 JST 2009
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
|
11
|
+
class FtConditionalTest < Test::Unit::TestCase
|
12
|
+
include FunctionalBase
|
13
|
+
|
14
|
+
def test_string_equality
|
15
|
+
|
16
|
+
pdef = Ruote.process_definition :name => 'test' do
|
17
|
+
|
18
|
+
set :f => 'd', :val => '2'
|
19
|
+
|
20
|
+
sequence do
|
21
|
+
|
22
|
+
echo '${f:d}'
|
23
|
+
|
24
|
+
echo 'a', :if => '${f:d}'
|
25
|
+
echo 'b', :if => '${f:d} == 2'
|
26
|
+
echo 'c', :if => "${f:d} == '2'"
|
27
|
+
echo 'd', :if => '${f:d} is set'
|
28
|
+
echo 'e', :if => '${f:e} is set'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
assert_trace(%w[ 2 a b d ], pdef)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_string_equality_when_space
|
36
|
+
|
37
|
+
pdef = Ruote.process_definition :name => 'test' do
|
38
|
+
|
39
|
+
set :f => 'd', :val => 'some dude'
|
40
|
+
|
41
|
+
sequence do
|
42
|
+
|
43
|
+
echo '${f:d}'
|
44
|
+
|
45
|
+
echo 'a', :if => '${f:d}'
|
46
|
+
echo 'b', :if => '${f:d} == some dude'
|
47
|
+
echo 'c', :if => "${f:d} == 'some dude'"
|
48
|
+
echo 'd', :if => "${f:d} == ${'f:d}"
|
49
|
+
echo 'e', :if => '${f:d} is set'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
assert_trace("some dude\na\nc\nd\ne", pdef)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_unless
|
57
|
+
|
58
|
+
pdef = Ruote.process_definition :name => 'test' do
|
59
|
+
|
60
|
+
echo '${f:f}'
|
61
|
+
echo 'u', :unless => '${f:f} == 2000'
|
62
|
+
echo 'i', :if => '${f:f} == 2000'
|
63
|
+
echo '.'
|
64
|
+
end
|
65
|
+
|
66
|
+
assert_trace(%w[ 2000 i . ], { 'f' => 2000 }, pdef)
|
67
|
+
|
68
|
+
@tracer.clear
|
69
|
+
|
70
|
+
assert_trace(%w[ 2000 i . ], { 'f' => '2000' }, pdef)
|
71
|
+
|
72
|
+
@tracer.clear
|
73
|
+
|
74
|
+
assert_trace(%w[ other u . ], { 'f' => 'other' }, pdef)
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_and_or
|
78
|
+
|
79
|
+
pdef = Ruote.process_definition do
|
80
|
+
|
81
|
+
set 'f:t' => true
|
82
|
+
set 'f:f' => false
|
83
|
+
set 'f:name' => 'n'
|
84
|
+
set 'f:city' => 'c'
|
85
|
+
|
86
|
+
sequence do
|
87
|
+
|
88
|
+
echo '${f:t}/${f:f}'
|
89
|
+
|
90
|
+
echo 'a', :if => '${f:t}'
|
91
|
+
echo 'b', :if => '${f:t} or ${f:f}'
|
92
|
+
echo 'c', :if => '${f:t} and ${f:f}'
|
93
|
+
echo 'd', :if => '${f:t} and (${f:t} or ${f:f})'
|
94
|
+
echo 'e', :if => '${f:t} and (${f:t} and ${f:f})'
|
95
|
+
echo 'f', :if => '${name} == n and ${city} == c'
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
assert_trace(%w[ true/false a b d f ], pdef)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
@@ -0,0 +1,138 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Sun Jul 5 22:56:06 JST 2009
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
|
11
|
+
class FtKillTest < Test::Unit::TestCase
|
12
|
+
include FunctionalBase
|
13
|
+
|
14
|
+
def test_kill_process
|
15
|
+
|
16
|
+
pdef = Ruote.process_definition do
|
17
|
+
alpha
|
18
|
+
end
|
19
|
+
|
20
|
+
alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
|
21
|
+
|
22
|
+
#noisy
|
23
|
+
|
24
|
+
wfid = @engine.launch(pdef)
|
25
|
+
wait_for(:alpha)
|
26
|
+
|
27
|
+
@engine.kill_process(wfid)
|
28
|
+
|
29
|
+
wait_for(wfid)
|
30
|
+
ps = @engine.process(wfid)
|
31
|
+
|
32
|
+
assert_nil ps
|
33
|
+
assert_equal 0, alpha.size
|
34
|
+
|
35
|
+
assert_equal(
|
36
|
+
1, logger.log.select { |e| e['action'] == 'kill_process' }.size)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_kill_does_not_trigger_on_cancel
|
40
|
+
|
41
|
+
pdef = Ruote.process_definition do
|
42
|
+
sequence :on_cancel => 'catcher' do
|
43
|
+
alpha
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
@engine.register_participant :alpha, Ruote::StorageParticipant
|
48
|
+
sto = @engine.register_participant :catcher, Ruote::StorageParticipant
|
49
|
+
|
50
|
+
wfid = @engine.launch(pdef)
|
51
|
+
wait_for(:alpha)
|
52
|
+
|
53
|
+
@engine.kill_process(wfid)
|
54
|
+
|
55
|
+
wait_for(wfid)
|
56
|
+
|
57
|
+
assert_equal 0, sto.size
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_kill_expression_does_not_trigger_on_cancel
|
61
|
+
|
62
|
+
pdef = Ruote.process_definition do
|
63
|
+
sequence :on_cancel => 'catcher' do
|
64
|
+
alpha
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
@engine.register_participant :alpha, Ruote::StorageParticipant
|
69
|
+
sto = @engine.register_participant :catcher, Ruote::StorageParticipant
|
70
|
+
|
71
|
+
wfid = @engine.launch(pdef)
|
72
|
+
wait_for(:alpha)
|
73
|
+
|
74
|
+
@engine.kill_expression(sto.first.fei)
|
75
|
+
|
76
|
+
wait_for(wfid)
|
77
|
+
|
78
|
+
assert_equal 0, sto.size
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_kill__expression
|
82
|
+
|
83
|
+
pdef = Ruote.process_definition do
|
84
|
+
alpha
|
85
|
+
end
|
86
|
+
|
87
|
+
@engine.register_participant :alpha, Ruote::NullParticipant
|
88
|
+
|
89
|
+
#noisy
|
90
|
+
|
91
|
+
wfid = @engine.launch(pdef)
|
92
|
+
|
93
|
+
@engine.wait_for(:alpha)
|
94
|
+
|
95
|
+
@engine.kill(wfid)
|
96
|
+
|
97
|
+
@engine.wait_for(wfid)
|
98
|
+
|
99
|
+
assert_nil @engine.process(wfid)
|
100
|
+
|
101
|
+
assert_equal 1, logger.log.select { |e| e['action'] == 'kill_process' }.size
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_kill__process
|
105
|
+
|
106
|
+
pdef = Ruote.process_definition do
|
107
|
+
alpha
|
108
|
+
echo '0'
|
109
|
+
alpha
|
110
|
+
echo '1'
|
111
|
+
alpha
|
112
|
+
echo '2'
|
113
|
+
end
|
114
|
+
|
115
|
+
@engine.register_participant :alpha, Ruote::NullParticipant
|
116
|
+
|
117
|
+
wfid = @engine.launch(pdef)
|
118
|
+
|
119
|
+
r = @engine.wait_for(:alpha)
|
120
|
+
|
121
|
+
@engine.kill(r['fei']) # fei as a Hash
|
122
|
+
|
123
|
+
r = @engine.wait_for(:alpha)
|
124
|
+
|
125
|
+
@engine.kill(Ruote.sid(r['fei'])) # fei as a String
|
126
|
+
|
127
|
+
r = @engine.wait_for(:alpha)
|
128
|
+
|
129
|
+
@engine.kill(Ruote::Workitem.new(r['workitem'])) # fei as workitem
|
130
|
+
|
131
|
+
@engine.wait_for(wfid)
|
132
|
+
|
133
|
+
assert_equal %w[ 0 1 2 ], @tracer.to_a
|
134
|
+
|
135
|
+
assert_equal 6, logger.log.select { |e| e['flavour'] == 'kill' }.size
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|