ruote 2.1.9 → 2.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/CHANGELOG.txt +32 -0
  2. data/CREDITS.txt +3 -0
  3. data/Rakefile +4 -4
  4. data/TODO.txt +55 -11
  5. data/examples/barley.rb +2 -1
  6. data/examples/flickr_report.rb +5 -6
  7. data/examples/web_first_page.rb +11 -0
  8. data/lib/ruote/context.rb +36 -13
  9. data/lib/ruote/engine.rb +88 -56
  10. data/lib/ruote/engine/process_error.rb +13 -0
  11. data/lib/ruote/engine/process_status.rb +33 -1
  12. data/lib/ruote/error_handler.rb +122 -0
  13. data/lib/ruote/evt/tracker.rb +27 -10
  14. data/lib/ruote/exp/fe_apply.rb +69 -0
  15. data/lib/ruote/exp/fe_participant.rb +33 -5
  16. data/lib/ruote/exp/flowexpression.rb +37 -5
  17. data/lib/ruote/exp/ro_persist.rb +8 -4
  18. data/lib/ruote/exp/ro_variables.rb +2 -2
  19. data/lib/ruote/fei.rb +59 -7
  20. data/lib/ruote/log/storage_history.rb +2 -0
  21. data/lib/ruote/log/test_logger.rb +28 -19
  22. data/lib/ruote/log/wait_logger.rb +4 -2
  23. data/lib/ruote/parser.rb +2 -1
  24. data/lib/ruote/part/dispatch_pool.rb +10 -10
  25. data/lib/ruote/part/engine_participant.rb +2 -2
  26. data/lib/ruote/part/local_participant.rb +99 -7
  27. data/lib/ruote/part/participant_list.rb +18 -7
  28. data/lib/ruote/part/storage_participant.rb +9 -6
  29. data/lib/ruote/receiver/base.rb +109 -10
  30. data/lib/ruote/storage/base.rb +118 -41
  31. data/lib/ruote/storage/fs_storage.rb +1 -0
  32. data/lib/ruote/storage/hash_storage.rb +2 -1
  33. data/lib/ruote/util/lookup.rb +22 -2
  34. data/lib/ruote/util/misc.rb +5 -5
  35. data/lib/ruote/version.rb +1 -1
  36. data/lib/ruote/worker.rb +50 -63
  37. data/lib/ruote/workitem.rb +64 -0
  38. data/ruote.gemspec +17 -12
  39. data/test/functional/base.rb +3 -1
  40. data/test/functional/concurrent_base.rb +35 -29
  41. data/test/functional/crunner.sh +19 -0
  42. data/test/functional/ct_0_concurrence.rb +17 -30
  43. data/test/functional/ct_1_iterator.rb +20 -17
  44. data/test/functional/ct_2_cancel.rb +32 -25
  45. data/test/functional/eft_12_listen.rb +2 -1
  46. data/test/functional/eft_23_apply.rb +23 -0
  47. data/test/functional/eft_3_participant.rb +27 -0
  48. data/test/functional/ft_11_recursion.rb +1 -1
  49. data/test/functional/ft_13_variables.rb +22 -0
  50. data/test/functional/ft_14_re_apply.rb +3 -0
  51. data/test/functional/ft_15_timeout.rb +1 -0
  52. data/test/functional/ft_20_storage_participant.rb +20 -2
  53. data/test/functional/ft_21_forget.rb +30 -0
  54. data/test/functional/ft_22_process_definitions.rb +2 -1
  55. data/test/functional/ft_24_block_participants.rb +1 -1
  56. data/test/functional/ft_25_receiver.rb +83 -1
  57. data/test/functional/ft_26_participant_timeout.rb +1 -1
  58. data/test/functional/ft_2_errors.rb +2 -5
  59. data/test/functional/ft_30_smtp_participant.rb +47 -45
  60. data/test/functional/ft_36_storage_history.rb +4 -4
  61. data/test/functional/ft_37_engine_participant.rb +14 -10
  62. data/test/functional/ft_38_participant_more.rb +178 -0
  63. data/test/functional/ft_39_wait_for.rb +100 -0
  64. data/test/functional/ft_40_participant_on_reply.rb +87 -0
  65. data/test/functional/ft_41_participants.rb +65 -0
  66. data/test/functional/ft_42_storage_copy.rb +67 -0
  67. data/test/functional/ft_5_on_error.rb +103 -0
  68. data/test/functional/ft_9_subprocesses.rb +2 -1
  69. data/test/functional/storage_helper.rb +5 -1
  70. data/test/functional/test.rb +4 -1
  71. data/test/functional/vertical.rb +46 -0
  72. data/test/unit/storage.rb +17 -1
  73. data/test/unit/storages.rb +27 -7
  74. data/test/unit/ut_11_lookup.rb +36 -0
  75. data/test/unit/ut_16_parser.rb +43 -0
  76. data/test/unit/ut_1_fei.rb +28 -1
  77. data/test/unit/ut_7_workitem.rb +23 -0
  78. metadata +67 -105
  79. data/lib/ruote/log/fs_history.rb +0 -182
  80. data/test/functional/ft_32_fs_history.rb +0 -188
  81. data/test/mpc_test.rb +0 -29
@@ -1,188 +0,0 @@
1
-
2
- #
3
- # testing ruote
4
- #
5
- # Sun Oct 4 00:14:27 JST 2009
6
- #
7
-
8
- require File.join(File.dirname(__FILE__), 'base')
9
-
10
- require_json
11
- Rufus::Json.detect_backend rescue nil
12
-
13
- require 'ruote/log/fs_history'
14
- require 'ruote/part/no_op_participant'
15
-
16
-
17
- class FtFsHistoryTest < Test::Unit::TestCase
18
- include FunctionalBase
19
-
20
- def test_launch
21
-
22
- pdef = Ruote.process_definition do
23
- alpha
24
- echo 'done.'
25
- end
26
-
27
- history = @engine.add_service(
28
- 'history', 'ruote/log/fs_history', 'Ruote::FsHistory')
29
-
30
- @engine.register_participant :alpha, Ruote::NoOpParticipant
31
-
32
- #noisy
33
-
34
- wfid0 = assert_trace("done.", pdef)
35
- wfid1 = assert_trace("done.\ndone.", pdef)
36
-
37
- sleep 0.100
38
-
39
- lines = File.readlines(Dir['work/log/*'].first)
40
-
41
- assert_equal 17, lines.size
42
- #lines.each { |l| puts l }
43
-
44
- h = @engine.context.history.by_process(wfid0)
45
- #h.each { |r| p r }
46
- assert_equal 8, h.size
47
-
48
- # testing record.to_h
49
-
50
- h = @engine.context.history.by_process(wfid1)
51
- #h.each { |r| p r }
52
- assert_equal 8, h.size
53
-
54
- ensure
55
-
56
- @engine.context.history.shutdown
57
- Dir['work/log/*'].each { |fn| FileUtils.rm(fn) }
58
- end
59
-
60
- def test_subprocess
61
-
62
- pdef = Ruote.process_definition :name => 'test', :revision => '3' do
63
- sequence do
64
- sub0
65
- echo 'done.'
66
- end
67
- define 'sub0' do
68
- alpha
69
- end
70
- end
71
-
72
- history = @engine.add_service(
73
- 'history', 'ruote/log/fs_history', 'Ruote::FsHistory',
74
- 'history_path' => 'work/log2')
75
-
76
- @engine.register_participant :alpha, Ruote::NoOpParticipant
77
-
78
- #noisy
79
-
80
- wfid0 = assert_trace("done.", pdef)
81
-
82
- sleep 0.100
83
-
84
- h = @engine.context.history.by_process(wfid0)
85
- #h.each { |r| p r }
86
- assert_equal 11, h.size
87
-
88
- ensure
89
-
90
- @engine.context.history.shutdown
91
- Dir['work/log2/*'].each { |fn| FileUtils.rm(fn) }
92
- end
93
-
94
- def test_errors
95
-
96
- pdef = Ruote.process_definition :name => 'test' do
97
- nada
98
- end
99
-
100
- history = @engine.add_service(
101
- 'history', 'ruote/log/fs_history', 'Ruote::FsHistory')
102
-
103
- #noisy
104
-
105
- wfid = @engine.launch(pdef)
106
- wait_for(wfid)
107
-
108
- sleep 0.100
109
-
110
- h = @engine.context.history.by_process(wfid)
111
- #h.each { |r| p r }
112
- assert_equal 2, h.size
113
-
114
- ensure
115
-
116
- @engine.context.history.shutdown
117
- Dir['work/log/*'].each { |fn| FileUtils.rm(fn) }
118
- end
119
-
120
- def test_cancelling_failed_exp
121
-
122
- pdef = Ruote.process_definition :name => 'test' do
123
- nada
124
- end
125
-
126
- history = @engine.add_service(
127
- 'history', 'ruote/log/fs_history', 'Ruote::FsHistory')
128
-
129
- #noisy
130
-
131
- wfid = @engine.launch(pdef)
132
- wait_for(wfid)
133
-
134
- fei = @engine.process(wfid).errors.first.fei
135
-
136
- @engine.cancel_expression(fei)
137
- wait_for(wfid)
138
-
139
- sleep 0.100
140
-
141
- h = @engine.context.history.by_process(wfid)
142
- #h.each { |r| p r }
143
- assert_equal 5, h.size
144
-
145
- ensure
146
-
147
- @engine.context.history.shutdown
148
- Dir['work/log/*'].each { |fn| FileUtils.rm(fn) }
149
- end
150
-
151
- def test_history_date
152
-
153
- history = @engine.add_service(
154
- 'history', 'ruote/log/fs_history', 'Ruote::FsHistory')
155
-
156
- FileUtils.mkdir(File.join(@engine.workdir, 'log')) rescue nil
157
-
158
- File.open(File.join('work', 'log', 'history_2009-10-08.json'), 'w') do |f|
159
- f.puts(%{
160
- ["!2009-10-08!12:33:27.835469",{"wfid":"20091224-beretsureto","tree":["define",{},[["alpha",{},[]],["echo",{"done.":null},[]]]],"workitem":{"fields":{},"fei":{"engine_id":"engine","wfid":"20091224-beretsureto","expid":"0"}},"variables":{},"type":"msgs","_id":"17619-2151883888-1261658007.83374","action":"launch","_rev":0,"put_at":"2009/12/24 12:33:27.833769 UTC"}]
161
- ["!2009-10-08!12:33:27.836787",{"fei":{"engine_id":"engine","wfid":"20091224-beretsureto","expid":"0_0"},"tree":["participant",{"ref":"alpha"},[]],"parent_id":{"engine_id":"engine","wfid":"20091224-beretsureto","expid":"0"},"variables":null,"workitem":{"fields":{"params":{"ref":"alpha"}},"fei":{"engine_id":"engine","wfid":"20091224-beretsureto","expid":"0_0"},"participant_name":"alpha"},"type":"msgs","_id":"17619-2157823640-1261658007.83534","action":"apply","_rev":0,"put_at":"2009/12/24 12:33:27.835369 UTC"}]
162
- ["!2009-10-08!12:33:27.837098",{"fei":{"engine_id":"engine","wfid":"20091224-beretsureto","expid":"0_0"},"participant_name":"alpha","workitem":{"fields":{"params":{"ref":"alpha"}},"fei":{"engine_id":"engine","wfid":"20091224-beretsureto","expid":"0_0"},"participant_name":"alpha"},"for_engine_worker?":false,"type":"msgs","_id":"17619-2157823640-1261658007.83666","action":"dispatch","_rev":0,"put_at":"2009/12/24 12:33:27.836690 UTC"}]
163
- }.strip)
164
- end
165
-
166
- File.open(File.join('work', 'log', 'history_2009-10-31.json'), 'w') do |f|
167
- f.puts(%{
168
- ["!2009-10-31!12:33:27.835469",{"wfid":"20091224-beretsureto","tree":["define",{},[["alpha",{},[]],["echo",{"done.":null},[]]]],"workitem":{"fields":{},"fei":{"engine_id":"engine","wfid":"20091224-beretsureto","expid":"0"}},"variables":{},"type":"msgs","_id":"17619-2151883888-1261658007.83374","action":"launch","_rev":0,"put_at":"2009/12/24 12:33:27.833769 UTC"}]
169
- ["!2009-10-31!12:33:27.836787",{"fei":{"engine_id":"engine","wfid":"20091224-beretsureto","expid":"0_0"},"tree":["participant",{"ref":"alpha"},[]],"parent_id":{"engine_id":"engine","wfid":"20091224-beretsureto","expid":"0"},"variables":null,"workitem":{"fields":{"params":{"ref":"alpha"}},"fei":{"engine_id":"engine","wfid":"20091224-beretsureto","expid":"0_0"},"participant_name":"alpha"},"type":"msgs","_id":"17619-2157823640-1261658007.83534","action":"apply","_rev":0,"put_at":"2009/12/24 12:33:27.835369 UTC"}]
170
- ["!2009-10-31!12:33:27.837098",{"fei":{"engine_id":"engine","wfid":"20091224-beretsureto","expid":"0_0"},"participant_name":"alpha","workitem":{"fields":{"params":{"ref":"alpha"}},"fei":{"engine_id":"engine","wfid":"20091224-beretsureto","expid":"0_0"},"participant_name":"alpha"},"for_engine_worker?":false,"type":"msgs","_id":"17619-2157823640-1261658007.83666","action":"dispatch","_rev":0,"put_at":"2009/12/24 12:33:27.836690 UTC"}]
171
- ["!2009-10-31!12:33:27.837961",{"fei":{"engine_id":"engine","wfid":"20091224-beretsureto","expid":"0_0"},"workitem":{"fields":{},"fei":{"engine_id":"engine","wfid":"20091224-beretsureto","expid":"0_0"},"participant_name":"alpha"},"participant_name":"alpha","type":"msgs","_id":"17619-2159486252-1261658007.83719","action":"receive","_rev":0,"put_at":"2009/12/24 12:33:27.837235 UTC"}]
172
- }.strip)
173
- end
174
-
175
- assert_equal 3, @engine.context.history.by_date('2009-10-08').size
176
- assert_equal 4, @engine.context.history.by_date('2009-10-31').size
177
-
178
- assert_equal(
179
- [ Time.parse(Time.now.strftime('%Y-%m-%d')), Time.parse('2009-10-08') ],
180
- @engine.context.history.range)
181
-
182
- ensure
183
-
184
- @engine.context.history.shutdown
185
- Dir['work/log/*'].each { |fn| FileUtils.rm(fn) }
186
- end
187
- end
188
-
@@ -1,29 +0,0 @@
1
-
2
- #
3
- # multi process concurrence test
4
- #
5
-
6
- t = Time.now
7
-
8
- N = 100
9
- failures = 0
10
-
11
- N.times do |i|
12
-
13
- #o = `ruby19 test/functional/ct_0_concurrence.rb -n test_collision --dm`
14
- o = `ruby19 test/functional/ct_0_concurrence.rb -n test_collision #{ARGV[0]}`
15
-
16
- if $?.exitstatus == 0
17
- print '.'
18
- puts(o) if i == 0
19
- else
20
- failures += 1
21
- print 'x'
22
- puts; puts(o)
23
- end
24
- STDOUT.flush
25
- end
26
-
27
- puts
28
- puts "failures : #{failures}/#{N} #{(Time.now - t).to_f} seconds"
29
-