ruote 2.1.10 → 2.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. data/CHANGELOG.txt +51 -1
  2. data/CREDITS.txt +9 -0
  3. data/README.rdoc +13 -0
  4. data/Rakefile +50 -21
  5. data/TODO.txt +42 -4
  6. data/examples/pong.rb +37 -0
  7. data/lib/ruote/context.rb +19 -9
  8. data/lib/ruote/engine/process_error.rb +10 -0
  9. data/lib/ruote/engine/process_status.rb +140 -41
  10. data/lib/ruote/engine.rb +394 -27
  11. data/lib/ruote/exp/command.rb +2 -0
  12. data/lib/ruote/exp/fe_concurrence.rb +8 -0
  13. data/lib/ruote/exp/fe_concurrent_iterator.rb +3 -0
  14. data/lib/ruote/exp/fe_cursor.rb +48 -4
  15. data/lib/ruote/exp/fe_iterator.rb +40 -0
  16. data/lib/ruote/exp/fe_listen.rb +3 -3
  17. data/lib/ruote/exp/fe_participant.rb +30 -12
  18. data/lib/ruote/exp/fe_ref.rb +126 -0
  19. data/lib/ruote/exp/fe_subprocess.rb +20 -1
  20. data/lib/ruote/exp/fe_wait.rb +4 -1
  21. data/lib/ruote/exp/fe_when.rb +7 -10
  22. data/lib/ruote/exp/flowexpression.rb +23 -12
  23. data/lib/ruote/exp/ro_attributes.rb +5 -8
  24. data/lib/ruote/exp/ro_variables.rb +4 -2
  25. data/lib/ruote/fei.rb +2 -0
  26. data/lib/ruote/id/wfid_generator.rb +1 -1
  27. data/lib/ruote/log/pretty.rb +137 -0
  28. data/lib/ruote/log/storage_history.rb +1 -1
  29. data/lib/ruote/log/test_logger.rb +51 -126
  30. data/lib/ruote/log/wait_logger.rb +8 -13
  31. data/lib/ruote/parser/ruby_dsl.rb +4 -4
  32. data/lib/ruote/parser.rb +2 -2
  33. data/lib/ruote/part/block_participant.rb +1 -1
  34. data/lib/ruote/part/engine_participant.rb +1 -1
  35. data/lib/ruote/part/storage_participant.rb +27 -28
  36. data/lib/ruote/part/template.rb +8 -3
  37. data/lib/ruote/receiver/base.rb +24 -6
  38. data/lib/ruote/storage/base.rb +76 -11
  39. data/lib/ruote/storage/fs_storage.rb +10 -0
  40. data/lib/ruote/storage/hash_storage.rb +19 -8
  41. data/lib/ruote/{part → svc}/dispatch_pool.rb +3 -2
  42. data/lib/ruote/svc/dollar_sub.rb +265 -0
  43. data/lib/ruote/{error_handler.rb → svc/error_handler.rb} +6 -1
  44. data/lib/ruote/{exp → svc}/expression_map.rb +31 -37
  45. data/lib/ruote/{part → svc}/participant_list.rb +165 -25
  46. data/lib/ruote/{evt → svc}/tracker.rb +0 -0
  47. data/lib/ruote/{util → svc}/treechecker.rb +0 -0
  48. data/lib/ruote/util/look.rb +4 -1
  49. data/lib/ruote/util/ometa.rb +21 -5
  50. data/lib/ruote/{subprocess.rb → util/subprocess.rb} +0 -0
  51. data/lib/ruote/version.rb +1 -1
  52. data/lib/ruote/worker.rb +29 -69
  53. data/lib/ruote/workitem.rb +28 -1
  54. data/ruote.gemspec +26 -22
  55. data/test/functional/base.rb +3 -0
  56. data/test/functional/concurrent_base.rb +1 -0
  57. data/test/functional/crunner.sh +1 -1
  58. data/test/functional/ct_0_concurrence.rb +6 -0
  59. data/test/functional/ct_1_iterator.rb +3 -0
  60. data/test/functional/ct_2_cancel.rb +5 -0
  61. data/test/functional/eft_13_iterator.rb +39 -4
  62. data/test/functional/eft_14_cursor.rb +39 -0
  63. data/test/functional/eft_30_ref.rb +140 -0
  64. data/test/functional/eft_3_participant.rb +25 -23
  65. data/test/functional/ft_10_dollar.rb +17 -1
  66. data/test/functional/ft_14_re_apply.rb +76 -0
  67. data/test/functional/ft_1_process_status.rb +170 -29
  68. data/test/functional/ft_20_storage_participant.rb +14 -0
  69. data/test/functional/ft_24_block_participants.rb +1 -1
  70. data/test/functional/ft_26_participant_timeout.rb +93 -0
  71. data/test/functional/ft_2_errors.rb +24 -17
  72. data/test/functional/ft_30_smtp_participant.rb +7 -2
  73. data/test/functional/ft_38_participant_more.rb +15 -0
  74. data/test/functional/ft_39_wait_for.rb +34 -1
  75. data/test/functional/ft_3_participant_registration.rb +270 -2
  76. data/test/functional/ft_40_wait_logger.rb +61 -0
  77. data/test/functional/ft_42_storage_copy.rb +4 -0
  78. data/test/functional/{ft_40_participant_on_reply.rb → ft_43_participant_on_reply.rb} +17 -0
  79. data/test/functional/ft_44_var_participant.rb +35 -0
  80. data/test/functional/ft_45_participant_accept.rb +64 -0
  81. data/test/functional/ft_46_launch_single.rb +49 -0
  82. data/test/functional/ft_5_on_error.rb +39 -1
  83. data/test/functional/storage_helper.rb +7 -1
  84. data/test/test_helper.rb +1 -1
  85. data/test/unit/storage.rb +105 -32
  86. data/test/unit/ut_0_ruby_parser.rb +31 -1
  87. data/test/unit/ut_16_parser.rb +20 -0
  88. data/test/unit/ut_19_part_template.rb +11 -1
  89. data/test/unit/ut_20_composite_storage.rb +1 -1
  90. data/test/unit/ut_4_expmap.rb +1 -1
  91. data/test/unit/ut_6_condition.rb +2 -2
  92. metadata +112 -74
  93. data/lib/ruote/exp/raw.rb +0 -44
  94. data/lib/ruote/util/dollar.rb +0 -193
data/ruote.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruote}
8
- s.version = "2.1.10"
8
+ s.version = "2.1.11"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["John Mettraux", "Kenneth Kalmer", "Torsten Schoenebaum"]
12
- s.date = %q{2010-06-15}
12
+ s.date = %q{2010-10-01}
13
13
  s.description = %q{
14
14
  ruote is an open source ruby workflow engine.
15
15
  }
@@ -28,6 +28,7 @@ ruote is an open source ruby workflow engine.
28
28
  "TODO.txt",
29
29
  "examples/barley.rb",
30
30
  "examples/flickr_report.rb",
31
+ "examples/pong.rb",
31
32
  "examples/ruote_quickstart.rb",
32
33
  "examples/web_first_page.rb",
33
34
  "lib/ruote.rb",
@@ -35,12 +36,9 @@ ruote is an open source ruby workflow engine.
35
36
  "lib/ruote/engine.rb",
36
37
  "lib/ruote/engine/process_error.rb",
37
38
  "lib/ruote/engine/process_status.rb",
38
- "lib/ruote/error_handler.rb",
39
- "lib/ruote/evt/tracker.rb",
40
39
  "lib/ruote/exp/command.rb",
41
40
  "lib/ruote/exp/commanded.rb",
42
41
  "lib/ruote/exp/condition.rb",
43
- "lib/ruote/exp/expression_map.rb",
44
42
  "lib/ruote/exp/fe_add_branches.rb",
45
43
  "lib/ruote/exp/fe_apply.rb",
46
44
  "lib/ruote/exp/fe_cancel_process.rb",
@@ -61,6 +59,7 @@ ruote is an open source ruby workflow engine.
61
59
  "lib/ruote/exp/fe_noop.rb",
62
60
  "lib/ruote/exp/fe_participant.rb",
63
61
  "lib/ruote/exp/fe_redo.rb",
62
+ "lib/ruote/exp/fe_ref.rb",
64
63
  "lib/ruote/exp/fe_reserve.rb",
65
64
  "lib/ruote/exp/fe_restore.rb",
66
65
  "lib/ruote/exp/fe_save.rb",
@@ -73,13 +72,13 @@ ruote is an open source ruby workflow engine.
73
72
  "lib/ruote/exp/flowexpression.rb",
74
73
  "lib/ruote/exp/iterator.rb",
75
74
  "lib/ruote/exp/merge.rb",
76
- "lib/ruote/exp/raw.rb",
77
75
  "lib/ruote/exp/ro_attributes.rb",
78
76
  "lib/ruote/exp/ro_persist.rb",
79
77
  "lib/ruote/exp/ro_variables.rb",
80
78
  "lib/ruote/fei.rb",
81
79
  "lib/ruote/id/mnemo_wfid_generator.rb",
82
80
  "lib/ruote/id/wfid_generator.rb",
81
+ "lib/ruote/log/pretty.rb",
83
82
  "lib/ruote/log/storage_history.rb",
84
83
  "lib/ruote/log/test_logger.rb",
85
84
  "lib/ruote/log/wait_logger.rb",
@@ -87,13 +86,11 @@ ruote is an open source ruby workflow engine.
87
86
  "lib/ruote/parser/ruby_dsl.rb",
88
87
  "lib/ruote/parser/xml.rb",
89
88
  "lib/ruote/part/block_participant.rb",
90
- "lib/ruote/part/dispatch_pool.rb",
91
89
  "lib/ruote/part/engine_participant.rb",
92
90
  "lib/ruote/part/hash_participant.rb",
93
91
  "lib/ruote/part/local_participant.rb",
94
92
  "lib/ruote/part/no_op_participant.rb",
95
93
  "lib/ruote/part/null_participant.rb",
96
- "lib/ruote/part/participant_list.rb",
97
94
  "lib/ruote/part/smtp_participant.rb",
98
95
  "lib/ruote/part/storage_participant.rb",
99
96
  "lib/ruote/part/template.rb",
@@ -103,18 +100,23 @@ ruote is an open source ruby workflow engine.
103
100
  "lib/ruote/storage/composite_storage.rb",
104
101
  "lib/ruote/storage/fs_storage.rb",
105
102
  "lib/ruote/storage/hash_storage.rb",
106
- "lib/ruote/subprocess.rb",
103
+ "lib/ruote/svc/dispatch_pool.rb",
104
+ "lib/ruote/svc/dollar_sub.rb",
105
+ "lib/ruote/svc/error_handler.rb",
106
+ "lib/ruote/svc/expression_map.rb",
107
+ "lib/ruote/svc/participant_list.rb",
108
+ "lib/ruote/svc/tracker.rb",
109
+ "lib/ruote/svc/treechecker.rb",
107
110
  "lib/ruote/tree_dot.rb",
108
- "lib/ruote/util/dollar.rb",
109
111
  "lib/ruote/util/hashdot.rb",
110
112
  "lib/ruote/util/look.rb",
111
113
  "lib/ruote/util/lookup.rb",
112
114
  "lib/ruote/util/misc.rb",
113
115
  "lib/ruote/util/ometa.rb",
114
116
  "lib/ruote/util/serializer.rb",
117
+ "lib/ruote/util/subprocess.rb",
115
118
  "lib/ruote/util/time.rb",
116
119
  "lib/ruote/util/tree.rb",
117
- "lib/ruote/util/treechecker.rb",
118
120
  "lib/ruote/version.rb",
119
121
  "lib/ruote/worker.rb",
120
122
  "lib/ruote/workitem.rb",
@@ -158,6 +160,7 @@ ruote is an open source ruby workflow engine.
158
160
  "test/functional/eft_28_when.rb",
159
161
  "test/functional/eft_29_cron.rb",
160
162
  "test/functional/eft_2_sequence.rb",
163
+ "test/functional/eft_30_ref.rb",
161
164
  "test/functional/eft_3_participant.rb",
162
165
  "test/functional/eft_4_set.rb",
163
166
  "test/functional/eft_5_subprocess.rb",
@@ -198,9 +201,13 @@ ruote is an open source ruby workflow engine.
198
201
  "test/functional/ft_38_participant_more.rb",
199
202
  "test/functional/ft_39_wait_for.rb",
200
203
  "test/functional/ft_3_participant_registration.rb",
201
- "test/functional/ft_40_participant_on_reply.rb",
204
+ "test/functional/ft_40_wait_logger.rb",
202
205
  "test/functional/ft_41_participants.rb",
203
206
  "test/functional/ft_42_storage_copy.rb",
207
+ "test/functional/ft_43_participant_on_reply.rb",
208
+ "test/functional/ft_44_var_participant.rb",
209
+ "test/functional/ft_45_participant_accept.rb",
210
+ "test/functional/ft_46_launch_single.rb",
204
211
  "test/functional/ft_4_cancel.rb",
205
212
  "test/functional/ft_5_on_error.rb",
206
213
  "test/functional/ft_6_on_cancel.rb",
@@ -248,7 +255,7 @@ ruote is an open source ruby workflow engine.
248
255
  s.rdoc_options = ["--charset=UTF-8"]
249
256
  s.require_paths = ["lib"]
250
257
  s.rubyforge_project = %q{ruote}
251
- s.rubygems_version = %q{1.3.5}
258
+ s.rubygems_version = %q{1.3.6}
252
259
  s.summary = %q{an open source ruby workflow engine}
253
260
  s.test_files = [
254
261
  "test/test.rb"
@@ -259,10 +266,9 @@ ruote is an open source ruby workflow engine.
259
266
  s.specification_version = 3
260
267
 
261
268
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
262
- s.add_runtime_dependency(%q<rufus-json>, [">= 0.2.2"])
263
- s.add_runtime_dependency(%q<rufus-cloche>, [">= 0.1.17"])
269
+ s.add_runtime_dependency(%q<rufus-json>, [">= 0.2.5"])
270
+ s.add_runtime_dependency(%q<rufus-cloche>, [">= 0.1.20"])
264
271
  s.add_runtime_dependency(%q<rufus-dollar>, [">= 0"])
265
- s.add_runtime_dependency(%q<rufus-lru>, [">= 0"])
266
272
  s.add_runtime_dependency(%q<rufus-mnemo>, [">= 1.1.0"])
267
273
  s.add_runtime_dependency(%q<rufus-scheduler>, [">= 2.0.5"])
268
274
  s.add_runtime_dependency(%q<rufus-treechecker>, [">= 1.0.3"])
@@ -273,10 +279,9 @@ ruote is an open source ruby workflow engine.
273
279
  s.add_development_dependency(%q<mailtrap>, [">= 0"])
274
280
  s.add_development_dependency(%q<jeweler>, [">= 0"])
275
281
  else
276
- s.add_dependency(%q<rufus-json>, [">= 0.2.2"])
277
- s.add_dependency(%q<rufus-cloche>, [">= 0.1.17"])
282
+ s.add_dependency(%q<rufus-json>, [">= 0.2.5"])
283
+ s.add_dependency(%q<rufus-cloche>, [">= 0.1.20"])
278
284
  s.add_dependency(%q<rufus-dollar>, [">= 0"])
279
- s.add_dependency(%q<rufus-lru>, [">= 0"])
280
285
  s.add_dependency(%q<rufus-mnemo>, [">= 1.1.0"])
281
286
  s.add_dependency(%q<rufus-scheduler>, [">= 2.0.5"])
282
287
  s.add_dependency(%q<rufus-treechecker>, [">= 1.0.3"])
@@ -288,10 +293,9 @@ ruote is an open source ruby workflow engine.
288
293
  s.add_dependency(%q<jeweler>, [">= 0"])
289
294
  end
290
295
  else
291
- s.add_dependency(%q<rufus-json>, [">= 0.2.2"])
292
- s.add_dependency(%q<rufus-cloche>, [">= 0.1.17"])
296
+ s.add_dependency(%q<rufus-json>, [">= 0.2.5"])
297
+ s.add_dependency(%q<rufus-cloche>, [">= 0.1.20"])
293
298
  s.add_dependency(%q<rufus-dollar>, [">= 0"])
294
- s.add_dependency(%q<rufus-lru>, [">= 0"])
295
299
  s.add_dependency(%q<rufus-mnemo>, [">= 1.1.0"])
296
300
  s.add_dependency(%q<rufus-scheduler>, [">= 2.0.5"])
297
301
  s.add_dependency(%q<rufus-treechecker>, [">= 1.0.3"])
@@ -22,6 +22,8 @@ module FunctionalBase
22
22
  #require 'ruote/util/look'
23
23
  #Ruote::Look.dump_lsof
24
24
  #Ruote::Look.dump_lsof_count
25
+ #
26
+ # uncomment this when "too many open files"
25
27
 
26
28
  @engine =
27
29
  Ruote::Engine.new(
@@ -44,6 +46,7 @@ module FunctionalBase
44
46
 
45
47
  @engine.shutdown
46
48
  @engine.context.storage.purge!
49
+ @engine.context.storage.close if @engine.context.storage.respond_to?(:close)
47
50
  end
48
51
 
49
52
  def assert_log_count (count, &block)
@@ -47,6 +47,7 @@ class Ruote::Engine
47
47
  (1..77).to_a.inject({}) { |h, i|
48
48
  #(i % 10).times { Thread.pass }
49
49
  sleep 0.001
50
+ sleep 0.025 # couch :-(
50
51
  m = peek_msg
51
52
  h[m['_id']] = m if m
52
53
  h
@@ -14,6 +14,6 @@ while [ $? == 0 ]
14
14
  do
15
15
  echo " *** $COUNT"
16
16
  ((COUNT=$COUNT + 1))
17
- time ruby $TEST $1 $2
17
+ time ruby -I. $TEST $*
18
18
  done
19
19
 
@@ -13,6 +13,10 @@ require File.join(File.dirname(__FILE__), 'concurrent_base')
13
13
  class CtConcurrenceTest < Test::Unit::TestCase
14
14
  include ConcurrentBase
15
15
 
16
+ # A collision between two workers replying to the same concurrence expression.
17
+ #
18
+ # Worker 0 replies for echo 'a' while worker 1 replies for echo 'b'.
19
+ #
16
20
  def test_collision
17
21
 
18
22
  pdef = Ruote.process_definition do
@@ -41,6 +45,8 @@ class CtConcurrenceTest < Test::Unit::TestCase
41
45
 
42
46
  replies.sort! { |a, b| a['put_at'] <=> b['put_at'] }
43
47
 
48
+ #replies.each { |r| p r }
49
+
44
50
  t0 = Thread.new { @engine1.do_process(replies[0]) }
45
51
  t1 = Thread.new { @engine0.do_process(replies[1]) }
46
52
  t0.join
@@ -11,6 +11,9 @@ require File.join(File.dirname(__FILE__), 'concurrent_base')
11
11
  class CtIteratorTest < Test::Unit::TestCase
12
12
  include ConcurrentBase
13
13
 
14
+ # Test proper handling of collisions between an iterator and another worker
15
+ # passing a stop command.
16
+ #
14
17
  def test_collision
15
18
 
16
19
  pdef = Ruote.process_definition do
@@ -11,6 +11,11 @@ require File.join(File.dirname(__FILE__), 'concurrent_base')
11
11
  class CtCancelTest < Test::Unit::TestCase
12
12
  include ConcurrentBase
13
13
 
14
+ # A collision between a reply and a cancel
15
+ #
16
+ # The first one to occur should neutralize the other (and the flow should
17
+ # not stall).
18
+ #
14
19
  def test_collision
15
20
 
16
21
  pdef = Ruote.process_definition do
@@ -7,6 +7,8 @@
7
7
 
8
8
  require File.join(File.dirname(__FILE__), 'base')
9
9
 
10
+ require 'ruote/participant'
11
+
10
12
 
11
13
  class EftIteratorTest < Test::Unit::TestCase
12
14
  include FunctionalBase
@@ -26,7 +28,15 @@ class EftIteratorTest < Test::Unit::TestCase
26
28
  assert_trace('done.', pdef)
27
29
  end
28
30
 
29
- def test_iterator
31
+ class TraceParticipant
32
+ include Ruote::LocalParticipant
33
+ def consume (wi)
34
+ context.tracer << "#{wi.participant_name}/#{wi.fei.expid}\n"
35
+ reply(wi)
36
+ end
37
+ end
38
+
39
+ def test_on_val
30
40
 
31
41
  pdef = Ruote.process_definition :name => 'test' do
32
42
  iterator :on_val => 'alice, bob, charly', :to_var => 'v' do
@@ -34,15 +44,40 @@ class EftIteratorTest < Test::Unit::TestCase
34
44
  end
35
45
  end
36
46
 
37
- @engine.register_participant '.*' do |workitem|
38
- @tracer << "#{workitem.participant_name}/#{workitem.fei.expid}\n"
39
- end
47
+ @engine.register_participant '.*', TraceParticipant
40
48
 
41
49
  #noisy
42
50
 
43
51
  assert_trace(%w[ alice/0_0_0 bob/0_0_0 charly/0_0_0 ], pdef)
44
52
  end
45
53
 
54
+ def test_on__list
55
+
56
+ pdef = Ruote.process_definition :name => 'test' do
57
+ iterator :on => 'alice, bob, charly', :to_var => 'v' do
58
+ participant '${v:v}'
59
+ end
60
+ end
61
+
62
+ @engine.register_participant '.*', TraceParticipant
63
+
64
+ assert_trace(%w[ alice/0_0_0 bob/0_0_0 charly/0_0_0 ], pdef)
65
+ end
66
+
67
+ def test_on_f
68
+
69
+ pdef = Ruote.process_definition :name => 'test' do
70
+ set :f => 'people', :val => %w[ alice bob charly ]
71
+ iterator :on_f => 'people', :to_var => 'v' do
72
+ participant '${v:v}'
73
+ end
74
+ end
75
+
76
+ @engine.register_participant '.*', TraceParticipant
77
+
78
+ assert_trace(%w[ alice/0_1_0 bob/0_1_0 charly/0_1_0 ], pdef)
79
+ end
80
+
46
81
  def test_to_f
47
82
 
48
83
  pdef = Ruote.process_definition :name => 'test' do
@@ -274,5 +274,44 @@ class EftCursorTest < Test::Unit::TestCase
274
274
 
275
275
  assert_trace 'done.', pdef
276
276
  end
277
+
278
+ class Alpha
279
+ include Ruote::LocalParticipant
280
+ def consume (workitem)
281
+ workitem.command = 'break'
282
+ reply_to_engine(workitem)
283
+ end
284
+ def cancel (fei, flavour)
285
+ end
286
+ end
287
+ class Bravo < Alpha
288
+ def consume (workitem)
289
+ workitem.command = 'skip 1'
290
+ reply_to_engine(workitem)
291
+ end
292
+ end
293
+
294
+ def test_cursor_and_workitem
295
+
296
+ pdef = Ruote.define do
297
+ cursor do
298
+ echo 'in'
299
+ bravo
300
+ echo 'mid'
301
+ alpha
302
+ echo 'out'
303
+ end
304
+ echo 'done.'
305
+ end
306
+
307
+ #noisy
308
+
309
+ @engine.register do
310
+ alpha EftCursorTest::Alpha
311
+ bravo EftCursorTest::Bravo
312
+ end
313
+
314
+ assert_trace "in\ndone.", pdef
315
+ end
277
316
  end
278
317
 
@@ -0,0 +1,140 @@
1
+
2
+ #
3
+ # testing ruote
4
+ #
5
+ # Tue Jul 20 12:47:36 JST 2010
6
+ #
7
+
8
+ require File.join(File.dirname(__FILE__), 'base')
9
+
10
+ require 'ruote/participant'
11
+
12
+
13
+ class EftRefTest < Test::Unit::TestCase
14
+ include FunctionalBase
15
+
16
+ class AlphaParticipant
17
+ include Ruote::LocalParticipant
18
+
19
+ def consume (workitem)
20
+ @context.tracer << workitem.fei.expid
21
+ @context.tracer << "\n"
22
+ reply(workitem)
23
+ end
24
+ end
25
+
26
+ def test_participant
27
+
28
+ pdef = Ruote.process_definition do
29
+ ref :ref => 'alpha'
30
+ ref 'alpha'
31
+ echo 'done.'
32
+ end
33
+
34
+ @engine.register_participant :alpha, AlphaParticipant
35
+
36
+ #noisy
37
+
38
+ assert_trace %w[ 0_0 0_1 done. ], pdef
39
+ end
40
+
41
+ def test_subprocess
42
+
43
+ pdef = Ruote.process_definition do
44
+
45
+ define 'alpha' do
46
+ echo 'alpha'
47
+ end
48
+
49
+ sequence do
50
+ ref :ref => 'alpha'
51
+ ref 'alpha'
52
+ echo 'done.'
53
+ end
54
+ end
55
+
56
+ assert_trace %w[ alpha alpha done. ], pdef
57
+ end
58
+
59
+ def test_missing_participant_ref
60
+
61
+ pdef = Ruote.process_definition do
62
+ ref 'alpha'
63
+ end
64
+
65
+ #noisy
66
+
67
+ wfid = @engine.launch(pdef)
68
+
69
+ @engine.wait_for(wfid)
70
+
71
+ ps = @engine.process(wfid)
72
+
73
+ assert_equal 1, ps.errors.size
74
+
75
+ # correct problem and replay at error
76
+
77
+ @engine.register_participant 'alpha', AlphaParticipant
78
+
79
+ @engine.replay_at_error(ps.errors.first)
80
+
81
+ @engine.wait_for(wfid)
82
+
83
+ assert_nil @engine.process(wfid)
84
+ assert_equal '0_0', @tracer.to_s
85
+ end
86
+
87
+ def test_missing_subprocess_ref
88
+
89
+ pdef = Ruote.process_definition do
90
+ ref 'alpha'
91
+ end
92
+
93
+ #noisy
94
+
95
+ wfid = @engine.launch(pdef)
96
+
97
+ @engine.wait_for(wfid)
98
+
99
+ ps = @engine.process(wfid)
100
+
101
+ assert_equal 1, ps.errors.size
102
+
103
+ # correct problem and replay at error
104
+
105
+ @engine.variables['alpha'] = Ruote.process_definition do
106
+ echo 'alpha'
107
+ end
108
+
109
+ @engine.replay_at_error(ps.errors.first)
110
+
111
+ @engine.wait_for(wfid)
112
+
113
+ assert_nil @engine.process(wfid)
114
+ assert_equal 'alpha', @tracer.to_s
115
+ end
116
+
117
+ # Making sure that the ref expression forces the triggered subprocess to
118
+ # consider its timeout.
119
+ #
120
+ def test_ref_and_subprocess_timeout
121
+
122
+ @engine.register_participant :alpha, Ruote::StorageParticipant
123
+
124
+ pdef = Ruote.process_definition do
125
+ define 'sub0' do
126
+ alpha
127
+ end
128
+ sub0 :timeout => '2d'
129
+ end
130
+
131
+ wfid = @engine.launch(pdef)
132
+ @engine.wait_for(:alpha)
133
+
134
+ scheds = @engine.schedules
135
+
136
+ assert_equal 1, scheds.size
137
+ assert_equal '0_1', scheds.first['target'].expid
138
+ end
139
+ end
140
+
@@ -7,7 +7,7 @@
7
7
 
8
8
  require File.join(File.dirname(__FILE__), 'base')
9
9
 
10
- require 'ruote/part/hash_participant'
10
+ require 'ruote/participant'
11
11
 
12
12
 
13
13
  class EftParticipantTest < Test::Unit::TestCase
@@ -35,58 +35,58 @@ class EftParticipantTest < Test::Unit::TestCase
35
35
  def test_participant_att_text
36
36
 
37
37
  pdef = Ruote.process_definition do
38
- participant :alpha
38
+ participant :bravo
39
39
  end
40
40
 
41
- @engine.register_participant :alpha do |workitem|
42
- @tracer << 'alpha'
41
+ @engine.register_participant :bravo do |workitem|
42
+ @tracer << 'bravo'
43
43
  end
44
44
 
45
45
  #noisy
46
46
 
47
- assert_trace 'alpha', pdef
47
+ assert_trace 'bravo', pdef
48
48
  end
49
49
 
50
50
  def test_participant_exp_name
51
51
 
52
52
  pdef = Ruote.process_definition do
53
- alpha
53
+ charly
54
54
  end
55
55
 
56
- @engine.register_participant :alpha do |workitem|
57
- @tracer << 'alpha'
56
+ @engine.register_participant :charly do |workitem|
57
+ @tracer << 'charly'
58
58
  end
59
59
 
60
60
  #noisy
61
61
 
62
- assert_trace 'alpha', pdef
62
+ assert_trace 'charly', pdef
63
63
  end
64
64
 
65
65
  def test_participant_exp_name_tree_rewriting
66
66
 
67
67
  pdef = Ruote.process_definition do
68
- alpha :tag => 'whatever'
68
+ delta :tag => 'whatever'
69
69
  end
70
70
 
71
- alpha = @engine.register_participant :alpha, Ruote::HashParticipant.new
71
+ delta = @engine.register_participant :delta, Ruote::HashParticipant.new
72
72
 
73
73
  @engine.launch(pdef)
74
- wait_for(:alpha)
74
+ wait_for(:delta)
75
75
 
76
76
  assert_equal(
77
- ['participant', {'tag'=>'whatever', 'ref'=>'alpha'}, []],
78
- Ruote::Exp::FlowExpression.fetch(@engine.context, alpha.first.h.fei).tree)
77
+ ['participant', {'tag'=>'whatever', 'ref'=>'delta'}, []],
78
+ Ruote::Exp::FlowExpression.fetch(@engine.context, delta.first.h.fei).tree)
79
79
  end
80
80
 
81
81
  def test_participant_if
82
82
 
83
83
  pdef = Ruote.process_definition do
84
- alpha
85
- bravo :if => 'false == true'
86
- charly
84
+ eecho
85
+ fox :if => 'false == true'
86
+ gamma
87
87
  end
88
88
 
89
- %w[ alpha bravo charly ].each do |pname|
89
+ %w[ eecho fox gamma ].each do |pname|
90
90
  @engine.register_participant pname do |workitem|
91
91
  @tracer << "#{pname}\n"
92
92
  end
@@ -94,7 +94,7 @@ class EftParticipantTest < Test::Unit::TestCase
94
94
 
95
95
  #noisy
96
96
 
97
- assert_trace %w[ alpha charly ], pdef
97
+ assert_trace %w[ eecho gamma ], pdef
98
98
  end
99
99
 
100
100
  def test_participant_and_att_text
@@ -122,19 +122,21 @@ class EftParticipantTest < Test::Unit::TestCase
122
122
 
123
123
  def test_dispatched
124
124
 
125
- part = @engine.register_participant :alpha do
126
- sleep 1
125
+ @engine.register_participant :hotel do
126
+ sleep 5
127
127
  end
128
128
 
129
129
  pdef = Ruote.process_definition do
130
- alpha
130
+ hotel
131
131
  end
132
132
 
133
133
  #noisy
134
134
 
135
135
  wfid = @engine.launch(pdef)
136
136
 
137
- wait_for(:alpha)
137
+ #wait_for(:hotel)
138
+ sleep 0.777
139
+ sleep 1 # just for ruote-couch :-(
138
140
 
139
141
  ps = @engine.process(wfid)
140
142
 
@@ -154,7 +154,7 @@ class FtDollarTest < Test::Unit::TestCase
154
154
  assert_trace 'AA', pdef
155
155
  end
156
156
 
157
- def test_wfid
157
+ def test_fei_and_wfid
158
158
 
159
159
  pdef = Ruote.process_definition do
160
160
  sequence do
@@ -169,5 +169,21 @@ class FtDollarTest < Test::Unit::TestCase
169
169
 
170
170
  assert_equal "0_0_0!!#{wfid}\n#{wfid}", @tracer.to_s
171
171
  end
172
+
173
+ def test_direct_access_to_fields
174
+
175
+ pdef = Ruote.process_definition do
176
+ sequence do
177
+ set 'f:a' => [ 'alpha', 'bravo', 'charly' ]
178
+ echo '${r:a.join("/")}'
179
+ end
180
+ end
181
+
182
+ @engine.context['ruby_eval_allowed'] = true
183
+
184
+ #noisy
185
+
186
+ assert_trace 'alpha/bravo/charly', pdef
187
+ end
172
188
  end
173
189