ruote-maestrodev 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (265) hide show
  1. data/CHANGELOG.txt +290 -0
  2. data/CREDITS.txt +99 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.rdoc +88 -0
  5. data/Rakefile +108 -0
  6. data/TODO.txt +488 -0
  7. data/lib/ruote.rb +7 -0
  8. data/lib/ruote/context.rb +194 -0
  9. data/lib/ruote/engine.rb +1062 -0
  10. data/lib/ruote/engine/process_error.rb +122 -0
  11. data/lib/ruote/engine/process_status.rb +448 -0
  12. data/lib/ruote/exp/command.rb +87 -0
  13. data/lib/ruote/exp/commanded.rb +69 -0
  14. data/lib/ruote/exp/condition.rb +227 -0
  15. data/lib/ruote/exp/fe_add_branches.rb +138 -0
  16. data/lib/ruote/exp/fe_apply.rb +154 -0
  17. data/lib/ruote/exp/fe_cancel_process.rb +78 -0
  18. data/lib/ruote/exp/fe_command.rb +156 -0
  19. data/lib/ruote/exp/fe_concurrence.rb +321 -0
  20. data/lib/ruote/exp/fe_concurrent_iterator.rb +219 -0
  21. data/lib/ruote/exp/fe_cron.rb +141 -0
  22. data/lib/ruote/exp/fe_cursor.rb +324 -0
  23. data/lib/ruote/exp/fe_define.rb +112 -0
  24. data/lib/ruote/exp/fe_echo.rb +60 -0
  25. data/lib/ruote/exp/fe_equals.rb +115 -0
  26. data/lib/ruote/exp/fe_error.rb +82 -0
  27. data/lib/ruote/exp/fe_filter.rb +648 -0
  28. data/lib/ruote/exp/fe_forget.rb +88 -0
  29. data/lib/ruote/exp/fe_given.rb +154 -0
  30. data/lib/ruote/exp/fe_if.rb +127 -0
  31. data/lib/ruote/exp/fe_inc.rb +205 -0
  32. data/lib/ruote/exp/fe_iterator.rb +234 -0
  33. data/lib/ruote/exp/fe_let.rb +75 -0
  34. data/lib/ruote/exp/fe_listen.rb +304 -0
  35. data/lib/ruote/exp/fe_lose.rb +110 -0
  36. data/lib/ruote/exp/fe_noop.rb +45 -0
  37. data/lib/ruote/exp/fe_once.rb +215 -0
  38. data/lib/ruote/exp/fe_participant.rb +287 -0
  39. data/lib/ruote/exp/fe_read.rb +69 -0
  40. data/lib/ruote/exp/fe_redo.rb +82 -0
  41. data/lib/ruote/exp/fe_ref.rb +152 -0
  42. data/lib/ruote/exp/fe_registerp.rb +110 -0
  43. data/lib/ruote/exp/fe_reserve.rb +126 -0
  44. data/lib/ruote/exp/fe_restore.rb +102 -0
  45. data/lib/ruote/exp/fe_save.rb +72 -0
  46. data/lib/ruote/exp/fe_sequence.rb +59 -0
  47. data/lib/ruote/exp/fe_set.rb +154 -0
  48. data/lib/ruote/exp/fe_subprocess.rb +211 -0
  49. data/lib/ruote/exp/fe_that.rb +92 -0
  50. data/lib/ruote/exp/fe_undo.rb +67 -0
  51. data/lib/ruote/exp/fe_unregisterp.rb +69 -0
  52. data/lib/ruote/exp/fe_wait.rb +95 -0
  53. data/lib/ruote/exp/flowexpression.rb +886 -0
  54. data/lib/ruote/exp/iterator.rb +81 -0
  55. data/lib/ruote/exp/merge.rb +118 -0
  56. data/lib/ruote/exp/ro_attributes.rb +212 -0
  57. data/lib/ruote/exp/ro_filters.rb +136 -0
  58. data/lib/ruote/exp/ro_persist.rb +154 -0
  59. data/lib/ruote/exp/ro_variables.rb +189 -0
  60. data/lib/ruote/exp/ro_vf.rb +68 -0
  61. data/lib/ruote/fei.rb +260 -0
  62. data/lib/ruote/id/mnemo_wfid_generator.rb +43 -0
  63. data/lib/ruote/id/wfid_generator.rb +81 -0
  64. data/lib/ruote/log/default_history.rb +122 -0
  65. data/lib/ruote/log/pretty.rb +176 -0
  66. data/lib/ruote/log/storage_history.rb +159 -0
  67. data/lib/ruote/log/test_logger.rb +208 -0
  68. data/lib/ruote/log/wait_logger.rb +64 -0
  69. data/lib/ruote/part/block_participant.rb +137 -0
  70. data/lib/ruote/part/code_participant.rb +81 -0
  71. data/lib/ruote/part/engine_participant.rb +189 -0
  72. data/lib/ruote/part/local_participant.rb +138 -0
  73. data/lib/ruote/part/no_op_participant.rb +60 -0
  74. data/lib/ruote/part/null_participant.rb +54 -0
  75. data/lib/ruote/part/rev_participant.rb +169 -0
  76. data/lib/ruote/part/smtp_participant.rb +116 -0
  77. data/lib/ruote/part/storage_participant.rb +392 -0
  78. data/lib/ruote/part/template.rb +84 -0
  79. data/lib/ruote/participant.rb +7 -0
  80. data/lib/ruote/reader.rb +278 -0
  81. data/lib/ruote/reader/json.rb +49 -0
  82. data/lib/ruote/reader/radial.rb +290 -0
  83. data/lib/ruote/reader/ruby_dsl.rb +186 -0
  84. data/lib/ruote/reader/xml.rb +99 -0
  85. data/lib/ruote/receiver/base.rb +212 -0
  86. data/lib/ruote/storage/base.rb +364 -0
  87. data/lib/ruote/storage/composite_storage.rb +121 -0
  88. data/lib/ruote/storage/fs_storage.rb +139 -0
  89. data/lib/ruote/storage/hash_storage.rb +211 -0
  90. data/lib/ruote/svc/dispatch_pool.rb +158 -0
  91. data/lib/ruote/svc/dollar_sub.rb +298 -0
  92. data/lib/ruote/svc/error_handler.rb +138 -0
  93. data/lib/ruote/svc/expression_map.rb +97 -0
  94. data/lib/ruote/svc/participant_list.rb +397 -0
  95. data/lib/ruote/svc/tracker.rb +172 -0
  96. data/lib/ruote/svc/treechecker.rb +141 -0
  97. data/lib/ruote/tree_dot.rb +85 -0
  98. data/lib/ruote/util/filter.rb +525 -0
  99. data/lib/ruote/util/hashdot.rb +79 -0
  100. data/lib/ruote/util/look.rb +128 -0
  101. data/lib/ruote/util/lookup.rb +127 -0
  102. data/lib/ruote/util/misc.rb +167 -0
  103. data/lib/ruote/util/ometa.rb +71 -0
  104. data/lib/ruote/util/serializer.rb +103 -0
  105. data/lib/ruote/util/subprocess.rb +88 -0
  106. data/lib/ruote/util/time.rb +100 -0
  107. data/lib/ruote/util/tree.rb +58 -0
  108. data/lib/ruote/version.rb +29 -0
  109. data/lib/ruote/worker.rb +386 -0
  110. data/lib/ruote/workitem.rb +394 -0
  111. data/phil.txt +14 -0
  112. data/ruote.gemspec +44 -0
  113. data/test/bm/ci.rb +55 -0
  114. data/test/bm/ici.rb +71 -0
  115. data/test/bm/juuman.rb +54 -0
  116. data/test/bm/launch_bench.rb +37 -0
  117. data/test/bm/load_26c.rb +97 -0
  118. data/test/bm/mega.rb +64 -0
  119. data/test/bm/seq_thousand.rb +31 -0
  120. data/test/bm/t.rb +35 -0
  121. data/test/functional/base.rb +247 -0
  122. data/test/functional/concurrent_base.rb +98 -0
  123. data/test/functional/crunner.rb +31 -0
  124. data/test/functional/ct_0_concurrence.rb +65 -0
  125. data/test/functional/ct_1_iterator.rb +67 -0
  126. data/test/functional/ct_2_cancel.rb +81 -0
  127. data/test/functional/eft_0_process_definition.rb +65 -0
  128. data/test/functional/eft_10_cancel_process.rb +46 -0
  129. data/test/functional/eft_11_wait.rb +109 -0
  130. data/test/functional/eft_12_listen.rb +500 -0
  131. data/test/functional/eft_13_iterator.rb +342 -0
  132. data/test/functional/eft_14_cursor.rb +456 -0
  133. data/test/functional/eft_15_loop.rb +69 -0
  134. data/test/functional/eft_16_if.rb +183 -0
  135. data/test/functional/eft_17_equals.rb +55 -0
  136. data/test/functional/eft_18_concurrent_iterator.rb +410 -0
  137. data/test/functional/eft_19_reserve.rb +136 -0
  138. data/test/functional/eft_1_echo.rb +68 -0
  139. data/test/functional/eft_20_save.rb +116 -0
  140. data/test/functional/eft_21_restore.rb +61 -0
  141. data/test/functional/eft_22_noop.rb +28 -0
  142. data/test/functional/eft_23_apply.rb +168 -0
  143. data/test/functional/eft_24_add_branches.rb +98 -0
  144. data/test/functional/eft_25_command.rb +28 -0
  145. data/test/functional/eft_26_error.rb +77 -0
  146. data/test/functional/eft_27_inc.rb +280 -0
  147. data/test/functional/eft_28_once.rb +135 -0
  148. data/test/functional/eft_29_cron.rb +64 -0
  149. data/test/functional/eft_2_sequence.rb +58 -0
  150. data/test/functional/eft_30_ref.rb +155 -0
  151. data/test/functional/eft_31_registerp.rb +130 -0
  152. data/test/functional/eft_32_lose.rb +93 -0
  153. data/test/functional/eft_33_let.rb +31 -0
  154. data/test/functional/eft_34_given.rb +123 -0
  155. data/test/functional/eft_35_filter.rb +375 -0
  156. data/test/functional/eft_36_read.rb +95 -0
  157. data/test/functional/eft_3_participant.rb +149 -0
  158. data/test/functional/eft_4_set.rb +296 -0
  159. data/test/functional/eft_5_subprocess.rb +163 -0
  160. data/test/functional/eft_6_concurrence.rb +304 -0
  161. data/test/functional/eft_7_forget.rb +61 -0
  162. data/test/functional/eft_8_undo.rb +114 -0
  163. data/test/functional/eft_9_redo.rb +138 -0
  164. data/test/functional/ft_0_worker.rb +65 -0
  165. data/test/functional/ft_10_dollar.rb +304 -0
  166. data/test/functional/ft_11_recursion.rb +109 -0
  167. data/test/functional/ft_12_launchitem.rb +43 -0
  168. data/test/functional/ft_13_variables.rb +151 -0
  169. data/test/functional/ft_14_re_apply.rb +324 -0
  170. data/test/functional/ft_15_timeout.rb +226 -0
  171. data/test/functional/ft_16_participant_params.rb +98 -0
  172. data/test/functional/ft_17_conditional.rb +102 -0
  173. data/test/functional/ft_18_kill.rb +138 -0
  174. data/test/functional/ft_19_participant_code.rb +67 -0
  175. data/test/functional/ft_1_process_status.rb +796 -0
  176. data/test/functional/ft_20_storage_participant.rb +543 -0
  177. data/test/functional/ft_21_forget.rb +153 -0
  178. data/test/functional/ft_22_process_definitions.rb +90 -0
  179. data/test/functional/ft_23_load_defs.rb +79 -0
  180. data/test/functional/ft_24_block_participant.rb +235 -0
  181. data/test/functional/ft_25_receiver.rb +207 -0
  182. data/test/functional/ft_26_participant_rtimeout.rb +179 -0
  183. data/test/functional/ft_27_var_indirection.rb +128 -0
  184. data/test/functional/ft_28_null_noop_participants.rb +51 -0
  185. data/test/functional/ft_29_part_template.rb +60 -0
  186. data/test/functional/ft_2_errors.rb +380 -0
  187. data/test/functional/ft_30_smtp_participant.rb +122 -0
  188. data/test/functional/ft_31_part_blocking.rb +72 -0
  189. data/test/functional/ft_33_participant_subprocess_priority.rb +32 -0
  190. data/test/functional/ft_34_cursor_rewind.rb +101 -0
  191. data/test/functional/ft_35_add_service.rb +56 -0
  192. data/test/functional/ft_36_storage_history.rb +150 -0
  193. data/test/functional/ft_37_default_history.rb +109 -0
  194. data/test/functional/ft_38_participant_more.rb +193 -0
  195. data/test/functional/ft_39_wait_for.rb +136 -0
  196. data/test/functional/ft_3_participant_registration.rb +574 -0
  197. data/test/functional/ft_40_wait_logger.rb +62 -0
  198. data/test/functional/ft_41_participants.rb +91 -0
  199. data/test/functional/ft_42_storage_copy.rb +71 -0
  200. data/test/functional/ft_43_participant_on_reply.rb +87 -0
  201. data/test/functional/ft_44_var_participant.rb +35 -0
  202. data/test/functional/ft_45_participant_accept.rb +64 -0
  203. data/test/functional/ft_46_launch_single.rb +83 -0
  204. data/test/functional/ft_47_wfid_generator.rb +54 -0
  205. data/test/functional/ft_48_lose.rb +112 -0
  206. data/test/functional/ft_49_engine_on_error.rb +201 -0
  207. data/test/functional/ft_4_cancel.rb +132 -0
  208. data/test/functional/ft_50_engine_config.rb +22 -0
  209. data/test/functional/ft_51_misc.rb +67 -0
  210. data/test/functional/ft_52_case.rb +134 -0
  211. data/test/functional/ft_53_engine_on_terminate.rb +95 -0
  212. data/test/functional/ft_54_patterns.rb +104 -0
  213. data/test/functional/ft_55_engine_participant.rb +303 -0
  214. data/test/functional/ft_56_filter_attribute.rb +259 -0
  215. data/test/functional/ft_57_rev_participant.rb +252 -0
  216. data/test/functional/ft_58_workitem.rb +69 -0
  217. data/test/functional/ft_59_pause.rb +343 -0
  218. data/test/functional/ft_5_on_error.rb +384 -0
  219. data/test/functional/ft_60_code_participant.rb +45 -0
  220. data/test/functional/ft_61_trailing_fields.rb +34 -0
  221. data/test/functional/ft_62_exp_name_and_dollar_substitution.rb +35 -0
  222. data/test/functional/ft_6_on_cancel.rb +221 -0
  223. data/test/functional/ft_7_tags.rb +177 -0
  224. data/test/functional/ft_8_participant_consumption.rb +124 -0
  225. data/test/functional/ft_9_subprocesses.rb +146 -0
  226. data/test/functional/restart_base.rb +34 -0
  227. data/test/functional/rt_0_wait.rb +55 -0
  228. data/test/functional/rt_1_listen.rb +56 -0
  229. data/test/functional/rt_2_errors.rb +56 -0
  230. data/test/functional/rt_3_once.rb +70 -0
  231. data/test/functional/rt_4_cron.rb +64 -0
  232. data/test/functional/rt_5_timeout.rb +60 -0
  233. data/test/functional/rtest.rb +8 -0
  234. data/test/functional/storage_helper.rb +93 -0
  235. data/test/functional/test.rb +44 -0
  236. data/test/functional/vertical.rb +46 -0
  237. data/test/path_helper.rb +15 -0
  238. data/test/test.rb +13 -0
  239. data/test/test_helper.rb +28 -0
  240. data/test/unit/storage.rb +428 -0
  241. data/test/unit/storages.rb +37 -0
  242. data/test/unit/test.rb +28 -0
  243. data/test/unit/ut_0_ruby_reader.rb +223 -0
  244. data/test/unit/ut_11_lookup.rb +122 -0
  245. data/test/unit/ut_13_serializer.rb +65 -0
  246. data/test/unit/ut_14_is_uri.rb +28 -0
  247. data/test/unit/ut_15_util.rb +57 -0
  248. data/test/unit/ut_16_reader.rb +225 -0
  249. data/test/unit/ut_18_engine.rb +47 -0
  250. data/test/unit/ut_19_part_template.rb +86 -0
  251. data/test/unit/ut_1_fei.rb +165 -0
  252. data/test/unit/ut_20_composite_storage.rb +74 -0
  253. data/test/unit/ut_21_svc_participant_list.rb +46 -0
  254. data/test/unit/ut_22_filter.rb +1094 -0
  255. data/test/unit/ut_23_svc_tracker.rb +48 -0
  256. data/test/unit/ut_24_radial_reader.rb +332 -0
  257. data/test/unit/ut_25_merge.rb +113 -0
  258. data/test/unit/ut_3_wait_logger.rb +39 -0
  259. data/test/unit/ut_4_expmap.rb +20 -0
  260. data/test/unit/ut_5_tree.rb +54 -0
  261. data/test/unit/ut_6_condition.rb +303 -0
  262. data/test/unit/ut_7_workitem.rb +99 -0
  263. data/test/unit/ut_8_tree_to_dot.rb +72 -0
  264. data/test/unit/ut_9_xml_reader.rb +61 -0
  265. metadata +504 -0
@@ -0,0 +1,69 @@
1
+
2
+ #
3
+ # testing ruote
4
+ #
5
+ # Mon Jun 29 22:29:15 JST 2009
6
+ #
7
+
8
+ require File.join(File.dirname(__FILE__), 'base')
9
+
10
+
11
+ class EftLoopTest < Test::Unit::TestCase
12
+ include FunctionalBase
13
+
14
+ def test_loop
15
+
16
+ pdef = Ruote.process_definition :name => 'test' do
17
+ _loop do
18
+ alpha
19
+ bravo
20
+ end
21
+ end
22
+
23
+ #noisy
24
+
25
+ @engine.register_participant :alpha do |workitem|
26
+
27
+ @tracer << "a\n"
28
+ (workitem.fields['count'] ||= 0)
29
+ workitem.fields['count'] += 1
30
+ end
31
+
32
+ @engine.register_participant :bravo do |workitem|
33
+
34
+ @tracer << "b\n"
35
+ workitem.fields['count'] += 1
36
+
37
+ if workitem.fields['count'] > 5
38
+ workitem.fields['__command__'] = [ 'break', nil ]
39
+ end
40
+ end
41
+
42
+ assert_trace(%w[ a b a b a b ], pdef)
43
+ end
44
+
45
+ def test_repeat
46
+
47
+ pdef = Ruote.process_definition :name => 'test' do
48
+ repeat do
49
+ alpha
50
+ end
51
+ end
52
+
53
+ #noisy
54
+
55
+ @engine.register_participant :alpha do |workitem|
56
+
57
+ @tracer << "a\n"
58
+ (workitem.fields['count'] ||= 0)
59
+ workitem.fields['count'] += 1
60
+
61
+ if workitem.fields['count'] > 5
62
+ workitem.fields['__command__'] = [ 'break', nil ]
63
+ end
64
+ end
65
+
66
+ assert_trace(%w[ a a a a a a ], pdef)
67
+ end
68
+ end
69
+
@@ -0,0 +1,183 @@
1
+
2
+ #
3
+ # testing ruote
4
+ #
5
+ # Thu Jul 9 12:40:10 JST 2009
6
+ #
7
+
8
+ require File.join(File.dirname(__FILE__), 'base')
9
+
10
+
11
+ class EftIfTest < Test::Unit::TestCase
12
+ include FunctionalBase
13
+
14
+ def test_then
15
+
16
+ pdef = Ruote.process_definition :name => 'test' do
17
+ _if :test => 'true' do
18
+ echo 'then'
19
+ echo 'else'
20
+ end
21
+ end
22
+
23
+ #noisy
24
+
25
+ assert_trace('then', pdef)
26
+ end
27
+
28
+ def test_else
29
+
30
+ pdef = Ruote.process_definition :name => 'test' do
31
+ _if :test => 'false' do
32
+ echo 'then'
33
+ echo 'else'
34
+ end
35
+ end
36
+
37
+ #noisy
38
+
39
+ assert_trace('else', pdef)
40
+ end
41
+
42
+ def test_missing_then
43
+
44
+ pdef = Ruote.process_definition :name => 'test' do
45
+ sequence do
46
+ _if :test => 'true' do
47
+ end
48
+ echo 'done.'
49
+ end
50
+ end
51
+
52
+ #noisy
53
+
54
+ assert_trace('done.', pdef)
55
+ end
56
+
57
+ def test_missing_else
58
+
59
+ pdef = Ruote.process_definition :name => 'test' do
60
+ sequence do
61
+ _if :test => 'false' do
62
+ echo 'then'
63
+ end
64
+ echo 'done.'
65
+ end
66
+ end
67
+
68
+ #noisy
69
+
70
+ assert_trace('done.', pdef)
71
+ end
72
+
73
+ def test_equals_true
74
+
75
+ pdef = Ruote.process_definition :name => 'test' do
76
+ _if do
77
+ equals :val => 'a', :other_value => 'a'
78
+ echo 'then'
79
+ echo 'else'
80
+ end
81
+ end
82
+
83
+ #noisy
84
+
85
+ assert_trace('then', pdef)
86
+ end
87
+
88
+ def test_equals_false
89
+
90
+ pdef = Ruote.process_definition :name => 'test' do
91
+ _if do
92
+ equals :val => 'a', :other_value => 'z'
93
+ echo 'then'
94
+ echo 'else'
95
+ end
96
+ end
97
+
98
+ #noisy
99
+
100
+ assert_trace('else', pdef)
101
+ end
102
+
103
+ def test_equals_true_no_then
104
+
105
+ pdef = Ruote.process_definition :name => 'test' do
106
+ sequence do
107
+ _if do
108
+ equals :val => 'a', :other_value => 'z'
109
+ end
110
+ echo 'done.'
111
+ end
112
+ end
113
+
114
+ #noisy
115
+
116
+ assert_trace('done.', pdef)
117
+ end
118
+
119
+ def test_attribute_text
120
+
121
+ pdef = Ruote.process_definition :name => 'test' do
122
+ sequence do
123
+ _if 'true' do
124
+ echo 'then'
125
+ echo 'else'
126
+ end
127
+ _if 'false' do
128
+ echo 'then'
129
+ echo 'else'
130
+ end
131
+ _if false do
132
+ echo 'then'
133
+ echo 'else'
134
+ end
135
+ _if :test => false do
136
+ echo 'then'
137
+ echo 'else'
138
+ end
139
+ end
140
+ end
141
+
142
+ #noisy
143
+
144
+ assert_trace(%w[ then else else else ], pdef)
145
+ end
146
+
147
+ def test_xml_equals
148
+
149
+ require_json
150
+ Rufus::Json.detect_backend
151
+ # making sure JSON dup is available in case of HashStorage
152
+
153
+ pdef = %{
154
+ <?xml version="1.0"?>
155
+ <process-definition name="test_xml">
156
+ <if>
157
+ <equals field-value="state" other-value="A" />
158
+ <echo>alpha</echo>
159
+ <echo>bravo</echo>
160
+ </if>
161
+ </process-definition>
162
+ }
163
+
164
+ assert_trace('alpha', { 'state' => 'A' }, pdef)
165
+
166
+ @tracer.clear
167
+
168
+ assert_trace('alpha', { :state => 'A' }, pdef)
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
182
+ end
183
+
@@ -0,0 +1,55 @@
1
+
2
+ #
3
+ # testing ruote
4
+ #
5
+ # Thu Jul 9 13:31:59 JST 2009
6
+ #
7
+
8
+ require File.join(File.dirname(__FILE__), 'base')
9
+
10
+
11
+ class EftEqualsTest < Test::Unit::TestCase
12
+ include FunctionalBase
13
+
14
+ def test_false
15
+
16
+ pdef = Ruote.process_definition :name => 'test' do
17
+ sequence do
18
+
19
+ equals :field_value => 'missing', :other_value => 'nada'
20
+ echo '${f:__result__}'
21
+ equals :variable_value => 'missing', :other_value => 'nada'
22
+ echo '${f:__result__}'
23
+
24
+ equals :value => 'missing', :other_value => 'nada'
25
+ echo '${f:__result__}'
26
+ equals :val => 'missing', :other_val => 'nada'
27
+ echo '${f:__result__}'
28
+ end
29
+ end
30
+
31
+ #noisy
32
+
33
+ assert_trace(%w[ false ] * 4, pdef)
34
+ end
35
+
36
+ def test_true
37
+
38
+ pdef = Ruote.process_definition :name => 'test' do
39
+ sequence do
40
+
41
+ equals :value => 'nada', :other_value => 'nada'
42
+ echo '${f:__result__}'
43
+
44
+ set 'v:nada' => 'nada'
45
+ equals :variable_value => 'nada', :other_value => 'nada'
46
+ echo '${f:__result__}'
47
+ end
48
+ end
49
+
50
+ #noisy
51
+
52
+ assert_trace(%w[ true ] * 2, pdef)
53
+ end
54
+ end
55
+
@@ -0,0 +1,410 @@
1
+
2
+ #
3
+ # testing ruote
4
+ #
5
+ # Wed Jul 29 23:25:44 JST 2009
6
+ #
7
+
8
+ require File.join(File.dirname(__FILE__), 'base')
9
+
10
+
11
+ class EftConcurrentIteratorTest < Test::Unit::TestCase
12
+ include FunctionalBase
13
+
14
+ def test_empty_iterator
15
+
16
+ pdef = Ruote.process_definition :name => 'test' do
17
+ sequence do
18
+ concurrent_iterator :on_val => 'alice, bob, charly', :to_var => 'v' do
19
+ end
20
+ echo 'done.'
21
+ end
22
+ end
23
+
24
+ #noisy
25
+
26
+ assert_trace('done.', pdef)
27
+ end
28
+
29
+ def test_empty_list
30
+
31
+ pdef = Ruote.process_definition :name => 'test' do
32
+ sequence do
33
+ citerator :on_val => '', :to_var => 'v' do
34
+ echo 'x'
35
+ end
36
+ echo 'done.'
37
+ end
38
+ end
39
+
40
+ #noisy
41
+
42
+ assert_trace('done.', pdef)
43
+ end
44
+
45
+ def test_iterator
46
+
47
+ pdef = Ruote.process_definition :name => 'test' do
48
+ concurrent_iterator :on_val => 'alice, bob, charly', :to_var => 'v' do
49
+ participant '${v:v}'
50
+ end
51
+ end
52
+
53
+ register_catchall_participant
54
+
55
+ #noisy
56
+
57
+ wfid = @engine.launch(pdef)
58
+
59
+ wait_for(wfid)
60
+
61
+ trace = @tracer.to_s.split("\n").sort
62
+ assert_equal %w[ alice/0_0_0 bob/0_0_0 charly/0_0_0 ], trace
63
+ assert_equal 3, @subs.sort.uniq.size
64
+ end
65
+
66
+ def test_iterator_cbeer
67
+
68
+ pdef = Ruote.process_definition :name => 'test' do
69
+ concurrent_iterator :on_field => 'assets', :to_var => 'v' do
70
+ participant '${v:v}'
71
+ end
72
+ end
73
+
74
+ register_catchall_participant
75
+
76
+ #noisy
77
+
78
+ wfid = @engine.launch(pdef, 'assets' => %w[ a b c ])
79
+
80
+ wait_for(wfid)
81
+
82
+ trace = @tracer.to_s.split("\n").sort
83
+ assert_equal %w[ a/0_0_0 b/0_0_0 c/0_0_0 ], trace
84
+ assert_equal 3, @subs.sort.uniq.size
85
+ end
86
+
87
+ def test_iterator_to_f
88
+
89
+ pdef = Ruote.process_definition :name => 'test' do
90
+ concurrent_iterator :on_val => 'alice, bob, charly', :to_field => 'f' do
91
+ participant '${f:f}'
92
+ end
93
+ end
94
+
95
+ register_catchall_participant
96
+
97
+ #noisy
98
+
99
+ wfid = @engine.launch(pdef)
100
+
101
+ wait_for(wfid)
102
+
103
+ trace = @tracer.to_s.split("\n").sort
104
+ assert_equal %w[ alice/0_0_0 bob/0_0_0 charly/0_0_0 ], trace
105
+ assert_equal 3, @subs.sort.uniq.size
106
+ end
107
+
108
+ def test_iterator_with_array_param
109
+
110
+ pdef = Ruote.process_definition :name => 'test' do
111
+ sequence do
112
+ concurrent_iterator :on_val => %w[ a b c ], :to_field => 'f' do
113
+ participant '${f:f}'
114
+ end
115
+ echo 'done.'
116
+ end
117
+ end
118
+
119
+ register_catchall_participant
120
+
121
+ #noisy
122
+
123
+ wfid = @engine.launch(pdef)
124
+
125
+ wait_for(wfid)
126
+
127
+ trace = @tracer.to_s.split("\n").sort
128
+ assert_equal %w[ a/0_0_0_0 b/0_0_0_0 c/0_0_0_0 done. ], trace
129
+ assert_equal 3, @subs.sort.uniq.size
130
+ end
131
+
132
+ def test_iterator_with_branches_finishing_before_others
133
+
134
+ pdef = Ruote.process_definition :name => 'test' do
135
+ sequence do
136
+ concurrent_iterator :on_value => (1..2).to_a, :to_field => 'f' do
137
+ sequence do
138
+ participant_1
139
+ participant_2
140
+ end
141
+ end
142
+ participant_3
143
+ end
144
+ end
145
+
146
+ sto = @engine.register_participant '.+', Ruote::StorageParticipant
147
+
148
+ assert_equal 0, sto.size # just to be sure
149
+
150
+ #noisy
151
+
152
+ wfid = @engine.launch(pdef)
153
+
154
+ wait_for(:participant_1)
155
+ wait_for(:participant_1)
156
+
157
+ assert_equal(
158
+ { 'participant_1' => 2 },
159
+ sto.per_participant_count)
160
+
161
+ sto.proceed(sto.first)
162
+
163
+ wait_for(:participant_2)
164
+ wait_for(1)
165
+
166
+ assert_equal(
167
+ { 'participant_1' => 1, 'participant_2' => 1 },
168
+ sto.per_participant_count)
169
+
170
+ sto.proceed(sto.per_participant['participant_2'].first)
171
+
172
+ wait_for(3)
173
+
174
+ assert_equal 1, sto.size
175
+ assert_equal 'participant_1', sto.first.participant_name
176
+ end
177
+
178
+ def test_passing_non_array_as_thing_to_iterate
179
+
180
+ pdef = Ruote.process_definition :name => 'test' do
181
+ sequence do
182
+ concurrent_iterator :on_val => { 'a' => 'A' }, :to_f => 'f' do
183
+ p1
184
+ end
185
+ echo 'out'
186
+ end
187
+ end
188
+
189
+ @engine.register_participant :p1 do |workitem|
190
+ @tracer << "p1:#{workitem.fields['f'].join(':')}\n"
191
+ end
192
+
193
+ #noisy
194
+
195
+ assert_trace %w[ p1:a:A out ], pdef
196
+ end
197
+
198
+ def test_without_to
199
+
200
+ pdef = Ruote.process_definition :name => 'test' do
201
+ concurrent_iterator :on_value => (1..2).to_a do
202
+ echo 'a'
203
+ end
204
+ end
205
+
206
+ #noisy
207
+
208
+ assert_trace %w[ a a ], pdef
209
+ end
210
+
211
+ def test_branches_att
212
+
213
+ pdef = Ruote.process_definition :name => 'test' do
214
+ concurrent_iterator :branches => '2' do
215
+ echo 'a'
216
+ end
217
+ end
218
+
219
+ #noisy
220
+
221
+ assert_trace %w[ a a ], pdef
222
+ end
223
+
224
+ def test_implicit_i_variable
225
+
226
+ pdef = Ruote.process_definition :name => 'test' do
227
+ concurrent_iterator :on_val => 'alice, bob, charly' do
228
+ participant '${v:i}:${v:ii}'
229
+ end
230
+ end
231
+
232
+ register_catchall_participant
233
+
234
+ #noisy
235
+
236
+ wfid = @engine.launch(pdef)
237
+
238
+ wait_for(wfid)
239
+
240
+ trace = @tracer.to_s.split("\n").sort
241
+ assert_equal %w[ alice:0/0_0_0 bob:1/0_0_0 charly:2/0_0_0 ], trace
242
+ assert_equal 3, @subs.sort.uniq.size
243
+ end
244
+
245
+ def test_on_only
246
+
247
+ pdef = Ruote.process_definition :name => 'test' do
248
+ concurrent_iterator :on => 'a, b, c' do
249
+ echo '${v:i}'
250
+ end
251
+ end
252
+
253
+ #noisy
254
+
255
+ #assert_trace(*%w[ a b c ].permutation.to_a, pdef)
256
+ # this is not ruby 1.8.7p72 friendly
257
+
258
+ perms = %w[ a b c ].permutation.to_a
259
+ perms << pdef
260
+ assert_trace(*perms)
261
+ end
262
+
263
+ def test_merge_type_isolate
264
+
265
+ pdef = Ruote.process_definition do
266
+ concurrent_iterator :on => 'a, b, c', :to_f => 'f', :merge_type => 'isolate' do
267
+ echo '.'
268
+ end
269
+ bravo
270
+ end
271
+
272
+ @engine.register_participant :bravo do |workitem|
273
+ stash[:mf] = workitem.fields
274
+ nil
275
+ end
276
+
277
+ #noisy
278
+
279
+ assert_trace(%w[ . . . ], pdef)
280
+
281
+ mf = ('0'..'2').to_a.map { |k| @engine.context.stash[:mf][k]['f'] }.sort
282
+ assert_equal %w[ a b c ], mf
283
+ end
284
+
285
+ def test_merge_type_stack
286
+
287
+ pdef = Ruote.process_definition do
288
+ concurrent_iterator :on => 'a, b', :to_f => 'f', :merge_type => 'stack' do
289
+ echo '.'
290
+ end
291
+ bravo
292
+ end
293
+
294
+ @engine.register_participant :bravo do |workitem|
295
+ stash[:mf] = workitem.fields
296
+ nil
297
+ end
298
+
299
+ #noisy
300
+
301
+ assert_trace(%w[ . . ], pdef)
302
+
303
+ assert_equal(
304
+ [["a"], ["b"]],
305
+ @engine.context.stash[:mf]['stack'].collect { |f| f.values }.sort)
306
+ assert_equal(
307
+ {"on"=>"a, b", "to_f"=>"f", "merge_type"=>"stack"},
308
+ @engine.context.stash[:mf]['stack_attributes'])
309
+ end
310
+
311
+ def test_cancel
312
+
313
+ #n = 77
314
+ n = 14
315
+
316
+ pdef = Ruote.process_definition do
317
+ concurrent_iterator :times => n do
318
+ sequence do
319
+ alpha
320
+ bravo
321
+ end
322
+ end
323
+ end
324
+
325
+ @engine.context.stash[:a_count] = 0
326
+ @engine.register_participant(:alpha) { |wi| stash[:a_count] += 1 }
327
+ @engine.register_participant(:bravo, Ruote::NullParticipant)
328
+
329
+ #noisy
330
+
331
+ wfid = @engine.launch(pdef)
332
+
333
+ wait_for(2 + n * 5)
334
+ #p "=" * 80
335
+
336
+ assert_equal n, @engine.context.stash[:a_count]
337
+
338
+ @engine.cancel_process(wfid)
339
+ wait_for(wfid)
340
+
341
+ assert_nil @engine.process(wfid)
342
+ end
343
+
344
+ def test_add_branch_command
345
+
346
+ pdef = Ruote.process_definition :name => 'test' do
347
+ sequence do
348
+ concurrent_iterator :on_value => (1..2).to_a, :to_field => 'f' do
349
+ alpha
350
+ end
351
+ echo '.'
352
+ end
353
+ end
354
+
355
+ @engine.register_participant 'alpha' do |wi|
356
+
357
+ @tracer << "#{wi.fields['f']}\n"
358
+
359
+ wi.fields['__add_branches__'] = %w[ a b ] if wi.fields['f'] == 2
360
+ end
361
+
362
+ #noisy
363
+
364
+ wfid = @engine.launch(pdef)
365
+ wait_for(wfid)
366
+
367
+ assert_equal %w[ . 1 2 a b ], @tracer.to_a.sort
368
+ end
369
+
370
+ def test_union_merge_type
371
+
372
+ pdef = Ruote.process_definition :name => 'test' do
373
+ concurrent_iterator :on_value => (1..2).to_a, :merge_type => 'union' do
374
+ alpha
375
+ end
376
+ end
377
+
378
+ @engine.register_participant :alpha do |workitem|
379
+ workitem.fields['a'] = [ 'x' ]
380
+ end
381
+
382
+ #@engine.noisy = true
383
+
384
+ wfid = @engine.launch(pdef)
385
+ r = @engine.wait_for(wfid)
386
+
387
+ assert_equal %w[ x x ], r['workitem']['fields']['a']
388
+ end
389
+
390
+ protected
391
+
392
+ def register_catchall_participant
393
+
394
+ @subs = []
395
+ subs = @subs
396
+ @engine.context.instance_eval do
397
+ @subs = subs
398
+ end
399
+
400
+ @engine.register_participant '.*' do |workitem|
401
+
402
+ @subs << workitem.fei.subid
403
+
404
+ @tracer << [
405
+ workitem.participant_name, workitem.fei.expid
406
+ ].join('/') + "\n"
407
+ end
408
+ end
409
+ end
410
+