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
  # Fri Dec 4 17:15:10 JST 2009
6
6
  #
7
7
 
8
- require File.join(File.dirname(__FILE__), 'base.rb')
8
+ require File.expand_path('../base', __FILE__)
9
9
 
10
10
 
11
11
  class Ruote::Worker
@@ -16,7 +16,9 @@ end
16
16
  class Ruote::Engine
17
17
 
18
18
  def peek_msg
19
- @msgs = @context.storage.get_msgs if ( ! @msgs) || @msgs.size < 1
19
+ if ( ! @msgs) || @msgs.size < 1
20
+ @msgs = @context.storage.get_msgs
21
+ end
20
22
  @msgs.shift
21
23
  end
22
24
 
@@ -62,37 +64,38 @@ module ConcurrentBase
62
64
 
63
65
  def setup
64
66
 
65
- @storage = determine_storage(
66
- 's_logger' => [ 'ruote/log/test_logger', 'Ruote::TestLogger' ])
67
+ @storage = determine_storage({})
67
68
 
68
- @engine0 = Ruote::Engine.new(Ruote::Worker.new(@storage), false)
69
- @engine1 = Ruote::Engine.new(Ruote::Worker.new(@storage), false)
69
+ @dashboard0 = Ruote::Engine.new(Ruote::Worker.new(@storage), false)
70
+ @dashboard1 = Ruote::Engine.new(Ruote::Worker.new(@storage), false)
70
71
  #
71
72
  # the 2 engines are set with run=false
72
73
 
73
74
  @tracer0 = Tracer.new
74
75
  @tracer1 = Tracer.new
75
76
 
76
- @engine0.context.add_service('s_tracer', @tracer0, nil)
77
- @engine1.context.add_service('s_tracer', @tracer1, nil)
77
+ @dashboard0.context.add_service('s_tracer', @tracer0, nil)
78
+ @dashboard1.context.add_service('s_tracer', @tracer1, nil)
79
+
80
+ @dashboard1.context.logger.color = '32' # green
78
81
 
79
- @engine1.context.logger.color = '32' # green
82
+ noisy if ARGV.include?('-N')
80
83
  end
81
84
 
82
85
  def teardown
83
86
 
84
87
  @storage.purge!
85
88
 
86
- @engine0.shutdown
87
- @engine1.shutdown
89
+ @dashboard0.shutdown
90
+ @dashboard1.shutdown
88
91
  end
89
92
 
90
93
  protected
91
94
 
92
95
  def noisy
93
96
 
94
- @engine0.context.logger.noisy = true
95
- @engine1.context.logger.noisy = true
97
+ @dashboard0.noisy = true
98
+ @dashboard1.noisy = true
96
99
  end
97
100
  end
98
101
 
@@ -5,9 +5,7 @@
5
5
  # Wed Jul 8 15:30:55 JST 2009
6
6
  #
7
7
 
8
- require File.join(File.dirname(__FILE__), 'concurrent_base')
9
-
10
- #require 'ruote/part/hash_participant'
8
+ require File.expand_path('../concurrent_base', __FILE__)
11
9
 
12
10
 
13
11
  class CtConcurrenceTest < Test::Unit::TestCase
@@ -26,20 +24,18 @@ class CtConcurrenceTest < Test::Unit::TestCase
26
24
  end
27
25
  end
28
26
 
29
- noisy if ARGV.include?('-N')
30
-
31
- wfid = @engine0.launch(pdef)
27
+ wfid = @dashboard0.launch(pdef)
32
28
 
33
29
  replies = []
34
30
 
35
31
  while replies.size < 2
36
32
 
37
- msg = @engine0.next_msg
33
+ msg = @dashboard0.next_msg
38
34
 
39
35
  if msg['action'] == 'reply'
40
36
  replies << msg
41
37
  else
42
- @engine0.do_process(msg)
38
+ @dashboard0.do_process(msg)
43
39
  end
44
40
  end
45
41
 
@@ -47,12 +43,12 @@ class CtConcurrenceTest < Test::Unit::TestCase
47
43
 
48
44
  #replies.each { |r| p r }
49
45
 
50
- t0 = Thread.new { @engine1.do_process(replies[0]) }
51
- t1 = Thread.new { @engine0.do_process(replies[1]) }
46
+ t0 = Thread.new { @dashboard1.do_process(replies[0]) }
47
+ t1 = Thread.new { @dashboard0.do_process(replies[1]) }
52
48
  t0.join
53
49
  t1.join
54
50
 
55
- msgs = @engine0.gather_msgs
51
+ msgs = @dashboard0.gather_msgs
56
52
 
57
53
  assert_equal 1, msgs.size, 'exactly 1 message was expected'
58
54
 
@@ -5,7 +5,7 @@
5
5
  # Mon Dec 7 13:54:18 JST 2009
6
6
  #
7
7
 
8
- require File.join(File.dirname(__FILE__), 'concurrent_base')
8
+ require File.expand_path('../concurrent_base', __FILE__)
9
9
 
10
10
 
11
11
  class CtIteratorTest < Test::Unit::TestCase
@@ -29,35 +29,33 @@ class CtIteratorTest < Test::Unit::TestCase
29
29
  end
30
30
  end
31
31
 
32
- noisy if ARGV.include?('-N')
33
-
34
- wfid = @engine0.launch(pdef)
32
+ wfid = @dashboard0.launch(pdef)
35
33
 
36
34
  stop_msg = nil
37
35
 
38
36
  loop do
39
- m = @engine0.next_msg
37
+ m = @dashboard0.next_msg
40
38
  if m['command']
41
39
  stop_msg = m
42
40
  break
43
41
  end
44
- @engine0.do_process(m)
42
+ @dashboard0.do_process(m)
45
43
  end
46
44
 
47
45
  assert_equal 'stop', stop_msg['command'].first
48
46
  assert_equal '0_0_0', stop_msg['fei']['expid']
49
47
 
50
- msg = @engine0.next_msg
48
+ msg = @dashboard0.next_msg
51
49
 
52
- t0 = Thread.new { @engine1.do_process(stop_msg) }
53
- t1 = Thread.new { @engine0.do_process(msg) }
50
+ t0 = Thread.new { @dashboard1.do_process(stop_msg) }
51
+ t1 = Thread.new { @dashboard0.do_process(msg) }
54
52
  t0.join
55
53
  t1.join
56
54
 
57
55
  loop do
58
- m = @engine0.next_msg
56
+ m = @dashboard0.next_msg
59
57
  break if m['action'] == 'terminated'
60
- @engine0.do_process(m)
58
+ @dashboard0.do_process(m)
61
59
  end
62
60
 
63
61
  assert_equal "1\n2", @tracer0.to_s
@@ -5,7 +5,7 @@
5
5
  # Mon Dec 28 19:13:02 JST 2009
6
6
  #
7
7
 
8
- require File.join(File.dirname(__FILE__), 'concurrent_base')
8
+ require File.expand_path('../concurrent_base', __FILE__)
9
9
 
10
10
 
11
11
  class CtCancelTest < Test::Unit::TestCase
@@ -24,58 +24,69 @@ class CtCancelTest < Test::Unit::TestCase
24
24
  end
25
25
  end
26
26
 
27
- alpha = @engine0.register_participant :alpha do |workitem|
27
+ alpha = @dashboard0.register_participant :alpha do |workitem|
28
28
  # let reply immediately
29
29
  end
30
30
 
31
- noisy if ARGV.include?('-N')
31
+ wfid = @dashboard0.launch(pdef)
32
32
 
33
- wfid = @engine0.launch(pdef)
33
+ #
34
+ # test preparation...
34
35
 
35
- @engine0.step 7
36
+ @dashboard0.step 6
36
37
 
37
38
  dispatched_seen = false
38
39
  reply_msg = nil
39
40
 
41
+ #
42
+ # reach the point where the reply is coming (and the dispatched msg has
43
+ # passed)
44
+
40
45
  loop do
41
- m = @engine0.next_msg
46
+ m = @dashboard0.next_msg
42
47
  ma = m['action']
43
48
  if ma == 'dispatched'
44
49
  dispatched_seen = true
45
- @engine0.do_process(m)
50
+ @dashboard0.do_process(m)
46
51
  break if reply_msg
47
52
  elsif ma == 'reply'
48
53
  reply_msg = m
49
- break
54
+ break if dispatched_seen
50
55
  else
51
- @engine0.do_process(m)
56
+ @dashboard0.do_process(m)
52
57
  end
53
58
  end
54
59
 
55
- #p dispatched_seen
60
+ #
61
+ # inject the cancel message
56
62
 
57
- @engine0.cancel_expression(
63
+ @dashboard0.cancel_expression(
58
64
  { 'engine_id' => 'engine', 'wfid' => wfid, 'expid' => '0_0' })
59
65
 
60
- msgs = @engine0.gather_msgs
66
+ msgs = @dashboard0.gather_msgs
61
67
 
62
68
  msgs = msgs - [ reply_msg ]
63
69
 
64
70
  assert_equal 1, msgs.size
65
71
  assert_equal 'cancel', msgs.first['action']
72
+ #
73
+ # trusting is good, checking is better
74
+
75
+ #
76
+ # try to force a collision between the reply msg and the cancel msg
66
77
 
67
- t1 = Thread.new { @engine1.do_process(msgs.first) }
68
- t0 = Thread.new { @engine0.do_process(reply_msg) }
78
+ t1 = Thread.new { @dashboard1.do_process(msgs.first) }
79
+ t0 = Thread.new { @dashboard0.do_process(reply_msg) }
69
80
  t1.join
70
81
  t0.join
71
82
 
72
83
  loop do
73
- m = @engine0.next_msg
74
- @engine0.do_process(m)
84
+ m = @dashboard0.next_msg
85
+ @dashboard0.do_process(m)
75
86
  break if m['action'] == 'terminated'
76
87
  end
77
88
 
78
- assert_nil @engine0.process(wfid)
89
+ assert_nil @dashboard0.process(wfid)
79
90
  end
80
91
  end
81
92
 
@@ -0,0 +1,35 @@
1
+
2
+ #
3
+ # testing ruote
4
+ #
5
+ # Mon Jun 27 11:24:21 JST 2011
6
+ #
7
+
8
+
9
+ require File.expand_path('../base', __FILE__)
10
+
11
+
12
+ class EftFlowExpressionTest < Test::Unit::TestCase
13
+ include FunctionalBase
14
+
15
+ def test_root_and_root_id
16
+
17
+ @dashboard.register :alpha, Ruote::NullParticipant
18
+
19
+ wfid = @dashboard.launch(Ruote.define do
20
+ sequence do
21
+ alpha
22
+ end
23
+ end)
24
+
25
+ @dashboard.wait_for(:alpha)
26
+
27
+ fexp = @dashboard.ps(wfid).expressions.last
28
+
29
+ assert_equal '0', fexp.root.fei.expid
30
+ assert_equal Ruote::Exp::SequenceExpression, fexp.root.class
31
+
32
+ assert_equal '0', fexp.root_id.expid
33
+ end
34
+ end
35
+
@@ -5,7 +5,7 @@
5
5
  # Mon Jun 15 21:18: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 EftCancelProcessTest < Test::Unit::TestCase
@@ -5,7 +5,7 @@
5
5
  # Thu Jun 18 11:03:45 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 EftWaitTest < Test::Unit::TestCase
@@ -24,18 +24,18 @@ class EftWaitTest < Test::Unit::TestCase
24
24
 
25
25
  #noisy
26
26
 
27
- @engine.context.stash[:ts] = []
27
+ @dashboard.context.stash[:ts] = []
28
28
 
29
- @engine.register_participant(:alpha) { stash[:ts] << Time.now }
29
+ @dashboard.register_participant(:alpha) { stash[:ts] << Time.now }
30
30
 
31
31
  assert_trace 'done.', pdef
32
32
 
33
33
  d = (
34
- @engine.context.stash[:ts][1].sec - @engine.context.stash[:ts][0].sec
34
+ @dashboard.context.stash[:ts][1].sec - @dashboard.context.stash[:ts][0].sec
35
35
  ) % 60
36
36
 
37
- deltas = [ 2, 3 ]
38
- deltas << 4 if @engine.storage.class.name.match(/^Ruote::Couch::/)
37
+ deltas = [ 2, 3, 4 ]
38
+ #deltas << 4 if @dashboard.storage.class.name.match(/^Ruote::Couch::/)
39
39
 
40
40
  assert(
41
41
  deltas.include?(d),
@@ -54,23 +54,23 @@ class EftWaitTest < Test::Unit::TestCase
54
54
 
55
55
  #noisy
56
56
 
57
- wfid = @engine.launch(pdef)
57
+ wfid = @dashboard.launch(pdef)
58
58
 
59
59
  wait_for(4)
60
60
 
61
- @engine.cancel_process(wfid)
61
+ @dashboard.cancel_process(wfid)
62
62
 
63
63
  wait_for(wfid)
64
64
 
65
65
  assert_equal 'a', @tracer.to_s
66
- assert_equal 0, @engine.storage.get_many('schedules').size
66
+ assert_equal 0, @dashboard.storage.get_many('schedules').size
67
67
  end
68
68
 
69
69
  def test_wait_until
70
70
 
71
- @engine.context.stash[:ts] = []
71
+ @dashboard.context.stash[:ts] = []
72
72
 
73
- @engine.register_participant(:alpha) { stash[:ts] << Time.now }
73
+ @dashboard.register_participant(:alpha) { stash[:ts] << Time.now }
74
74
 
75
75
  pdef = Ruote.process_definition do
76
76
  sequence do
@@ -85,8 +85,8 @@ class EftWaitTest < Test::Unit::TestCase
85
85
 
86
86
  assert_trace 'done.', pdef
87
87
 
88
- ts0 = @engine.context.stash[:ts][0]
89
- ts1 = @engine.context.stash[:ts][1]
88
+ ts0 = @dashboard.context.stash[:ts][0]
89
+ ts1 = @dashboard.context.stash[:ts][1]
90
90
 
91
91
  assert(ts1 - ts0 > 1.0, "#{ts1 - ts0} should be > 1.0")
92
92
  end
@@ -5,7 +5,7 @@
5
5
  # Fri Jun 19 15:26:33 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 EftListenTest < Test::Unit::TestCase
@@ -25,19 +25,18 @@ class EftListenTest < Test::Unit::TestCase
25
25
  end
26
26
  end
27
27
 
28
- #noisy
29
-
30
- @engine.register_participant :alpha do
31
- @tracer << "alpha\n"
28
+ @dashboard.register_participant :alpha do
29
+ tracer << "alpha\n"
32
30
  end
33
31
 
34
- wfid = @engine.launch(pdef)
32
+ wfid = @dashboard.launch(pdef)
35
33
  wait_for(wfid)
36
34
 
37
35
  assert_equal %w[ 1 alpha ], @tracer.to_a.sort
38
36
 
39
37
  assert_equal(
40
- 0, @engine.context.storage.get('variables', 'trackers')['trackers'].size)
38
+ 0,
39
+ @dashboard.context.storage.get('variables', 'trackers')['trackers'].size)
41
40
  end
42
41
 
43
42
  def test_listen_with_child
@@ -54,24 +53,17 @@ class EftListenTest < Test::Unit::TestCase
54
53
  end
55
54
  end
56
55
 
57
- @engine.register_participant :alpha do
58
- @tracer << "a\n"
56
+ @dashboard.register_participant :alpha do
57
+ tracer << "a\n"
59
58
  end
60
- @engine.register_participant :bravo do |workitem|
61
- @tracer << "#{workitem.fei.wfid}|#{workitem.fei.subid}"
62
- @tracer << "\n"
59
+ @dashboard.register_participant :bravo do |workitem|
60
+ tracer << "#{workitem.fei.wfid}|#{workitem.fei.subid}"
61
+ tracer << "\n"
63
62
  end
64
63
 
65
- #noisy
66
-
67
- wfid = @engine.launch(pdef)
68
-
69
- wait_for(:bravo)
70
- wait_for(:bravo)
71
- wait_for(3)
64
+ wfid = @dashboard.launch(pdef)
72
65
 
73
- #sleep 0.001
74
- #p @tracer.to_s
66
+ 4.times { @dashboard.wait_for('dispatched') }
75
67
 
76
68
  a = @tracer.to_a
77
69
  assert_equal 2, a.select { |e| e == 'a' }.size
@@ -79,13 +71,14 @@ class EftListenTest < Test::Unit::TestCase
79
71
  a = (a - [ 'a', 'a' ]).sort
80
72
  assert_equal 2, a.uniq.size
81
73
 
82
- ps = @engine.process(wfid)
74
+ ps = @dashboard.process(wfid)
83
75
 
84
76
  #assert_equal 3, ps.expressions.size
85
77
  assert_equal 0, ps.errors.size
86
78
 
87
79
  assert_equal(
88
- 1, @engine.context.storage.get('variables', 'trackers')['trackers'].size)
80
+ 1,
81
+ @dashboard.context.storage.get('variables', 'trackers')['trackers'].size)
89
82
  end
90
83
 
91
84
  def test_upon
@@ -106,18 +99,16 @@ class EftListenTest < Test::Unit::TestCase
106
99
  end
107
100
  end
108
101
 
109
- #noisy
110
-
111
- @engine.register_participant :alpha do |workitem|
112
- @tracer << "alpha\n"
102
+ @dashboard.register_participant :alpha do |workitem|
103
+ tracer << "alpha\n"
113
104
  workitem.fields['seen'] = 'yes'
114
105
  end
115
- @engine.register_participant :bravo do |workitem|
116
- @tracer << "bravo:#{workitem.fields['seen']}\n"
106
+ @dashboard.register_participant :bravo do |workitem|
107
+ tracer << "bravo:#{workitem.fields['seen']}\n"
117
108
  end
118
109
 
119
- wfid = @engine.launch(pdef)
120
- @engine.wait_for(wfid)
110
+ wfid = @dashboard.launch(pdef)
111
+ @dashboard.wait_for(wfid)
121
112
 
122
113
  assert_equal %w[ alpha bravo: bravo:yes ], @tracer.to_a.sort
123
114
  end
@@ -138,15 +129,13 @@ class EftListenTest < Test::Unit::TestCase
138
129
  end
139
130
  end
140
131
 
141
- #noisy
142
-
143
- @engine.register_participant :alpha do |wi|
144
- @tracer << "alpha\n"
132
+ @dashboard.register_participant :alpha do |wi|
133
+ tracer << "alpha\n"
145
134
  wi.fields['name'] = 'William Mandella'
146
135
  end
147
- @engine.register_participant :bravo do |wi|
148
- @tracer << "name:#{wi.fields['name']} "
149
- @tracer << "other:#{wi.fields['other']}\n"
136
+ @dashboard.register_participant :bravo do |wi|
137
+ tracer << "name:#{wi.fields['name']} "
138
+ tracer << "other:#{wi.fields['other']}\n"
150
139
  end
151
140
 
152
141
  assert_trace("alpha\nname:William Mandella other:nothing", pdef)
@@ -168,25 +157,23 @@ class EftListenTest < Test::Unit::TestCase
168
157
  end
169
158
  end
170
159
 
171
- #noisy
172
-
173
160
  stash[:count] = 0
174
161
 
175
- @engine.register_participant :alpha do |wi|
176
- @tracer << "alpha\n"
177
- wi.fields['who'] = 'toto' if stash[:count] > 0
178
- stash[:count] += 1
162
+ @dashboard.register_participant :alpha do |wi|
163
+ tracer << "alpha\n"
164
+ wi.fields['who'] = 'toto' if context.stash[:count] > 0
165
+ context.stash[:count] += 1
179
166
  end
180
167
 
181
- wfid = @engine.launch(pdef)
168
+ wfid = @dashboard.launch(pdef)
182
169
 
183
170
  wait_for(wfid) # ceased
184
171
 
185
172
  assert_equal %w[ alpha alpha toto ].join("\n"), @tracer.to_s
186
- assert_equal 3, @engine.process(wfid).expressions.size
173
+ assert_equal 3, @dashboard.process(wfid).expressions.size
187
174
 
188
175
  assert_not_nil(
189
- @engine.context.logger.log.find { |l| l['action'] == 'ceased' })
176
+ @dashboard.context.logger.log.find { |l| l['action'] == 'ceased' })
190
177
  end
191
178
 
192
179
  def test_listen_cancel
@@ -195,19 +182,19 @@ class EftListenTest < Test::Unit::TestCase
195
182
  listen :to => 'alpha'
196
183
  end
197
184
 
198
- wfid = @engine.launch(pdef)
185
+ wfid = @dashboard.launch(pdef)
199
186
 
200
187
  wait_for(2)
201
188
 
202
189
  assert_equal(
203
- 1, @engine.context.storage.get('variables', 'trackers')['trackers'].size)
190
+ 1, @dashboard.context.storage.get('variables', 'trackers')['trackers'].size)
204
191
 
205
- @engine.cancel_process(wfid)
192
+ @dashboard.cancel_process(wfid)
206
193
 
207
194
  wait_for(wfid)
208
195
 
209
196
  assert_equal(
210
- 0, @engine.context.storage.get('variables', 'trackers')['trackers'].size)
197
+ 0, @dashboard.context.storage.get('variables', 'trackers')['trackers'].size)
211
198
  end
212
199
 
213
200
  def test_cross
@@ -225,14 +212,12 @@ class EftListenTest < Test::Unit::TestCase
225
212
  end
226
213
  end
227
214
 
228
- @engine.register_participant :alpha do
215
+ @dashboard.register_participant :alpha do
229
216
  # nothing
230
217
  end
231
218
 
232
- #noisy
233
-
234
- lwfid = @engine.launch(listening)
235
- ewfid = @engine.launch(emitting)
219
+ lwfid = @dashboard.launch(listening)
220
+ ewfid = @dashboard.launch(emitting)
236
221
 
237
222
  wait_for(lwfid, ewfid)
238
223
 
@@ -255,18 +240,18 @@ class EftListenTest < Test::Unit::TestCase
255
240
  end
256
241
  end
257
242
 
258
- @engine.register_participant :alpha do
243
+ @dashboard.register_participant :alpha do
259
244
  # nothing
260
245
  end
261
246
 
262
- lwfid = @engine.launch(listening)
263
- ewfid = @engine.launch(emitting)
247
+ lwfid = @dashboard.launch(listening)
248
+ ewfid = @dashboard.launch(emitting)
264
249
 
265
250
  wait_for(ewfid)
266
251
 
267
252
  assert_equal("edone.", @tracer.to_s)
268
253
 
269
- ps = @engine.process(lwfid)
254
+ ps = @dashboard.process(lwfid)
270
255
  assert_equal(3, ps.expressions.size)
271
256
  end
272
257
 
@@ -289,10 +274,8 @@ class EftListenTest < Test::Unit::TestCase
289
274
  echo 'edone.'
290
275
  end
291
276
 
292
- #noisy
293
-
294
- lwfid = @engine.launch(listening)
295
- ewfid = @engine.launch(emitting)
277
+ lwfid = @dashboard.launch(listening)
278
+ ewfid = @dashboard.launch(emitting)
296
279
 
297
280
  wait_for(ewfid)
298
281
 
@@ -328,11 +311,161 @@ class EftListenTest < Test::Unit::TestCase
328
311
  end
329
312
  end
330
313
 
331
- wfid = @engine.launch(pdef)
314
+ wfid = @dashboard.launch(pdef)
332
315
 
333
- @engine.wait_for(wfid)
316
+ @dashboard.wait_for(wfid)
334
317
 
335
318
  assert_equal %w[ milestone stone ], @tracer.to_a
336
319
  end
320
+
321
+ # somewhere between Haneda and Changi (Thu Apr 21 00:56:19 JST 2011)
322
+
323
+ def test_listen_to_errors
324
+
325
+ @dashboard.context['ruby_eval_allowed'] = true
326
+
327
+ pdef = Ruote.define do
328
+ concurrence :count => 1 do
329
+ listen :to => :errors do
330
+ echo 'error:${f:__error__.message}'
331
+ end
332
+ sequence do
333
+ nemo
334
+ end
335
+ end
336
+ end
337
+
338
+ wfid = @dashboard.launch(pdef)
339
+
340
+ @dashboard.wait_for(wfid)
341
+
342
+ @dashboard.wait_for(3)
343
+ # give it some time (steps) to launch the listen block
344
+
345
+ assert_equal "error:unknown participant or subprocess 'nemo'", @tracer.to_s
346
+ end
347
+
348
+ def test_listen_and_caught_errors
349
+
350
+ pdef = Ruote.define do
351
+ concurrence :count => 1 do
352
+ listen :to => :errors do
353
+ echo 'error intercepted'
354
+ end
355
+ sequence :on_error => :pass do
356
+ nemo
357
+ end
358
+ end
359
+ end
360
+
361
+ wfid = @dashboard.launch(pdef)
362
+ @dashboard.wait_for(wfid)
363
+
364
+ assert_equal '', @tracer.to_s
365
+ end
366
+
367
+ def test_listen_does_not_work_for_errors_in_other_processes
368
+
369
+ wfid0 = @dashboard.launch(Ruote.define do
370
+ listen :to => :errors do
371
+ echo 'error intercepted'
372
+ end
373
+ end)
374
+
375
+ sleep 0.700
376
+
377
+ wfid1 = @dashboard.launch(Ruote.define do
378
+ nemo
379
+ end)
380
+
381
+ @dashboard.wait_for(wfid1)
382
+
383
+ sleep 0.350
384
+ # just to be sure the 'listen' doesn't trigger
385
+
386
+ assert_equal '', @tracer.to_s
387
+ end
388
+
389
+ def test_listen_error_class
390
+
391
+ pdef = Ruote.define do
392
+ concurrence do
393
+ listen :to => :errors, :class => 'RuntimeError' do
394
+ echo 'runtime error'
395
+ end
396
+ listen :to => :errors, :class => 'ArgumentError' do
397
+ echo 'argument error'
398
+ end
399
+ sequence do
400
+ nemo
401
+ end
402
+ sequence do
403
+ echo '${r:nada}'
404
+ end
405
+ end
406
+ end
407
+
408
+ wfid = @dashboard.launch(pdef)
409
+
410
+ #sleep 1.000
411
+ 4.times { @dashboard.wait_for(wfid) } # error, error, ceased, ceased
412
+
413
+ assert_equal(
414
+ true,
415
+ [ "runtime error\nargument error",
416
+ "argument error\nruntime error" ].include?(@tracer.to_s))
417
+ end
418
+
419
+ def test_listen_error_message
420
+
421
+ @dashboard.context['ruby_eval_allowed'] = true
422
+
423
+ pdef = Ruote.define do
424
+ concurrence do
425
+ listen :to => :errors, :msg => /nemo/ do
426
+ echo 'nemo error ${__error__.fei.expid}'
427
+ end
428
+ listen :to => :errors, :msg => 'nada' do
429
+ echo 'nada error ${__error__.fei.expid}'
430
+ end
431
+ sequence do
432
+ nemo
433
+ end
434
+ sequence do
435
+ error 'nada'
436
+ end
437
+ end
438
+ end
439
+
440
+ wfid = @dashboard.launch(pdef)
441
+
442
+ 4.times { @dashboard.wait_for(wfid) } # error, error, ceased, ceased
443
+
444
+ assert_equal "nemo error 0_0_2_0\nnada error 0_0_3_0", @tracer.to_s
445
+ end
446
+
447
+ def test_listen_error_classes
448
+
449
+ pdef = Ruote.define do
450
+ concurrence do
451
+ listen :to => :errors, :class => 'RuntimeError, ArgumentError' do
452
+ echo 'that error ${__error__.fei.expid}'
453
+ end
454
+ sequence do
455
+ nemo
456
+ end
457
+ sequence do
458
+ echo '${r:nada}'
459
+ end
460
+ end
461
+ end
462
+
463
+ wfid = @dashboard.launch(pdef)
464
+
465
+ #sleep 1.000
466
+ 4.times { @dashboard.wait_for(wfid) } # error, error, ceased, ceased
467
+
468
+ assert_equal "that error 0_0_1_0\nthat error 0_0_2_0", @tracer.to_s
469
+ end
337
470
  end
338
471