ruote 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (305) hide show
  1. data/CHANGELOG.txt +166 -1
  2. data/CREDITS.txt +36 -17
  3. data/LICENSE.txt +1 -1
  4. data/README.rdoc +1 -7
  5. data/Rakefile +38 -29
  6. data/TODO.txt +93 -52
  7. data/lib/ruote-fs.rb +3 -0
  8. data/lib/ruote.rb +5 -1
  9. data/lib/ruote/context.rb +140 -35
  10. data/lib/ruote/dashboard.rb +1247 -0
  11. data/lib/ruote/{engine → dboard}/process_error.rb +22 -2
  12. data/lib/ruote/dboard/process_status.rb +587 -0
  13. data/lib/ruote/engine.rb +6 -871
  14. data/lib/ruote/exp/command.rb +7 -2
  15. data/lib/ruote/exp/commanded.rb +2 -2
  16. data/lib/ruote/exp/condition.rb +38 -13
  17. data/lib/ruote/exp/fe_add_branches.rb +1 -1
  18. data/lib/ruote/exp/fe_apply.rb +1 -1
  19. data/lib/ruote/exp/fe_await.rb +357 -0
  20. data/lib/ruote/exp/fe_cancel_process.rb +17 -3
  21. data/lib/ruote/exp/fe_command.rb +8 -4
  22. data/lib/ruote/exp/fe_concurrence.rb +218 -18
  23. data/lib/ruote/exp/fe_concurrent_iterator.rb +71 -10
  24. data/lib/ruote/exp/fe_cron.rb +3 -10
  25. data/lib/ruote/exp/fe_cursor.rb +14 -4
  26. data/lib/ruote/exp/fe_define.rb +3 -1
  27. data/lib/ruote/exp/fe_echo.rb +1 -1
  28. data/lib/ruote/exp/fe_equals.rb +1 -1
  29. data/lib/ruote/exp/fe_error.rb +1 -1
  30. data/lib/ruote/exp/fe_filter.rb +163 -4
  31. data/lib/ruote/exp/fe_forget.rb +21 -4
  32. data/lib/ruote/exp/fe_given.rb +1 -1
  33. data/lib/ruote/exp/fe_if.rb +1 -1
  34. data/lib/ruote/exp/fe_inc.rb +102 -35
  35. data/lib/ruote/exp/fe_iterator.rb +47 -12
  36. data/lib/ruote/exp/fe_listen.rb +96 -11
  37. data/lib/ruote/exp/fe_lose.rb +31 -4
  38. data/lib/ruote/exp/fe_noop.rb +1 -1
  39. data/lib/ruote/exp/fe_on_error.rb +109 -0
  40. data/lib/ruote/exp/fe_once.rb +10 -19
  41. data/lib/ruote/exp/fe_participant.rb +90 -28
  42. data/lib/ruote/exp/fe_read.rb +69 -0
  43. data/lib/ruote/exp/fe_redo.rb +3 -2
  44. data/lib/ruote/exp/fe_ref.rb +57 -27
  45. data/lib/ruote/exp/fe_registerp.rb +1 -3
  46. data/lib/ruote/exp/fe_reserve.rb +1 -1
  47. data/lib/ruote/exp/fe_restore.rb +6 -6
  48. data/lib/ruote/exp/fe_save.rb +12 -19
  49. data/lib/ruote/exp/fe_sequence.rb +38 -2
  50. data/lib/ruote/exp/fe_set.rb +143 -40
  51. data/lib/ruote/exp/{fe_let.rb → fe_stall.rb} +7 -38
  52. data/lib/ruote/exp/fe_subprocess.rb +8 -2
  53. data/lib/ruote/exp/fe_that.rb +1 -1
  54. data/lib/ruote/exp/fe_undo.rb +40 -4
  55. data/lib/ruote/exp/fe_unregisterp.rb +1 -3
  56. data/lib/ruote/exp/fe_wait.rb +12 -25
  57. data/lib/ruote/exp/{flowexpression.rb → flow_expression.rb} +375 -229
  58. data/lib/ruote/exp/iterator.rb +2 -2
  59. data/lib/ruote/exp/merge.rb +78 -17
  60. data/lib/ruote/exp/ro_attributes.rb +46 -36
  61. data/lib/ruote/exp/ro_filters.rb +34 -8
  62. data/lib/ruote/exp/ro_on_x.rb +431 -0
  63. data/lib/ruote/exp/ro_persist.rb +19 -7
  64. data/lib/ruote/exp/ro_timers.rb +123 -0
  65. data/lib/ruote/exp/ro_variables.rb +90 -29
  66. data/lib/ruote/fei.rb +57 -3
  67. data/lib/ruote/fs.rb +3 -0
  68. data/lib/ruote/id/mnemo_wfid_generator.rb +30 -7
  69. data/lib/ruote/id/wfid_generator.rb +17 -38
  70. data/lib/ruote/log/default_history.rb +23 -9
  71. data/lib/ruote/log/fancy_printing.rb +265 -0
  72. data/lib/ruote/log/storage_history.rb +23 -13
  73. data/lib/ruote/log/wait_logger.rb +224 -17
  74. data/lib/ruote/observer.rb +82 -0
  75. data/lib/ruote/part/block_participant.rb +65 -28
  76. data/lib/ruote/part/code_participant.rb +81 -0
  77. data/lib/ruote/part/engine_participant.rb +7 -2
  78. data/lib/ruote/part/local_participant.rb +221 -21
  79. data/lib/ruote/part/no_op_participant.rb +1 -1
  80. data/lib/ruote/part/null_participant.rb +1 -1
  81. data/lib/ruote/part/participant.rb +50 -0
  82. data/lib/ruote/part/rev_participant.rb +178 -0
  83. data/lib/ruote/part/smtp_participant.rb +2 -2
  84. data/lib/ruote/part/storage_participant.rb +228 -60
  85. data/lib/ruote/part/template.rb +1 -1
  86. data/lib/ruote/participant.rb +2 -0
  87. data/lib/ruote/reader.rb +205 -68
  88. data/lib/ruote/reader/json.rb +49 -0
  89. data/lib/ruote/reader/radial.rb +303 -0
  90. data/lib/ruote/reader/ruby_dsl.rb +44 -9
  91. data/lib/ruote/reader/xml.rb +11 -8
  92. data/lib/ruote/receiver/base.rb +98 -45
  93. data/lib/ruote/storage/base.rb +104 -35
  94. data/lib/ruote/storage/composite_storage.rb +50 -60
  95. data/lib/ruote/storage/fs_storage.rb +25 -34
  96. data/lib/ruote/storage/hash_storage.rb +38 -36
  97. data/lib/ruote/svc/dispatch_pool.rb +104 -35
  98. data/lib/ruote/svc/dollar_sub.rb +10 -8
  99. data/lib/ruote/svc/error_handler.rb +108 -52
  100. data/lib/ruote/svc/expression_map.rb +3 -3
  101. data/lib/ruote/svc/participant_list.rb +160 -55
  102. data/lib/ruote/svc/tracker.rb +31 -31
  103. data/lib/ruote/svc/treechecker.rb +28 -16
  104. data/lib/ruote/tree_dot.rb +1 -1
  105. data/lib/ruote/util/deep.rb +143 -0
  106. data/lib/ruote/util/filter.rb +125 -18
  107. data/lib/ruote/util/hashdot.rb +15 -13
  108. data/lib/ruote/util/look.rb +1 -1
  109. data/lib/ruote/util/lookup.rb +60 -22
  110. data/lib/ruote/util/misc.rb +63 -18
  111. data/lib/ruote/util/mpatch.rb +53 -0
  112. data/lib/ruote/util/ometa.rb +1 -2
  113. data/lib/ruote/util/process_observer.rb +177 -0
  114. data/lib/ruote/util/subprocess.rb +1 -1
  115. data/lib/ruote/util/time.rb +2 -2
  116. data/lib/ruote/util/tree.rb +64 -2
  117. data/lib/ruote/version.rb +3 -2
  118. data/lib/ruote/worker.rb +421 -92
  119. data/lib/ruote/workitem.rb +157 -22
  120. data/ruote.gemspec +15 -9
  121. data/test/bm/ci.rb +0 -2
  122. data/test/bm/ici.rb +0 -2
  123. data/test/bm/load_26c.rb +0 -3
  124. data/test/bm/mega.rb +0 -2
  125. data/test/functional/base.rb +57 -43
  126. data/test/functional/concurrent_base.rb +16 -13
  127. data/test/functional/ct_0_concurrence.rb +7 -11
  128. data/test/functional/ct_1_iterator.rb +9 -11
  129. data/test/functional/ct_2_cancel.rb +28 -17
  130. data/test/functional/eft_0_flow_expression.rb +35 -0
  131. data/test/functional/eft_10_cancel_process.rb +1 -1
  132. data/test/functional/eft_11_wait.rb +13 -13
  133. data/test/functional/eft_12_listen.rb +199 -66
  134. data/test/functional/eft_13_iterator.rb +95 -29
  135. data/test/functional/eft_14_cursor.rb +74 -24
  136. data/test/functional/eft_15_loop.rb +7 -7
  137. data/test/functional/eft_16_if.rb +1 -1
  138. data/test/functional/eft_17_equals.rb +1 -1
  139. data/test/functional/eft_18_concurrent_iterator.rb +156 -68
  140. data/test/functional/eft_19_reserve.rb +15 -15
  141. data/test/functional/eft_1_echo.rb +1 -1
  142. data/test/functional/eft_20_save.rb +51 -9
  143. data/test/functional/eft_21_restore.rb +1 -1
  144. data/test/functional/eft_22_noop.rb +1 -1
  145. data/test/functional/eft_23_apply.rb +1 -1
  146. data/test/functional/eft_24_add_branches.rb +7 -8
  147. data/test/functional/eft_25_command.rb +1 -1
  148. data/test/functional/eft_26_error.rb +11 -11
  149. data/test/functional/eft_27_inc.rb +111 -67
  150. data/test/functional/eft_28_once.rb +16 -16
  151. data/test/functional/eft_29_cron.rb +9 -9
  152. data/test/functional/eft_2_sequence.rb +23 -4
  153. data/test/functional/eft_30_ref.rb +36 -24
  154. data/test/functional/eft_31_registerp.rb +24 -24
  155. data/test/functional/eft_32_lose.rb +46 -20
  156. data/test/functional/eft_34_given.rb +1 -1
  157. data/test/functional/eft_35_filter.rb +161 -7
  158. data/test/functional/eft_36_read.rb +97 -0
  159. data/test/functional/{eft_0_process_definition.rb → eft_37_process_definition.rb} +4 -4
  160. data/test/functional/eft_38_on_error.rb +195 -0
  161. data/test/functional/eft_39_stall.rb +35 -0
  162. data/test/functional/eft_3_participant.rb +77 -22
  163. data/test/functional/eft_40_await.rb +297 -0
  164. data/test/functional/eft_4_set.rb +110 -11
  165. data/test/functional/eft_5_subprocess.rb +27 -5
  166. data/test/functional/eft_6_concurrence.rb +299 -60
  167. data/test/functional/eft_7_forget.rb +24 -22
  168. data/test/functional/eft_8_undo.rb +52 -15
  169. data/test/functional/eft_9_redo.rb +18 -20
  170. data/test/functional/ft_0_worker.rb +122 -13
  171. data/test/functional/ft_10_dollar.rb +77 -16
  172. data/test/functional/ft_11_recursion.rb +9 -9
  173. data/test/functional/ft_12_launchitem.rb +7 -9
  174. data/test/functional/ft_13_variables.rb +125 -22
  175. data/test/functional/ft_14_re_apply.rb +112 -56
  176. data/test/functional/ft_15_timeout.rb +64 -33
  177. data/test/functional/ft_16_participant_params.rb +59 -6
  178. data/test/functional/ft_17_conditional.rb +68 -2
  179. data/test/functional/ft_18_kill.rb +48 -30
  180. data/test/functional/ft_19_participant_code.rb +67 -0
  181. data/test/functional/ft_1_process_status.rb +222 -150
  182. data/test/functional/ft_20_storage_participant.rb +445 -44
  183. data/test/functional/ft_21_forget.rb +21 -26
  184. data/test/functional/ft_22_process_definitions.rb +8 -6
  185. data/test/functional/ft_23_load_defs.rb +29 -5
  186. data/test/functional/ft_24_block_participant.rb +199 -20
  187. data/test/functional/ft_25_receiver.rb +98 -46
  188. data/test/functional/ft_26_participant_rtimeout.rb +34 -26
  189. data/test/functional/ft_27_var_indirection.rb +40 -5
  190. data/test/functional/ft_28_null_noop_participants.rb +5 -5
  191. data/test/functional/ft_29_part_template.rb +2 -2
  192. data/test/functional/ft_2_errors.rb +106 -74
  193. data/test/functional/ft_30_smtp_participant.rb +7 -7
  194. data/test/functional/ft_31_part_blocking.rb +11 -11
  195. data/test/functional/ft_32_scope.rb +50 -0
  196. data/test/functional/ft_33_participant_subprocess_priority.rb +3 -3
  197. data/test/functional/ft_34_cursor_rewind.rb +14 -14
  198. data/test/functional/ft_35_add_service.rb +67 -9
  199. data/test/functional/ft_36_storage_history.rb +92 -24
  200. data/test/functional/ft_37_default_history.rb +35 -23
  201. data/test/functional/ft_38_participant_more.rb +189 -32
  202. data/test/functional/ft_39_wait_for.rb +25 -25
  203. data/test/functional/ft_3_participant_registration.rb +235 -107
  204. data/test/functional/ft_40_wait_logger.rb +105 -18
  205. data/test/functional/ft_41_participants.rb +13 -12
  206. data/test/functional/ft_42_storage_copy.rb +12 -12
  207. data/test/functional/ft_43_participant_on_reply.rb +85 -11
  208. data/test/functional/ft_44_var_participant.rb +5 -5
  209. data/test/functional/ft_45_participant_accept.rb +3 -3
  210. data/test/functional/ft_46_launch_single.rb +17 -17
  211. data/test/functional/ft_47_wfids.rb +41 -0
  212. data/test/functional/ft_48_lose.rb +19 -25
  213. data/test/functional/ft_49_engine_on_error.rb +54 -70
  214. data/test/functional/ft_4_cancel.rb +84 -26
  215. data/test/functional/ft_50_engine_config.rb +4 -4
  216. data/test/functional/ft_51_misc.rb +12 -12
  217. data/test/functional/ft_52_case.rb +17 -17
  218. data/test/functional/ft_53_engine_on_terminate.rb +18 -21
  219. data/test/functional/ft_54_patterns.rb +18 -16
  220. data/test/functional/ft_55_engine_participant.rb +55 -55
  221. data/test/functional/ft_56_filter_attribute.rb +90 -52
  222. data/test/functional/ft_57_rev_participant.rb +252 -0
  223. data/test/functional/ft_58_workitem.rb +150 -0
  224. data/test/functional/ft_59_pause.rb +329 -0
  225. data/test/functional/ft_5_on_error.rb +430 -77
  226. data/test/functional/ft_60_code_participant.rb +65 -0
  227. data/test/functional/ft_61_trailing_fields.rb +34 -0
  228. data/test/functional/ft_62_exp_name_and_dollar_substitution.rb +35 -0
  229. data/test/functional/ft_63_participants_221.rb +458 -0
  230. data/test/functional/ft_64_stash.rb +41 -0
  231. data/test/functional/ft_65_timers.rb +313 -0
  232. data/test/functional/ft_66_flank.rb +133 -0
  233. data/test/functional/ft_67_radial_misc.rb +34 -0
  234. data/test/functional/ft_68_reput.rb +72 -0
  235. data/test/functional/ft_69_worker_info.rb +56 -0
  236. data/test/functional/ft_6_on_cancel.rb +189 -36
  237. data/test/functional/ft_70_take_and_discard_attributes.rb +94 -0
  238. data/test/functional/ft_71_retries.rb +144 -0
  239. data/test/functional/ft_72_on_terminate.rb +60 -0
  240. data/test/functional/ft_73_raise_msg.rb +107 -0
  241. data/test/functional/ft_74_respark.rb +106 -0
  242. data/test/functional/ft_75_context.rb +66 -0
  243. data/test/functional/ft_76_observer.rb +53 -0
  244. data/test/functional/ft_77_process_observer.rb +157 -0
  245. data/test/functional/ft_78_part_participant.rb +37 -0
  246. data/test/functional/ft_7_tags.rb +238 -50
  247. data/test/functional/ft_8_participant_consumption.rb +27 -21
  248. data/test/functional/ft_9_subprocesses.rb +48 -18
  249. data/test/functional/restart_base.rb +4 -6
  250. data/test/functional/rt_0_wait.rb +10 -10
  251. data/test/functional/rt_1_listen.rb +6 -6
  252. data/test/functional/rt_2_errors.rb +12 -12
  253. data/test/functional/rt_3_once.rb +17 -12
  254. data/test/functional/rt_4_cron.rb +17 -17
  255. data/test/functional/rt_5_timeout.rb +13 -13
  256. data/test/functional/signals.rb +103 -0
  257. data/test/functional/storage.rb +730 -0
  258. data/test/functional/storage_helper.rb +48 -35
  259. data/test/functional/test.rb +6 -2
  260. data/test/misc/idle.rb +21 -0
  261. data/test/misc/light.rb +29 -0
  262. data/test/path_helper.rb +1 -1
  263. data/test/test.rb +2 -5
  264. data/test/test_helper.rb +13 -0
  265. data/test/unit/test.rb +1 -4
  266. data/test/unit/ut_0_ruby_reader.rb +25 -9
  267. data/test/unit/ut_10_participants.rb +47 -0
  268. data/test/unit/ut_11_lookup.rb +59 -2
  269. data/test/unit/ut_12_wait_logger.rb +123 -0
  270. data/test/unit/ut_14_is_uri.rb +1 -1
  271. data/test/unit/ut_15_util.rb +1 -1
  272. data/test/unit/ut_16_reader.rb +136 -14
  273. data/test/unit/ut_17_merge.rb +155 -0
  274. data/test/unit/ut_19_part_template.rb +1 -1
  275. data/test/unit/ut_1_fei.rb +11 -2
  276. data/test/unit/ut_20_composite_storage.rb +27 -1
  277. data/test/unit/{ut_21_participant_list.rb → ut_21_svc_participant_list.rb} +2 -3
  278. data/test/unit/ut_22_filter.rb +231 -10
  279. data/test/unit/ut_23_svc_tracker.rb +48 -0
  280. data/test/unit/ut_24_radial_reader.rb +458 -0
  281. data/test/unit/ut_25_process_status.rb +143 -0
  282. data/test/unit/ut_26_deep.rb +131 -0
  283. data/test/unit/ut_2_dashboard.rb +114 -0
  284. data/test/unit/ut_3_worker.rb +54 -0
  285. data/test/unit/ut_4_expmap.rb +1 -1
  286. data/test/unit/ut_5_tree.rb +23 -23
  287. data/test/unit/ut_6_condition.rb +71 -29
  288. data/test/unit/ut_7_workitem.rb +18 -4
  289. data/test/unit/ut_8_tree_to_dot.rb +1 -1
  290. data/test/unit/ut_9_xml_reader.rb +1 -1
  291. metadata +142 -63
  292. data/jruby_issue.txt +0 -32
  293. data/lib/ruote/engine/process_status.rb +0 -403
  294. data/lib/ruote/log/pretty.rb +0 -165
  295. data/lib/ruote/log/test_logger.rb +0 -204
  296. data/lib/ruote/util/serializer.rb +0 -103
  297. data/phil.txt +0 -14
  298. data/test/functional/eft_33_let.rb +0 -31
  299. data/test/functional/ft_19_alias.rb +0 -33
  300. data/test/functional/ft_47_wfid_generator.rb +0 -54
  301. data/test/unit/storage.rb +0 -403
  302. data/test/unit/storages.rb +0 -37
  303. data/test/unit/ut_13_serializer.rb +0 -65
  304. data/test/unit/ut_18_engine.rb +0 -47
  305. data/test/unit/ut_3_wait_logger.rb +0 -39
@@ -5,7 +5,7 @@
5
5
  # Wed Jul 1 09:51:30 JST 2009
6
6
  #
7
7
 
8
- require File.join(File.dirname(__FILE__), 'base')
8
+ require File.expand_path('../base', __FILE__)
9
9
 
10
10
 
11
11
  class FtParticipantParamsTest < Test::Unit::TestCase
@@ -21,25 +21,78 @@ class FtParticipantParamsTest < Test::Unit::TestCase
21
21
  end
22
22
  end
23
23
 
24
- alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
24
+ alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
25
25
 
26
26
  #noisy
27
27
 
28
- wfid = @engine.launch(pdef)
28
+ wfid = @dashboard.launch(pdef)
29
29
 
30
30
  wait_for(:alpha)
31
31
  assert_equal({ 'ref' => 'alpha' }, alpha.first.fields['params'])
32
- alpha.reply(alpha.first)
32
+ alpha.proceed(alpha.first)
33
33
 
34
34
  wait_for(:alpha)
35
35
  assert_equal('buy groceries', alpha.first.fields['params']['activity'])
36
- alpha.reply(alpha.first)
36
+ alpha.proceed(alpha.first)
37
37
 
38
38
  wait_for(:alpha)
39
39
  assert_equal({ 'ref' => 'alpha' }, alpha.first.fields['params'])
40
- alpha.reply(alpha.first)
40
+ alpha.proceed(alpha.first)
41
41
 
42
42
  wait_for(wfid)
43
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
+ @dashboard.register { catchall }
53
+
54
+ #@dashboard.noisy = true
55
+
56
+ @dashboard.launch(pdef)
57
+
58
+ @dashboard.wait_for(:alpha)
59
+ workitem = @dashboard.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
+ @dashboard.storage_participant.proceed(workitem)
67
+
68
+ @dashboard.wait_for(:bravo)
69
+ workitem = @dashboard.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
+ @dashboard.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
+ #@dashboard.noisy = true
88
+
89
+ wfid = @dashboard.launch(pdef, 'theme' => 'mozart')
90
+ @dashboard.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
44
97
  end
45
98
 
@@ -5,7 +5,7 @@
5
5
  # Fri Jul 3 19:46:22 JST 2009
6
6
  #
7
7
 
8
- require File.join(File.dirname(__FILE__), 'base')
8
+ require File.expand_path('../base', __FILE__)
9
9
 
10
10
 
11
11
  class FtConditionalTest < Test::Unit::TestCase
@@ -80,6 +80,8 @@ class FtConditionalTest < Test::Unit::TestCase
80
80
 
81
81
  set 'f:t' => true
82
82
  set 'f:f' => false
83
+ set 'f:name' => 'n'
84
+ set 'f:city' => 'c'
83
85
 
84
86
  sequence do
85
87
 
@@ -90,10 +92,74 @@ class FtConditionalTest < Test::Unit::TestCase
90
92
  echo 'c', :if => '${f:t} and ${f:f}'
91
93
  echo 'd', :if => '${f:t} and (${f:t} or ${f:f})'
92
94
  echo 'e', :if => '${f:t} and (${f:t} and ${f:f})'
95
+ echo 'f', :if => '${name} == n and ${city} == c'
93
96
  end
94
97
  end
95
98
 
96
- assert_trace(%w[ true/false a b d ], pdef)
99
+ assert_trace(%w[ true/false a b d f ], pdef)
100
+ end
101
+
102
+ def test_if_booleans
103
+
104
+ pdef = Ruote.define do
105
+
106
+ echo 'a', :if => true
107
+ echo '.'
108
+ echo 'b', :if => 'true'
109
+ echo '.'
110
+ echo 'c', :if => false
111
+ echo '.'
112
+ echo 'd', :if => 'false'
113
+ end
114
+
115
+ wfid = @dashboard.launch(pdef)
116
+ r = @dashboard.wait_for(wfid)
117
+
118
+ assert_equal 'terminated', r['action']
119
+ assert_equal 'a.b..', @tracer.to_a.join
120
+ end
121
+
122
+ def test_unless_booleans
123
+
124
+ pdef = Ruote.define do
125
+
126
+ echo 'a', :unless => true
127
+ echo '.'
128
+ echo 'b', :unless => 'true'
129
+ echo '.'
130
+ echo 'c', :unless => false
131
+ echo '.'
132
+ echo 'd', :unless => 'false'
133
+ end
134
+
135
+ wfid = @dashboard.launch(pdef)
136
+ r = @dashboard.wait_for(wfid)
137
+
138
+ assert_equal 'terminated', r['action']
139
+ assert_equal '..c.d', @tracer.to_a.join
140
+ end
141
+
142
+ def test_with_numbers
143
+
144
+ pdef = Ruote.define do
145
+
146
+ set 'commission' => 2.310000
147
+ set 'scommission' => '2.310000'
148
+
149
+ echo 'a', :if => '${f:commission} > 0'
150
+ echo '.'
151
+ echo 'b', :unless => '${f:commission} > 0'
152
+ echo '.'
153
+ echo 'c', :if => '${f:scommission} > 0'
154
+ echo '.'
155
+ echo 'c', :unless => '${f:scommission} > 0'
156
+ end
157
+
158
+ wfid = @dashboard.launch(pdef)
159
+ r = @dashboard.wait_for(wfid)
160
+
161
+ assert_equal 'terminated', r['action']
162
+ assert_equal 'a..c.', @tracer.to_a.join
97
163
  end
98
164
  end
99
165
 
@@ -5,7 +5,7 @@
5
5
  # Sun Jul 5 22:56:06 JST 2009
6
6
  #
7
7
 
8
- require File.join(File.dirname(__FILE__), 'base')
8
+ require File.expand_path('../base', __FILE__)
9
9
 
10
10
 
11
11
  class FtKillTest < Test::Unit::TestCase
@@ -17,23 +17,36 @@ class FtKillTest < Test::Unit::TestCase
17
17
  alpha
18
18
  end
19
19
 
20
- alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
20
+ alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
21
21
 
22
22
  #noisy
23
23
 
24
- wfid = @engine.launch(pdef)
24
+ wfid = @dashboard.launch(pdef)
25
25
  wait_for(:alpha)
26
26
 
27
- @engine.kill_process(wfid)
27
+ @dashboard.kill_process(wfid)
28
28
 
29
29
  wait_for(wfid)
30
- ps = @engine.process(wfid)
30
+ ps = @dashboard.process(wfid)
31
31
 
32
32
  assert_nil ps
33
33
  assert_equal 0, alpha.size
34
34
 
35
35
  assert_equal(
36
- 1, logger.log.select { |e| e['action'] == 'kill_process' }.size)
36
+ 1,
37
+ logger.log.select { |e|
38
+ e['action'] == 'cancel_process' &&
39
+ e['flavour'] == 'kill'
40
+ }.size)
41
+ end
42
+
43
+ def test_kill_process_with_source
44
+
45
+ @dashboard.kill('20111121-nada', :source => 'y')
46
+
47
+ @dashboard.wait_for(1)
48
+
49
+ assert_equal 'y', @dashboard.context.logger.log.first['source']
37
50
  end
38
51
 
39
52
  def test_kill_does_not_trigger_on_cancel
@@ -44,13 +57,13 @@ class FtKillTest < Test::Unit::TestCase
44
57
  end
45
58
  end
46
59
 
47
- @engine.register_participant :alpha, Ruote::StorageParticipant
48
- sto = @engine.register_participant :catcher, Ruote::StorageParticipant
60
+ @dashboard.register_participant :alpha, Ruote::StorageParticipant
61
+ sto = @dashboard.register_participant :catcher, Ruote::StorageParticipant
49
62
 
50
- wfid = @engine.launch(pdef)
63
+ wfid = @dashboard.launch(pdef)
51
64
  wait_for(:alpha)
52
65
 
53
- @engine.kill_process(wfid)
66
+ @dashboard.kill_process(wfid)
54
67
 
55
68
  wait_for(wfid)
56
69
 
@@ -65,13 +78,13 @@ class FtKillTest < Test::Unit::TestCase
65
78
  end
66
79
  end
67
80
 
68
- @engine.register_participant :alpha, Ruote::StorageParticipant
69
- sto = @engine.register_participant :catcher, Ruote::StorageParticipant
81
+ @dashboard.register_participant :alpha, Ruote::StorageParticipant
82
+ sto = @dashboard.register_participant :catcher, Ruote::StorageParticipant
70
83
 
71
- wfid = @engine.launch(pdef)
84
+ wfid = @dashboard.launch(pdef)
72
85
  wait_for(:alpha)
73
86
 
74
- @engine.kill_expression(sto.first.fei)
87
+ @dashboard.kill_expression(sto.first.fei)
75
88
 
76
89
  wait_for(wfid)
77
90
 
@@ -84,21 +97,26 @@ class FtKillTest < Test::Unit::TestCase
84
97
  alpha
85
98
  end
86
99
 
87
- @engine.register_participant :alpha, Ruote::NullParticipant
100
+ @dashboard.register_participant :alpha, Ruote::NullParticipant
88
101
 
89
102
  #noisy
90
103
 
91
- wfid = @engine.launch(pdef)
104
+ wfid = @dashboard.launch(pdef)
92
105
 
93
- @engine.wait_for(:alpha)
106
+ @dashboard.wait_for(:alpha)
94
107
 
95
- @engine.kill(wfid)
108
+ @dashboard.kill(wfid)
96
109
 
97
- @engine.wait_for(wfid)
110
+ @dashboard.wait_for(wfid)
98
111
 
99
- assert_nil @engine.process(wfid)
112
+ assert_nil @dashboard.process(wfid)
100
113
 
101
- assert_equal 1, logger.log.select { |e| e['action'] == 'kill_process' }.size
114
+ assert_equal(
115
+ 1,
116
+ logger.log.select { |e|
117
+ e['action'] == 'cancel_process' &&
118
+ e['flavour'] == 'kill'
119
+ }.size)
102
120
  end
103
121
 
104
122
  def test_kill__process
@@ -112,23 +130,23 @@ class FtKillTest < Test::Unit::TestCase
112
130
  echo '2'
113
131
  end
114
132
 
115
- @engine.register_participant :alpha, Ruote::NullParticipant
133
+ @dashboard.register_participant :alpha, Ruote::NullParticipant
116
134
 
117
- wfid = @engine.launch(pdef)
135
+ wfid = @dashboard.launch(pdef)
118
136
 
119
- r = @engine.wait_for(:alpha)
137
+ r = @dashboard.wait_for(:alpha)
120
138
 
121
- @engine.kill(r['fei']) # fei as a Hash
139
+ @dashboard.kill(r['fei']) # fei as a Hash
122
140
 
123
- r = @engine.wait_for(:alpha)
141
+ r = @dashboard.wait_for(:alpha)
124
142
 
125
- @engine.kill(Ruote.sid(r['fei'])) # fei as a String
143
+ @dashboard.kill(Ruote.sid(r['fei'])) # fei as a String
126
144
 
127
- r = @engine.wait_for(:alpha)
145
+ r = @dashboard.wait_for(:alpha)
128
146
 
129
- @engine.kill(Ruote::Workitem.new(r['workitem'])) # fei as workitem
147
+ @dashboard.kill(Ruote::Workitem.new(r['workitem'])) # fei as workitem
130
148
 
131
- @engine.wait_for(wfid)
149
+ @dashboard.wait_for(wfid)
132
150
 
133
151
  assert_equal %w[ 0 1 2 ], @tracer.to_a
134
152
 
@@ -0,0 +1,67 @@
1
+
2
+ #
3
+ # testing ruote
4
+ #
5
+ # Fri Apr 22 15:44:38 JST 2011
6
+ #
7
+ # Singapore
8
+ #
9
+
10
+ require File.expand_path('../base', __FILE__)
11
+
12
+
13
+ class FtParticipantCodeTest < Test::Unit::TestCase
14
+ include FunctionalBase
15
+
16
+ def test_block_participant
17
+
18
+ @dashboard.context['participant_in_variable_enabled'] = true
19
+
20
+ pdef = Ruote.process_definition :name => 'def0' do
21
+
22
+ set 'v:alpha' => {
23
+ 'on_workitem' => lambda { |wi|
24
+ wi.fields['alpha'] = wi.participant_name
25
+ wi.fields['x'] = 0
26
+ }
27
+ }
28
+
29
+ alpha
30
+ end
31
+
32
+ wfid = @dashboard.launch(pdef)
33
+
34
+ r = @dashboard.wait_for(wfid)
35
+
36
+ assert_equal(
37
+ { 'alpha' => 'alpha', 'x' => 0, '__result__' => 0 },
38
+ r['workitem']['fields'])
39
+ end
40
+
41
+ def test_code_participant
42
+
43
+ @dashboard.context['participant_in_variable_enabled'] = true
44
+
45
+ pdef = Ruote.process_definition do
46
+
47
+ set 'v:alpha' => %{
48
+ def consume(workitem)
49
+ workitem.fields['x'] = 0
50
+ workitem.fields['alpha'] = workitem.participant_name
51
+ reply_to_engine(workitem)
52
+ end
53
+ }
54
+
55
+ alpha
56
+ end
57
+
58
+ wfid = @dashboard.launch(pdef)
59
+
60
+ r = @dashboard.wait_for(wfid)
61
+
62
+ assert_equal(
63
+ { 'x' => 0, 'alpha' => 'alpha' },
64
+ r['workitem']['fields'])
65
+ end
66
+ end
67
+
@@ -5,7 +5,7 @@
5
5
  # Fri May 15 09:51:28 JST 2009
6
6
  #
7
7
 
8
- require File.join(File.dirname(__FILE__), 'base')
8
+ require File.expand_path('../base', __FILE__)
9
9
 
10
10
  require 'ruote/participant'
11
11
 
@@ -19,15 +19,13 @@ class FtProcessStatusTest < Test::Unit::TestCase
19
19
  participant :ref => 'alpha'
20
20
  end
21
21
 
22
- #noisy
22
+ alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
23
23
 
24
- alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
25
-
26
- wfid = @engine.launch(pdef, :workitem => { 'kilroy' => 'was here' })
24
+ wfid = @dashboard.launch(pdef, :workitem => { 'kilroy' => 'was here' })
27
25
 
28
26
  wait_for(:alpha)
29
27
 
30
- ps = @engine.process(wfid)
28
+ ps = @dashboard.process(wfid)
31
29
 
32
30
  assert_equal 'my process', ps.definition_name
33
31
  assert_equal nil, ps.definition_revision
@@ -47,12 +45,12 @@ class FtProcessStatusTest < Test::Unit::TestCase
47
45
  end
48
46
  end
49
47
 
50
- alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
51
- wfid = @engine.launch(pdef, :workitem => { 'kilroy' => 'was here' })
48
+ alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
49
+ wfid = @dashboard.launch(pdef, :workitem => { 'kilroy' => 'was here' })
52
50
 
53
51
  wait_for(:alpha)
54
52
 
55
- ps = @engine.process(wfid)
53
+ ps = @dashboard.process(wfid)
56
54
 
57
55
  assert_equal 'my process', ps.definition_name
58
56
 
@@ -67,21 +65,21 @@ class FtProcessStatusTest < Test::Unit::TestCase
67
65
  nada
68
66
  end
69
67
 
70
- wfid = @engine.launch(pdef)
68
+ wfid = @dashboard.launch(pdef)
71
69
  wait_for(wfid)
72
70
 
73
- errs = @engine.errors
71
+ errs = @dashboard.errors
74
72
 
75
73
  assert_equal 1, errs.size
76
74
 
77
75
  assert_equal wfid, errs.first.wfid
78
76
 
79
- err = @engine.errors(wfid)
77
+ err = @dashboard.errors(wfid)
80
78
 
81
79
  assert_equal 1, err.size
82
80
  assert_equal wfid, err.first.wfid
83
81
 
84
- assert_equal 1, @engine.errors(:count => true)
82
+ assert_equal 1, @dashboard.errors(:count => true)
85
83
  end
86
84
 
87
85
  def test_tree
@@ -93,12 +91,12 @@ class FtProcessStatusTest < Test::Unit::TestCase
93
91
  end
94
92
  end
95
93
 
96
- alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
97
- wfid = @engine.launch(pdef)
94
+ alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
95
+ wfid = @dashboard.launch(pdef)
98
96
 
99
97
  wait_for(:alpha)
100
98
 
101
- ps = @engine.process(wfid)
99
+ ps = @dashboard.process(wfid)
102
100
 
103
101
  assert_equal(
104
102
  ["define", {"my process"=>nil}, [
@@ -145,12 +143,12 @@ class FtProcessStatusTest < Test::Unit::TestCase
145
143
  end
146
144
  end
147
145
 
148
- alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
149
- wfid = @engine.launch(pdef)
146
+ alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
147
+ wfid = @dashboard.launch(pdef)
150
148
 
151
149
  wait_for(:alpha)
152
150
 
153
- ps = @engine.process(wfid)
151
+ ps = @dashboard.process(wfid)
154
152
 
155
153
  assert_equal(
156
154
  {"my process"=>["0", ["define", {"my process"=>nil}, [["define", {"sub0"=>nil}, [["echo", {"meh"=>nil}, []]]], ["participant", {"ref"=>"alpha"}, []]]]], "sub0"=>["0_0", ["define", {"sub0"=>nil}, [["echo", {"meh"=>nil}, []]]]]},
@@ -184,15 +182,13 @@ class FtProcessStatusTest < Test::Unit::TestCase
184
182
  end
185
183
  end
186
184
 
187
- alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
188
-
189
- #noisy
185
+ alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
190
186
 
191
- wfid = @engine.launch(pdef)
187
+ wfid = @dashboard.launch(pdef)
192
188
 
193
189
  wait_for(:alpha)
194
190
 
195
- ps = @engine.process(wfid)
191
+ ps = @dashboard.process(wfid)
196
192
 
197
193
  assert_equal(0, ps.variables['v0'])
198
194
  assert_equal(nil, ps.variables['v1'])
@@ -214,18 +210,17 @@ class FtProcessStatusTest < Test::Unit::TestCase
214
210
  end
215
211
  end
216
212
 
217
- alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
218
-
219
- #noisy
213
+ alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
220
214
 
221
- wfid = @engine.launch(pdef)
215
+ wfid = @dashboard.launch(pdef)
222
216
  wait_for(:alpha)
223
217
 
224
- ps = @engine.process(wfid)
218
+ ps = @dashboard.process(wfid)
225
219
 
226
- assert_equal %w[ main part ], ps.tags.keys.sort
220
+ assert_equal %w[ main main/part part ], ps.tags.keys.sort
221
+ assert_equal %w[ main main/part part ], ps.all_tags.keys.sort
227
222
 
228
- assert_equal 2, ps.all_tags.size
223
+ assert_equal 3, ps.all_tags.size
229
224
  assert_kind_of Array, ps.all_tags['main']
230
225
  assert_equal 1, ps.all_tags['main'].size
231
226
  end
@@ -243,16 +238,14 @@ class FtProcessStatusTest < Test::Unit::TestCase
243
238
  end
244
239
  end
245
240
 
246
- alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
241
+ alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
247
242
 
248
- #noisy
249
-
250
- wfid = @engine.launch(pdef)
243
+ wfid = @dashboard.launch(pdef)
251
244
  wait_for(:alpha)
252
245
 
253
- ps = @engine.process(wfid)
246
+ ps = @dashboard.process(wfid)
254
247
 
255
- assert_equal 1, ps.tags.size
248
+ assert_equal 2, ps.tags.size
256
249
  assert_equal 2, ps.all_tags['tag0'].size
257
250
  end
258
251
 
@@ -262,17 +255,15 @@ class FtProcessStatusTest < Test::Unit::TestCase
262
255
  participant :ref => 'alpha'
263
256
  end
264
257
 
265
- #noisy
266
-
267
- alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
258
+ alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
268
259
 
269
- wfid0 = @engine.launch(pdef)
270
- wfid1 = @engine.launch(pdef)
260
+ wfid0 = @dashboard.launch(pdef)
261
+ wfid1 = @dashboard.launch(pdef)
271
262
 
272
263
  wait_for(:alpha)
273
264
  wait_for(:alpha)
274
265
 
275
- ps = @engine.processes
266
+ ps = @dashboard.processes
276
267
 
277
268
  assert_equal 2, ps.size
278
269
  assert_equal [ wfid0, wfid1 ].sort, ps.collect { |e| e.wfid }.sort
@@ -284,23 +275,23 @@ class FtProcessStatusTest < Test::Unit::TestCase
284
275
 
285
276
  n = 3
286
277
 
287
- @engine.register_participant :alpha, Ruote::StorageParticipant
278
+ @dashboard.register_participant :alpha, Ruote::StorageParticipant
288
279
 
289
- n.times.collect { @engine.launch(Ruote.define { alpha }) }
280
+ n.times.collect { @dashboard.launch(Ruote.define { alpha }) }
290
281
 
291
- while @engine.storage_participant.size < n; sleep 0.100; end
282
+ while @dashboard.storage_participant.size < n; sleep 0.100; end
292
283
  sleep 0.100
293
284
 
294
- @engine.ps(@engine.storage_participant.first.wfid).expressions.each do |exp|
295
- @engine.storage.delete(exp.h)
285
+ @dashboard.ps(@dashboard.storage_participant.first.wfid).expressions.each do |exp|
286
+ @dashboard.storage.delete(exp.h)
296
287
  end
297
288
  # nuking all the expressions of a process instance
298
289
 
299
- assert_equal n - 1, @engine.processes.size
300
- assert_equal n, @engine.storage_participant.size
290
+ assert_equal n - 1, @dashboard.processes.size
291
+ assert_equal n, @dashboard.storage_participant.size
301
292
  # orphan workitem left in storage
302
293
 
303
- assert_equal 1, @engine.leftovers.size
294
+ assert_equal 1, @dashboard.leftovers.size
304
295
  end
305
296
 
306
297
  def test_left_overs
@@ -313,15 +304,15 @@ class FtProcessStatusTest < Test::Unit::TestCase
313
304
  { '_id' => '0!f!z', 'type' => 'schedules', 'fei' => { 'wfid' => 'z' },
314
305
  'at' => Ruote.time_to_utc_s(Time.now + 24 * 3600) }
315
306
  ].each do |doc|
316
- @engine.storage.put(doc)
307
+ @dashboard.storage.put(doc)
317
308
  end
318
309
 
319
310
  assert_equal(
320
311
  3,
321
- @engine.leftovers.size)
312
+ @dashboard.leftovers.size)
322
313
  assert_equal(
323
314
  %w[ workitems errors schedules ],
324
- @engine.leftovers.collect { |lo| lo['type'] })
315
+ @dashboard.leftovers.collect { |lo| lo['type'] })
325
316
  end
326
317
 
327
318
  def test_tree_rewrite
@@ -335,9 +326,9 @@ class FtProcessStatusTest < Test::Unit::TestCase
335
326
  delta
336
327
  end
337
328
 
338
- @engine.register_participant :alpha do |wi, fexp|
329
+ @dashboard.register_participant :alpha do |wi, fexp|
339
330
 
340
- @tracer << "a\n"
331
+ tracer << "a\n"
341
332
 
342
333
  parent = fexp.parent
343
334
  parent.update_tree
@@ -345,29 +336,27 @@ class FtProcessStatusTest < Test::Unit::TestCase
345
336
  parent.persist
346
337
  end
347
338
 
348
- @engine.register_participant :bravo do |wi, fexp|
349
- @tracer << "b\n"
339
+ @dashboard.register_participant :bravo do |wi, fexp|
340
+ tracer << "b\n"
350
341
  end
351
- @engine.register_participant :charly do |wi, fexp|
352
- @tracer << "c\n"
342
+ @dashboard.register_participant :charly do |wi, fexp|
343
+ tracer << "c\n"
353
344
  stash[:tree0] = fexp.context.engine.process(fexp.fei.wfid).current_tree
354
345
  end
355
- @engine.register_participant :delta do |wi, fexp|
356
- @tracer << "d\n"
346
+ @dashboard.register_participant :delta do |wi, fexp|
347
+ tracer << "d\n"
357
348
  stash[:tree1] = fexp.context.engine.process(fexp.fei.wfid).current_tree
358
349
  end
359
350
 
360
- #noisy
361
-
362
351
  assert_trace %w[ a c c d ], pdef
363
352
 
364
353
  assert_equal(
365
354
  ["define", {"name"=>"test"}, [["sequence", {}, [["alpha", {}, []], ["charly", {}, []], ["participant", {"ref"=>"charly"}, []]]], ["delta", {}, []]]],
366
- @engine.context.stash[:tree0])
355
+ @dashboard.context.stash[:tree0])
367
356
 
368
357
  assert_equal(
369
358
  ["define", {"name"=>"test"}, [["sequence", {}, [["alpha", {}, []], ["charly", {}, []], ["charly", {}, []]]], ["participant", {"ref"=>"delta"}, []]]],
370
- @engine.context.stash[:tree1])
359
+ @dashboard.context.stash[:tree1])
371
360
  end
372
361
 
373
362
  def test_when_on_cancel_subprocess
@@ -381,15 +370,13 @@ class FtProcessStatusTest < Test::Unit::TestCase
381
370
  end
382
371
  end
383
372
 
384
- alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
385
-
386
- #noisy
373
+ alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
387
374
 
388
- wfid = @engine.launch(pdef)
375
+ wfid = @dashboard.launch(pdef)
389
376
 
390
377
  wait_for(:alpha)
391
378
 
392
- @engine.cancel_process(wfid)
379
+ @dashboard.cancel_process(wfid)
393
380
 
394
381
  wait_for(:alpha)
395
382
  wait_for(1)
@@ -397,14 +384,14 @@ class FtProcessStatusTest < Test::Unit::TestCase
397
384
  assert_match wfid, alpha.first.fei.wfid
398
385
  assert_not_nil alpha.first.fei.subid
399
386
 
400
- assert_equal 0, @engine.process(wfid).errors.size
401
- assert_equal 4, @engine.process(wfid).expressions.size
387
+ assert_equal 0, @dashboard.process(wfid).errors.size
388
+ assert_equal 4, @dashboard.process(wfid).expressions.size
402
389
 
403
390
  assert_equal(
404
391
  ["define", {"name"=>"test"}, [
405
392
  ["define", {"sub0"=>nil}, [["alpha", {}, []]]],
406
393
  ["sequence", {"on_cancel"=>"sub0"}, [["alpha", {}, []]]]]],
407
- @engine.process(wfid).original_tree)
394
+ @dashboard.process(wfid).original_tree)
408
395
 
409
396
  assert_equal(
410
397
  ["define", {"name"=>"test"}, [
@@ -412,7 +399,7 @@ class FtProcessStatusTest < Test::Unit::TestCase
412
399
  ["participant", {"ref"=>"alpha"}, []]]],
413
400
  ["sequence", {"on_cancel"=>"sub0", "_triggered"=>"on_cancel"}, [
414
401
  ["alpha", {}, []]]]]],
415
- @engine.process(wfid).current_tree)
402
+ @dashboard.process(wfid).current_tree)
416
403
  end
417
404
 
418
405
  def test_fexp_to_h
@@ -421,15 +408,13 @@ class FtProcessStatusTest < Test::Unit::TestCase
421
408
  participant :ref => 'alpha'
422
409
  end
423
410
 
424
- #noisy
411
+ alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
425
412
 
426
- alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
427
-
428
- wfid = @engine.launch(pdef)
413
+ wfid = @dashboard.launch(pdef)
429
414
 
430
415
  wait_for(:alpha)
431
416
 
432
- ps = @engine.process(wfid)
417
+ ps = @dashboard.process(wfid)
433
418
 
434
419
  h = ps.expressions.find { |hf|
435
420
  hf.is_a?(Ruote::Exp::ParticipantExpression)
@@ -449,13 +434,13 @@ class FtProcessStatusTest < Test::Unit::TestCase
449
434
  end
450
435
  end
451
436
 
452
- alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
437
+ alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
453
438
 
454
- wfid = @engine.launch(pdef)
439
+ wfid = @dashboard.launch(pdef)
455
440
 
456
441
  wait_for(:alpha)
457
442
 
458
- ps = @engine.process(wfid)
443
+ ps = @dashboard.process(wfid)
459
444
 
460
445
  #puts
461
446
  #puts ps.to_dot
@@ -494,20 +479,20 @@ digraph "process wfid {
494
479
  bravo
495
480
  end
496
481
 
497
- @engine.register_participant '.+', Ruote::StorageParticipant
482
+ @dashboard.register_participant '.+', Ruote::StorageParticipant
498
483
 
499
- wfid = @engine.launch(pdef)
484
+ wfid = @dashboard.launch(pdef)
500
485
 
501
- @engine.wait_for(:alpha)
486
+ @dashboard.wait_for(:alpha)
502
487
 
503
- t0 = Time.parse(@engine.process(wfid).last_active)
488
+ t0 = Time.parse(@dashboard.process(wfid).last_active)
504
489
 
505
- sp = @engine.storage_participant
506
- sp.reply(sp.first)
490
+ sp = @dashboard.storage_participant
491
+ sp.proceed(sp.first)
507
492
 
508
- @engine.wait_for(:bravo)
493
+ @dashboard.wait_for(:bravo)
509
494
 
510
- t1 = Time.parse(@engine.process(wfid).last_active)
495
+ t1 = Time.parse(@dashboard.process(wfid).last_active)
511
496
 
512
497
  assert t1 > t0
513
498
  end
@@ -518,20 +503,20 @@ digraph "process wfid {
518
503
  alpha :task => 'clean car'
519
504
  end
520
505
 
521
- @engine.register_participant '.+', Ruote::StorageParticipant
506
+ @dashboard.register_participant '.+', Ruote::StorageParticipant
522
507
 
523
- wfid = @engine.launch(pdef)
524
- @engine.wait_for(:alpha)
508
+ wfid = @dashboard.launch(pdef)
509
+ @dashboard.wait_for(:alpha)
525
510
 
526
511
  assert_equal(
527
512
  [ [ 'alpha', { 'task' => 'clean car' } ] ],
528
- @engine.process(wfid).position.collect { |pos| pos[1..-1] })
513
+ @dashboard.process(wfid).position.collect { |pos| pos[1..-1] })
529
514
 
530
515
  # #position leverages #workitems
531
516
 
532
517
  assert_equal(
533
518
  [ [ wfid, 'alpha' ] ],
534
- @engine.process(wfid).workitems.collect { |wi|
519
+ @dashboard.process(wfid).workitems.collect { |wi|
535
520
  [ wi.fei.wfid, wi.participant_name ]
536
521
  })
537
522
  end
@@ -542,25 +527,25 @@ digraph "process wfid {
542
527
  participant
543
528
  end
544
529
 
545
- wfid = @engine.launch(pdef)
546
- @engine.wait_for(wfid)
530
+ wfid = @dashboard.launch(pdef)
531
+ @dashboard.wait_for(wfid)
547
532
 
548
- assert_equal 1, @engine.process(wfid).errors.size
533
+ assert_equal 1, @dashboard.process(wfid).errors.size
549
534
 
550
535
  assert_equal(
551
536
  [ [ nil,
552
537
  { 'error' => '#<ArgumentError: no participant name specified>' } ] ],
553
- @engine.process(wfid).position.collect { |pos| pos[1..-1] })
538
+ @dashboard.process(wfid).position.collect { |pos| pos[1..-1] })
554
539
  end
555
540
 
556
541
  def test_ps_with_stored_workitems
557
542
 
558
- @engine.register_participant '.+', Ruote::StorageParticipant
543
+ @dashboard.register_participant '.+', Ruote::StorageParticipant
559
544
 
560
- wfid = @engine.launch(Ruote.define { alpha })
561
- @engine.wait_for(:alpha)
545
+ wfid = @dashboard.launch(Ruote.define { alpha })
546
+ @dashboard.wait_for(:alpha)
562
547
 
563
- ps = @engine.process(wfid)
548
+ ps = @dashboard.process(wfid)
564
549
 
565
550
  assert_equal 1, ps.stored_workitems.size
566
551
  assert_equal Ruote::Workitem, ps.stored_workitems.first.class
@@ -568,37 +553,35 @@ digraph "process wfid {
568
553
 
569
554
  def test_ps_without_stored_workitems
570
555
 
571
- @engine.register_participant '.+', Ruote::NullParticipant
556
+ @dashboard.register_participant '.+', Ruote::NullParticipant
572
557
 
573
- wfid = @engine.launch(Ruote.define { alpha })
574
- @engine.wait_for(:alpha)
558
+ wfid = @dashboard.launch(Ruote.define { alpha })
559
+ @dashboard.wait_for(:alpha)
575
560
 
576
- ps = @engine.process(wfid)
561
+ ps = @dashboard.process(wfid)
577
562
 
578
563
  assert_equal 0, ps.stored_workitems.size
579
564
  end
580
565
 
581
566
  def test_schedules
582
567
 
583
- @engine.register_participant '.+', Ruote::NullParticipant
568
+ @dashboard.register_participant '.+', Ruote::NullParticipant
584
569
 
585
- wfid = @engine.launch(Ruote.define { alpha :timeout => '2d' })
586
- @engine.wait_for(:alpha)
570
+ wfid = @dashboard.launch(Ruote.define { alpha :timeout => '2d' })
571
+ @dashboard.wait_for(:alpha)
587
572
 
588
- assert_equal 1, @engine.schedules.size
589
- assert_equal 1, @engine.schedules(:count => true)
573
+ assert_equal 1, @dashboard.schedules.size
574
+ assert_equal 1, @dashboard.schedules(:count => true)
590
575
  end
591
576
 
592
577
  def test_processes_and_schedules
593
578
 
594
- @engine.register_participant '.+', Ruote::NullParticipant
595
-
596
- #noisy
579
+ @dashboard.register_participant '.+', Ruote::NullParticipant
597
580
 
598
- wfid = @engine.launch(Ruote.define { alpha :timeout => '2d' })
599
- @engine.wait_for(:alpha)
581
+ wfid = @dashboard.launch(Ruote.define { alpha :timeout => '2d' })
582
+ @dashboard.wait_for(:alpha)
600
583
 
601
- ps = @engine.process(wfid)
584
+ ps = @dashboard.process(wfid)
602
585
 
603
586
  assert_equal 1, ps.schedules.size
604
587
  assert_match /^0_0![a-f0-9]+!#{wfid}$/, ps.schedules.first['target'].sid
@@ -608,50 +591,50 @@ digraph "process wfid {
608
591
 
609
592
  n = 7
610
593
 
611
- @engine.register_participant '.+', Ruote::StorageParticipant
594
+ @dashboard.register_participant '.+', Ruote::StorageParticipant
612
595
 
613
596
  wfids = (1..n).collect { |i|
614
- @engine.launch(Ruote.define { alpha })
597
+ @dashboard.launch(Ruote.define { alpha })
615
598
  }.sort
616
599
 
617
- while @engine.storage_participant.size < n; sleep 0.140; end
600
+ while @dashboard.storage_participant.size < n; sleep 0.140; end
618
601
 
619
- assert_equal wfids, @engine.process_wfids
602
+ assert_equal wfids, @dashboard.process_wfids
620
603
 
621
604
  assert_equal(
622
605
  wfids,
623
- @engine.processes.collect { |ps| ps.wfid })
606
+ @dashboard.processes.collect { |ps| ps.wfid })
624
607
 
625
608
  assert_equal(
626
609
  wfids,
627
- @engine.processes(:test => :garbage).collect { |ps| ps.wfid })
610
+ @dashboard.processes(:test => :garbage).collect { |ps| ps.wfid })
628
611
  # prompted by
629
612
  # http://groups.google.com/group/openwferu-users/browse_thread/thread/ee493bdf8d8cdb37
630
613
 
631
614
  assert_equal(
632
615
  wfids[0, 3],
633
- @engine.processes(:limit => 3).collect { |ps| ps.wfid })
616
+ @dashboard.processes(:limit => 3).collect { |ps| ps.wfid })
634
617
 
635
618
  assert_equal(
636
619
  wfids[3, 3],
637
- @engine.processes(:skip => 3, :limit => 3).collect { |ps| ps.wfid })
620
+ @dashboard.processes(:skip => 3, :limit => 3).collect { |ps| ps.wfid })
638
621
 
639
622
  #puts "==="
640
623
  #wfids.each { |wfid| puts wfid }
641
624
  #puts "---"
642
- #@engine.processes(:limit => 3, :descending => false).collect { |ps| ps.wfid }.each { |wfid| puts wfid }
625
+ #@dashboard.processes(:limit => 3, :descending => false).collect { |ps| ps.wfid }.each { |wfid| puts wfid }
643
626
  #puts "---"
644
- #@engine.processes(:limit => 3, :descending => true).collect { |ps| ps.wfid }.each { |wfid| puts wfid }
627
+ #@dashboard.processes(:limit => 3, :descending => true).collect { |ps| ps.wfid }.each { |wfid| puts wfid }
645
628
 
646
629
  assert_equal(
647
630
  wfids.reverse[0, 3],
648
- @engine.processes(
631
+ @dashboard.processes(
649
632
  :limit => 3, :descending => true
650
633
  ).collect { |ps| ps.wfid })
651
634
 
652
635
  assert_equal(
653
636
  n,
654
- @engine.processes(:count => true))
637
+ @dashboard.processes(:count => true))
655
638
  end
656
639
 
657
640
  # Issue identified by David Goodlad :
@@ -667,28 +650,26 @@ digraph "process wfid {
667
650
  end
668
651
  end
669
652
 
670
- #noisy
653
+ wfid = @dashboard.launch(pdef)
671
654
 
672
- wfid = @engine.launch(pdef)
655
+ @dashboard.wait_for(4)
673
656
 
674
- @engine.wait_for(4)
675
-
676
- #assert_equal 1, @engine.processes.size
677
- assert_equal [ wfid ], @engine.processes.collect { |ps| ps.wfid }
657
+ #assert_equal 1, @dashboard.processes.size
658
+ assert_equal [ wfid ], @dashboard.processes.collect { |ps| ps.wfid }
678
659
  end
679
660
 
680
661
  def test_ps
681
662
 
682
- @engine.register 'alpha', Ruote::NullParticipant
663
+ @dashboard.register 'alpha', Ruote::NullParticipant
683
664
 
684
665
  wfid = nil
685
666
 
686
- 2.times { wfid = @engine.launch(Ruote.define { alpha }) }
667
+ 2.times { wfid = @dashboard.launch(Ruote.define { alpha }) }
687
668
 
688
- @engine.wait_for(4)
669
+ @dashboard.wait_for(4)
689
670
 
690
- assert_equal 2, @engine.ps.size
691
- assert_equal wfid, @engine.ps(wfid).wfid
671
+ assert_equal 2, @dashboard.ps.size
672
+ assert_equal wfid, @dashboard.ps(wfid).wfid
692
673
  end
693
674
 
694
675
  def test_definition_name
@@ -697,21 +678,112 @@ digraph "process wfid {
697
678
  alpha
698
679
  end
699
680
 
700
- #noisy
681
+ alpha = @dashboard.register_participant :alpha, Ruote::NullParticipant
682
+
683
+ wfid = @dashboard.launch(pdef)
684
+
685
+ wait_for(:alpha)
686
+
687
+ assert_equal 'invictus', @dashboard.process(wfid).definition_name
688
+
689
+ exp = @dashboard.process(wfid).expressions.first
690
+ @dashboard.storage.delete(exp.h)
691
+
692
+ assert_nil @dashboard.process(wfid).definition_name
693
+ assert_nil @dashboard.process(wfid).definition_revision
694
+ end
695
+
696
+ def test_leaves
697
+
698
+ pdef = Ruote.define do
699
+ concurrence do
700
+ alpha
701
+ wait '1w'
702
+ end
703
+ end
704
+
705
+ @dashboard.register_participant :alpha, Ruote::NullParticipant
706
+
707
+ wfid = @dashboard.launch(pdef)
708
+
709
+ wait_for(:alpha)
710
+ wait_for(1)
711
+
712
+ leaves = @dashboard.process(wfid).leaves
713
+
714
+ assert_equal(
715
+ [ "0_0_0:Ruote::Exp::ParticipantExpression:",
716
+ "0_0_1:Ruote::Exp::WaitExpression:" ],
717
+ leaves.collect { |fexp|
718
+ [ fexp.fei.expid,
719
+ fexp.class.to_s,
720
+ fexp.error ? fexp.error.message : '' ].join(':')
721
+ })
722
+ end
723
+
724
+ def test_leaves_when_errors
725
+
726
+ pdef = Ruote.define do
727
+ concurrence do
728
+ wait '1w'
729
+ participant
730
+ alpha
731
+ end
732
+ end
733
+
734
+ @dashboard.register_participant :alpha, Ruote::NullParticipant
701
735
 
702
- alpha = @engine.register_participant :alpha, Ruote::NullParticipant
736
+ wfid = @dashboard.launch(pdef)
737
+
738
+ wait_for(:alpha)
739
+ wait_for(1)
740
+
741
+ leaves = @dashboard.process(wfid).leaves
742
+
743
+ assert_equal(
744
+ [ "0_0_0:Ruote::Exp::WaitExpression:",
745
+ "0_0_1:Ruote::Exp::ParticipantExpression:#<ArgumentError: no participant name specified>",
746
+ "0_0_2:Ruote::Exp::ParticipantExpression:" ],
747
+ leaves.collect { |fexp|
748
+ [ fexp.fei.expid,
749
+ fexp.class.to_s,
750
+ fexp.error ? fexp.error.message : '' ].join(':')
751
+ })
752
+ end
703
753
 
704
- wfid = @engine.launch(pdef)
754
+ def test_root_workitem
755
+
756
+ pdef = Ruote.define do
757
+ alpha
758
+ end
759
+
760
+ @dashboard.register_participant :alpha, Ruote::NullParticipant
761
+
762
+ wfid = @dashboard.launch(pdef, 'small' => 'town')
705
763
 
706
764
  wait_for(:alpha)
707
765
 
708
- assert_equal 'invictus', @engine.process(wfid).definition_name
766
+ wi = @dashboard.process(wfid).root_workitem
767
+
768
+ assert_equal 'town', wi.fields['small']
769
+ end
770
+
771
+ def test_to_h
772
+
773
+ @dashboard.register_participant :alpha, Ruote::StorageParticipant
774
+
775
+ pdef = Ruote.define do
776
+ concurrence do
777
+ alpha
778
+ wait '1d'
779
+ nada
780
+ end
781
+ end
709
782
 
710
- exp = @engine.process(wfid).expressions.first
711
- @engine.storage.delete(exp.h)
783
+ wfid = @dashboard.launch(pdef)
784
+ @dashboard.wait_for(7)
712
785
 
713
- assert_nil @engine.process(wfid).definition_name
714
- assert_nil @engine.process(wfid).definition_revision
786
+ assert_equal Hash, @dashboard.ps(wfid).to_h.class
715
787
  end
716
788
  end
717
789