ruote 2.1.7 → 2.1.8
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.
- data/CHANGELOG.txt +13 -0
- data/CREDITS.txt +2 -1
- data/Rakefile +4 -3
- data/TODO.txt +11 -1
- data/lib/ruote/exp/fe_concurrence.rb +26 -2
- data/lib/ruote/exp/fe_participant.rb +1 -1
- data/lib/ruote/exp/merge.rb +16 -9
- data/lib/ruote/fei.rb +1 -1
- data/lib/ruote/parser.rb +2 -1
- data/lib/ruote/part/smtp_participant.rb +22 -41
- data/lib/ruote/part/storage_participant.rb +20 -1
- data/lib/ruote/part/template.rb +34 -18
- data/lib/ruote/storage/base.rb +2 -20
- data/lib/ruote/storage/composite_storage.rb +134 -0
- data/lib/ruote/storage/fs_storage.rb +15 -1
- data/lib/ruote/util/dollar.rb +1 -0
- data/lib/ruote/util/misc.rb +5 -1
- data/lib/ruote/util/time.rb +13 -3
- data/lib/ruote/version.rb +1 -1
- data/lib/ruote/worker.rb +2 -2
- data/ruote.gemspec +18 -12
- data/test/bm/seq_thousand.rb +1 -1
- data/test/functional/base.rb +6 -8
- data/test/functional/crunner.rb +2 -0
- data/test/functional/eft_0_process_definition.rb +2 -2
- data/test/functional/eft_10_cancel_process.rb +2 -2
- data/test/functional/eft_11_wait.rb +3 -3
- data/test/functional/eft_12_listen.rb +1 -1
- data/test/functional/eft_13_iterator.rb +14 -14
- data/test/functional/eft_14_cursor.rb +12 -12
- data/test/functional/eft_15_loop.rb +2 -2
- data/test/functional/eft_16_if.rb +11 -15
- data/test/functional/eft_17_equals.rb +2 -2
- data/test/functional/eft_18_concurrent_iterator.rb +35 -8
- data/test/functional/eft_1_echo.rb +1 -1
- data/test/functional/eft_21_restore.rb +3 -3
- data/test/functional/eft_22_noop.rb +1 -1
- data/test/functional/eft_23_apply.rb +9 -9
- data/test/functional/eft_25_command.rb +1 -1
- data/test/functional/eft_27_inc.rb +12 -12
- data/test/functional/eft_28_when.rb +4 -4
- data/test/functional/eft_2_sequence.rb +3 -3
- data/test/functional/eft_3_participant.rb +5 -5
- data/test/functional/eft_4_set.rb +12 -12
- data/test/functional/eft_5_subprocess.rb +8 -8
- data/test/functional/eft_6_concurrence.rb +17 -4
- data/test/functional/eft_7_forget.rb +1 -1
- data/test/functional/eft_8_undo.rb +3 -3
- data/test/functional/ft_0_worker.rb +17 -1
- data/test/functional/ft_10_dollar.rb +9 -9
- data/test/functional/ft_11_recursion.rb +2 -2
- data/test/functional/ft_13_variables.rb +4 -4
- data/test/functional/ft_17_conditional.rb +5 -5
- data/test/functional/ft_19_alias.rb +1 -1
- data/test/functional/ft_1_process_status.rb +1 -1
- data/test/functional/ft_20_storage_participant.rb +2 -0
- data/test/functional/ft_22_process_definitions.rb +11 -4
- data/test/functional/ft_24_block_participants.rb +13 -4
- data/test/functional/ft_27_var_indirection.rb +5 -5
- data/test/functional/ft_28_null_noop_participants.rb +1 -1
- data/test/functional/ft_29_part_template.rb +4 -23
- data/test/functional/ft_30_smtp_participant.rb +50 -4
- data/test/functional/ft_32_fs_history.rb +4 -8
- data/test/functional/ft_33_participant_subprocess_priority.rb +1 -1
- data/test/functional/ft_36_storage_history.rb +2 -2
- data/test/functional/ft_5_on_error.rb +5 -5
- data/test/functional/ft_8_participant_consumption.rb +2 -2
- data/test/path_helper.rb +1 -1
- data/test/test_helper.rb +17 -0
- data/test/unit/storage.rb +2 -17
- data/test/unit/ut_19_part_template.rb +76 -0
- data/test/unit/ut_1_fei.rb +13 -0
- data/test/unit/ut_20_composite_storage.rb +34 -0
- metadata +111 -55
@@ -20,14 +20,15 @@ class FtPartTemplateTest < Test::Unit::TestCase
|
|
20
20
|
|
21
21
|
def initialize (opts={}, &block)
|
22
22
|
|
23
|
-
@block_template = block
|
24
23
|
@template = opts[:template]
|
25
24
|
end
|
26
25
|
|
27
26
|
def consume (workitem)
|
28
27
|
|
29
28
|
@context['s_tracer'] << render_template(
|
30
|
-
|
29
|
+
@template,
|
30
|
+
Ruote::Exp::FlowExpression.fetch(@context, workitem.fei.to_h),
|
31
|
+
workitem)
|
31
32
|
@context['s_tracer'] << "\n"
|
32
33
|
|
33
34
|
reply_to_engine(workitem)
|
@@ -52,27 +53,7 @@ class FtPartTemplateTest < Test::Unit::TestCase
|
|
52
53
|
:alpha,
|
53
54
|
MyParticipant.new(:template => "0:${v:var0}\n1:${f:field0}"))
|
54
55
|
|
55
|
-
assert_trace
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_block_template
|
59
|
-
|
60
|
-
pdef = Ruote.process_definition :name => 'def0' do
|
61
|
-
set 'v:var0' => 'v_value'
|
62
|
-
set 'f:field0' => 'f_value'
|
63
|
-
alpha
|
64
|
-
echo 'done.'
|
65
|
-
end
|
66
|
-
|
67
|
-
#noisy
|
68
|
-
|
69
|
-
@engine.register_participant(
|
70
|
-
:alpha,
|
71
|
-
MyParticipant.new {
|
72
|
-
"0:${v:var0}\n1:${f:field0}"
|
73
|
-
})
|
74
|
-
|
75
|
-
assert_trace pdef, %w[ 0:v_value 1:f_value done. ]
|
56
|
+
assert_trace %w[ 0:v_value 1:f_value done. ], pdef
|
76
57
|
end
|
77
58
|
end
|
78
59
|
|
@@ -13,7 +13,7 @@ require 'ruote/part/smtp_participant'
|
|
13
13
|
class NftSmtpParticipantTest < Test::Unit::TestCase
|
14
14
|
include FunctionalBase
|
15
15
|
|
16
|
-
|
16
|
+
unless Ruote::JAVA
|
17
17
|
|
18
18
|
require 'mailtrap' # sudo gem install mailtrap
|
19
19
|
|
@@ -24,9 +24,9 @@ class NftSmtpParticipantTest < Test::Unit::TestCase
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def _test_smtp
|
28
28
|
|
29
|
-
return if
|
29
|
+
return if Ruote::JAVA
|
30
30
|
|
31
31
|
pdef = Ruote.process_definition :name => 'test' do
|
32
32
|
sequence do
|
@@ -38,7 +38,7 @@ class NftSmtpParticipantTest < Test::Unit::TestCase
|
|
38
38
|
trapfile = Ruote::WIN ? 'ruote_mailtrap.txt' : '/tmp/ruote_mailtrap.txt'
|
39
39
|
FileUtils.rm_f(trapfile)
|
40
40
|
|
41
|
-
Thread.new do
|
41
|
+
t = Thread.new do
|
42
42
|
Trap.new('127.0.0.1', 2525, true, trapfile)
|
43
43
|
end
|
44
44
|
sleep 0.040
|
@@ -64,6 +64,52 @@ class NftSmtpParticipantTest < Test::Unit::TestCase
|
|
64
64
|
|
65
65
|
assert_match(/cat food/, File.read(trapfile))
|
66
66
|
assert_nil @engine.process(wfid)
|
67
|
+
|
68
|
+
t.kill
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_smtp_non_instance_participant
|
72
|
+
|
73
|
+
return if Ruote::JAVA
|
74
|
+
|
75
|
+
pdef = Ruote.process_definition :name => 'test' do
|
76
|
+
sequence do
|
77
|
+
set 'f:item' => 'cat food'
|
78
|
+
alpha
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
trapfile = Ruote::WIN ? 'ruote_mailtrap.txt' : '/tmp/ruote_mailtrap.txt'
|
83
|
+
FileUtils.rm_f(trapfile)
|
84
|
+
|
85
|
+
t = Thread.new do
|
86
|
+
Trap.new('127.0.0.1', 2525, true, trapfile)
|
87
|
+
end
|
88
|
+
sleep 0.040
|
89
|
+
# give it some time to start listening
|
90
|
+
|
91
|
+
@engine.register_participant(
|
92
|
+
:alpha,
|
93
|
+
Ruote::SmtpParticipant,
|
94
|
+
:server => '127.0.0.1',
|
95
|
+
:port => 2525,
|
96
|
+
:to => 'toto@cloudwhatever.ch',
|
97
|
+
:from => 'john@outoftheblue.ch',
|
98
|
+
:notification => true,
|
99
|
+
:template => %{
|
100
|
+
Hello, do you want ${f:item} ?
|
101
|
+
})
|
102
|
+
|
103
|
+
#noisy
|
104
|
+
|
105
|
+
wfid = @engine.launch(pdef)
|
106
|
+
|
107
|
+
sleep 0.450
|
108
|
+
|
109
|
+
assert_match(/cat food/, File.read(trapfile))
|
110
|
+
assert_nil @engine.process(wfid)
|
111
|
+
|
112
|
+
t.kill
|
67
113
|
end
|
68
114
|
end
|
69
115
|
|
@@ -7,11 +7,7 @@
|
|
7
7
|
|
8
8
|
require File.join(File.dirname(__FILE__), 'base')
|
9
9
|
|
10
|
-
|
11
|
-
require 'yajl'
|
12
|
-
rescue LoadError
|
13
|
-
require 'json'
|
14
|
-
end
|
10
|
+
require_json
|
15
11
|
Rufus::Json.detect_backend rescue nil
|
16
12
|
|
17
13
|
require 'ruote/log/fs_history'
|
@@ -35,8 +31,8 @@ class FtFsHistoryTest < Test::Unit::TestCase
|
|
35
31
|
|
36
32
|
#noisy
|
37
33
|
|
38
|
-
wfid0 = assert_trace(
|
39
|
-
wfid1 = assert_trace(
|
34
|
+
wfid0 = assert_trace("done.", pdef)
|
35
|
+
wfid1 = assert_trace("done.\ndone.", pdef)
|
40
36
|
|
41
37
|
sleep 0.100
|
42
38
|
|
@@ -81,7 +77,7 @@ class FtFsHistoryTest < Test::Unit::TestCase
|
|
81
77
|
|
82
78
|
#noisy
|
83
79
|
|
84
|
-
wfid0 = assert_trace(
|
80
|
+
wfid0 = assert_trace("done.", pdef)
|
85
81
|
|
86
82
|
sleep 0.100
|
87
83
|
|
@@ -28,8 +28,8 @@ class FtStorageHistoryTest < Test::Unit::TestCase
|
|
28
28
|
|
29
29
|
#noisy
|
30
30
|
|
31
|
-
wfid0 = assert_trace(
|
32
|
-
wfid1 = assert_trace(
|
31
|
+
wfid0 = assert_trace("done.", pdef)
|
32
|
+
wfid1 = assert_trace("done.\ndone.", pdef)
|
33
33
|
|
34
34
|
sleep 0.100
|
35
35
|
|
@@ -25,7 +25,7 @@ class FtOnErrorTest < Test::Unit::TestCase
|
|
25
25
|
|
26
26
|
#noisy
|
27
27
|
|
28
|
-
assert_trace(
|
28
|
+
assert_trace('caught', pdef)
|
29
29
|
|
30
30
|
assert_equal 1, logger.log.select { |e| e['action'] == 'fail' }.size
|
31
31
|
end
|
@@ -72,7 +72,7 @@ class FtOnErrorTest < Test::Unit::TestCase
|
|
72
72
|
|
73
73
|
#noisy
|
74
74
|
|
75
|
-
assert_trace(
|
75
|
+
assert_trace(%w[ 1 2 done. ], pdef)
|
76
76
|
end
|
77
77
|
|
78
78
|
def test_on_error_undo
|
@@ -91,7 +91,7 @@ class FtOnErrorTest < Test::Unit::TestCase
|
|
91
91
|
|
92
92
|
#noisy
|
93
93
|
|
94
|
-
wfid = assert_trace(
|
94
|
+
wfid = assert_trace(%w[ a b d ], pdef)
|
95
95
|
|
96
96
|
assert_nil @engine.process(wfid)
|
97
97
|
end
|
@@ -124,7 +124,7 @@ class FtOnErrorTest < Test::Unit::TestCase
|
|
124
124
|
|
125
125
|
#noisy
|
126
126
|
|
127
|
-
assert_trace(
|
127
|
+
assert_trace('failed.', pdef)
|
128
128
|
end
|
129
129
|
|
130
130
|
def test_with_concurrence
|
@@ -147,7 +147,7 @@ class FtOnErrorTest < Test::Unit::TestCase
|
|
147
147
|
|
148
148
|
#noisy
|
149
149
|
|
150
|
-
assert_trace
|
150
|
+
assert_trace 'done.', pdef
|
151
151
|
assert_equal 1, a_count
|
152
152
|
assert_equal 1, e_count
|
153
153
|
end
|
@@ -25,7 +25,7 @@ class FtParticipantConsumptionTest < Test::Unit::TestCase
|
|
25
25
|
|
26
26
|
#noisy
|
27
27
|
|
28
|
-
assert_trace(
|
28
|
+
assert_trace('alpha', pdef)
|
29
29
|
|
30
30
|
Thread.pass
|
31
31
|
# making sure the reply to the participant expression is intercepted
|
@@ -69,7 +69,7 @@ class FtParticipantConsumptionTest < Test::Unit::TestCase
|
|
69
69
|
@tracer << "#{workitem.participant_name} #{workitem.fei.expid}\n"
|
70
70
|
end
|
71
71
|
|
72
|
-
assert_trace(
|
72
|
+
assert_trace('alpha 0_0_0', pdef)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
data/test/path_helper.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -10,3 +10,20 @@ require File.join(File.dirname(__FILE__), 'path_helper')
|
|
10
10
|
require 'test/unit'
|
11
11
|
require 'rubygems'
|
12
12
|
|
13
|
+
|
14
|
+
def require_json
|
15
|
+
begin
|
16
|
+
require 'yajl'
|
17
|
+
rescue LoadError
|
18
|
+
require 'json'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def require_patron
|
23
|
+
begin
|
24
|
+
require 'patron'
|
25
|
+
rescue LoadError
|
26
|
+
# stick with net/http
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
data/test/unit/storage.rb
CHANGED
@@ -7,16 +7,8 @@
|
|
7
7
|
|
8
8
|
require File.join(File.dirname(__FILE__), %w[ .. test_helper.rb ])
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
rescue LoadError
|
13
|
-
require 'json'
|
14
|
-
end
|
15
|
-
begin
|
16
|
-
require 'patron'
|
17
|
-
rescue LoadError
|
18
|
-
# stick with net/http
|
19
|
-
end
|
10
|
+
require_json
|
11
|
+
require_patron
|
20
12
|
|
21
13
|
require File.join(File.dirname(__FILE__), %w[ .. functional storage_helper.rb ])
|
22
14
|
|
@@ -125,13 +117,6 @@ class UtStorage < Test::Unit::TestCase
|
|
125
117
|
|
126
118
|
def test_keys_should_be_string
|
127
119
|
|
128
|
-
#begin
|
129
|
-
# require 'yajl'
|
130
|
-
#rescue LoadError
|
131
|
-
# require 'json'
|
132
|
-
#end
|
133
|
-
#Rufus::Json.detect_backend
|
134
|
-
|
135
120
|
doc = { '_id' => 'h0', 'type' => 'dogfood', :m0 => :z, :m1 => [ :a, :b ] }
|
136
121
|
|
137
122
|
@s.put(doc)
|
@@ -0,0 +1,76 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Thu Mar 4 10:24:30 JST 2010
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), '..', 'test_helper.rb')
|
9
|
+
|
10
|
+
require_json
|
11
|
+
require 'ruote/part/template'
|
12
|
+
|
13
|
+
|
14
|
+
class UtPartTemplateTest < Test::Unit::TestCase
|
15
|
+
|
16
|
+
class MyParticipant
|
17
|
+
include ::Ruote::TemplateMixin
|
18
|
+
end
|
19
|
+
|
20
|
+
DEFAULT = %{
|
21
|
+
workitem for gonzalo
|
22
|
+
|
23
|
+
{"wfid":"20100304-bidehachina","expid":"0_0_1"}
|
24
|
+
|
25
|
+
- 'car' ==> "BMW"
|
26
|
+
- 'model' ==> "BMW 328 Mille Miglia"
|
27
|
+
}.strip
|
28
|
+
|
29
|
+
def setup
|
30
|
+
|
31
|
+
@workitem = {
|
32
|
+
'fei'=> { 'wfid' => '20100304-bidehachina', 'expid' => '0_0_1' },
|
33
|
+
'participant_name' => 'gonzalo',
|
34
|
+
'fields' => {
|
35
|
+
'car' => 'BMW',
|
36
|
+
'model' => 'BMW 328 Mille Miglia'
|
37
|
+
}
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_default_template
|
42
|
+
|
43
|
+
assert_equal(
|
44
|
+
DEFAULT,
|
45
|
+
MyParticipant.new.render_default_template(@workitem))
|
46
|
+
|
47
|
+
assert_equal(
|
48
|
+
DEFAULT,
|
49
|
+
MyParticipant.new.render_template(nil, nil, @workitem))
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_file_template
|
53
|
+
|
54
|
+
fn = "#{__FILE__}.template"
|
55
|
+
|
56
|
+
File.open(fn, 'wb') { |f| f.write('the model is ${f:model}') }
|
57
|
+
|
58
|
+
assert_equal(
|
59
|
+
'the model is BMW 328 Mille Miglia',
|
60
|
+
MyParticipant.new.render_template(fn, nil, @workitem))
|
61
|
+
|
62
|
+
FileUtils.rm_f(fn)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_string_template
|
66
|
+
|
67
|
+
template = %{
|
68
|
+
My car is a ${f:car}
|
69
|
+
}.strip
|
70
|
+
|
71
|
+
assert_equal(
|
72
|
+
'My car is a BMW',
|
73
|
+
MyParticipant.new.render_template(template, nil, @workitem))
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
data/test/unit/ut_1_fei.rb
CHANGED
@@ -74,5 +74,18 @@ class UtFeiTest < Test::Unit::TestCase
|
|
74
74
|
assert_equal f0.hash, f1.hash
|
75
75
|
assert_not_equal f0.hash, f2.hash
|
76
76
|
end
|
77
|
+
|
78
|
+
def test_from_id
|
79
|
+
|
80
|
+
assert_equal(
|
81
|
+
'0_0_1!!20100224-fake',
|
82
|
+
Ruote::FlowExpressionId.from_id('0_0_1!!20100224-fake').to_storage_id)
|
83
|
+
assert_equal(
|
84
|
+
'0_0_1!!20100224-fake',
|
85
|
+
Ruote::FlowExpressionId.from_id('wi!0_0_1!!20100224-fake').to_storage_id)
|
86
|
+
assert_equal(
|
87
|
+
'0_0_1!!20100224-fake',
|
88
|
+
Ruote::FlowExpressionId.from_id('wi!store!0_0_1!!20100224-fake').to_storage_id)
|
89
|
+
end
|
77
90
|
end
|
78
91
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Sun Mar 14 21:25:52 JST 2010
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), '..', 'test_helper.rb')
|
9
|
+
|
10
|
+
require 'ruote'
|
11
|
+
require 'ruote/storage/composite_storage'
|
12
|
+
|
13
|
+
|
14
|
+
class UtCompositeStorageTest < Test::Unit::TestCase
|
15
|
+
|
16
|
+
def test_initial
|
17
|
+
|
18
|
+
msgs = Ruote::HashStorage.new({})
|
19
|
+
default = Ruote::HashStorage.new({})
|
20
|
+
|
21
|
+
cs = Ruote::CompositeStorage.new(default, 'msgs' => msgs)
|
22
|
+
|
23
|
+
cs.put('action' => 'terminate', 'type' => 'msgs', 'id' => 'xxx')
|
24
|
+
cs.put_msg('terminate', 'type' => 'msgs')
|
25
|
+
cs.put_schedule('at', {}, Time.now + 10, 'action' => 'reply')
|
26
|
+
|
27
|
+
assert_equal 0, default.h['msgs'].size
|
28
|
+
assert_equal 1, default.h['schedules'].size
|
29
|
+
assert_equal 2, cs.get_msgs.size
|
30
|
+
assert_equal 2, msgs.get_msgs.size
|
31
|
+
assert_equal 0, msgs.h['schedules'].size
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|