openwferu 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. data/examples/mano_tracker.rb +11 -13
  2. data/lib/openwfe.rb +2 -4
  3. data/lib/openwfe/contextual.rb +8 -2
  4. data/lib/openwfe/engine/engine.rb +118 -2
  5. data/lib/openwfe/expool/expressionpool.rb +148 -53
  6. data/lib/openwfe/expool/expstorage.rb +36 -4
  7. data/lib/openwfe/expool/yamlexpstorage.rb +18 -0
  8. data/lib/openwfe/expressions/environment.rb +1 -1
  9. data/lib/openwfe/expressions/fe_misc.rb +14 -2
  10. data/lib/openwfe/expressions/fe_raw.rb +27 -11
  11. data/lib/openwfe/expressions/fe_subprocess.rb +45 -12
  12. data/lib/openwfe/expressions/fe_utils.rb +1 -1
  13. data/lib/openwfe/expressions/flowexpression.rb +5 -1
  14. data/lib/openwfe/expressions/raw_prog.rb +80 -32
  15. data/lib/openwfe/expressions/raw_xml.rb +10 -0
  16. data/lib/openwfe/flowexpressionid.rb +28 -7
  17. data/lib/openwfe/listeners/listener.rb +106 -0
  18. data/lib/openwfe/listeners/listeners.rb +140 -0
  19. data/lib/openwfe/listeners/socketlisteners.rb +239 -0
  20. data/lib/openwfe/listeners/sqslisteners.rb +145 -0
  21. data/lib/openwfe/participants/{csvparticipant.rb → csvparticipants.rb} +0 -0
  22. data/lib/openwfe/participants/{enoparticipant.rb → enoparticipants.rb} +1 -1
  23. data/lib/openwfe/participants/participantmap.rb +33 -1
  24. data/lib/openwfe/participants/participants.rb +99 -11
  25. data/lib/openwfe/participants/soapparticipants.rb +28 -8
  26. data/lib/openwfe/participants/socketparticipants.rb +172 -0
  27. data/lib/openwfe/participants/sqsparticipants.rb +121 -0
  28. data/lib/openwfe/rest/definitions.rb +1 -1
  29. data/lib/openwfe/{osocket.rb → rest/osocket.rb} +16 -8
  30. data/lib/openwfe/rest/xmlcodec.rb +41 -5
  31. data/lib/openwfe/storage/yamlfilestorage.rb +10 -13
  32. data/lib/openwfe/util/dollar.rb +23 -2
  33. data/lib/openwfe/util/otime.rb +1 -1
  34. data/lib/openwfe/util/safe.rb +149 -0
  35. data/lib/openwfe/util/scheduler.rb +47 -5
  36. data/lib/openwfe/util/sqs.rb +582 -0
  37. data/lib/openwfe/utils.rb +23 -0
  38. data/lib/openwfe/version.rb +1 -1
  39. data/lib/openwfe/workitem.rb +86 -3
  40. data/lib/openwfe/worklist/storeparticipant.rb +44 -4
  41. data/test/csv_test.rb +1 -1
  42. data/test/eno_test.rb +1 -1
  43. data/test/fei_test.rb +2 -15
  44. data/test/flowtestbase.rb +6 -2
  45. data/test/ft_11_ppd.rb +31 -0
  46. data/test/ft_13_eno.rb +1 -1
  47. data/test/ft_14b_subprocess.rb +74 -0
  48. data/test/ft_15_iterator.rb +0 -1
  49. data/test/ft_19_csv.rb +1 -1
  50. data/test/ft_20_cron.rb +1 -1
  51. data/test/ft_21_cron.rb +1 -1
  52. data/test/ft_27_getflowpos.rb +89 -0
  53. data/test/ft_28_fileparticipant.rb +65 -0
  54. data/test/ft_29_httprb.rb +95 -0
  55. data/test/ft_30_socketlistener.rb +197 -0
  56. data/test/ft_4_misc.rb +2 -1
  57. data/test/hash_test.rb +75 -0
  58. data/test/rake_qtest.rb +5 -4
  59. data/test/raw_prog_test.rb +205 -0
  60. data/test/rutest_utils.rb +16 -0
  61. data/test/safely_test.rb +89 -0
  62. data/test/scheduler_test.rb +71 -0
  63. data/test/sqs_test.rb +103 -0
  64. metadata +21 -6
  65. data/test/journal_persistence_test.rb +0 -147
@@ -9,7 +9,6 @@
9
9
 
10
10
  require 'openwfe/expressions/raw_prog'
11
11
  require 'openwfe/participants/participants'
12
- require 'openwfe/participants/enoparticipant'
13
12
  require 'flowtestbase'
14
13
 
15
14
 
@@ -7,7 +7,7 @@
7
7
 
8
8
  require 'flowtestbase'
9
9
  require 'openwfe/expressions/raw_prog'
10
- require 'openwfe/participants/csvparticipant'
10
+ require 'openwfe/participants/csvparticipants'
11
11
 
12
12
  include OpenWFE
13
13
 
@@ -7,7 +7,7 @@
7
7
 
8
8
  require 'flowtestbase'
9
9
  require 'openwfe/expressions/raw_prog'
10
- require 'openwfe/participants/csvparticipant'
10
+ require 'openwfe/participants/csvparticipants'
11
11
 
12
12
  include OpenWFE
13
13
 
@@ -7,7 +7,7 @@
7
7
 
8
8
  require 'flowtestbase'
9
9
  require 'openwfe/expressions/raw_prog'
10
- require 'openwfe/participants/csvparticipant'
10
+ require 'openwfe/participants/csvparticipants'
11
11
 
12
12
  include OpenWFE
13
13
 
@@ -0,0 +1,89 @@
1
+
2
+ #
3
+ # Testing OpenWFE
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Mon Oct 9 22:19:44 JST 2006
8
+ #
9
+
10
+ require 'openwfe/def'
11
+ require 'openwfe/worklist/storeparticipant'
12
+
13
+ require 'flowtestbase'
14
+
15
+
16
+ class FlowTest27 < Test::Unit::TestCase
17
+ include FlowTestBase
18
+
19
+ #def teardown
20
+ #end
21
+
22
+ #def setup
23
+ #end
24
+
25
+ #
26
+ # TEST 0
27
+
28
+ class TestDefinition0 < ProcessDefinition
29
+ def make
30
+ _process_definition :name => "27_gfp", :revision => "0" do
31
+ _sequence do
32
+ store_p
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ #def xxxx_gfp_0
39
+ def test_gfp_0
40
+
41
+ #sp = @engine.register_participant("store_p", OpenWFE::YamlParticipant)
42
+ sp = @engine.register_participant("store_p", OpenWFE::HashParticipant)
43
+
44
+ fei = @engine.launch(TestDefinition0)
45
+
46
+ l = @engine.get_expression_pool.get_flow_position(fei.wfid)
47
+
48
+ #l.each do |fexp|
49
+ # puts " - #{fexp.fei.to_debug_s}"
50
+ #end
51
+
52
+ assert \
53
+ l.size == 3,
54
+ "get_flow_position() returned #{l.size} elements"
55
+
56
+ wi = sp.first_workitem
57
+
58
+ sp.forward(wi)
59
+
60
+ assert sp.size == 0
61
+ end
62
+
63
+
64
+ #def xxxx_gfp_0b
65
+ def test_gfp_0b
66
+
67
+ sp = @engine.register_participant("store_p", OpenWFE::YamlParticipant)
68
+
69
+ fei = @engine.launch(TestDefinition0)
70
+
71
+ l = @engine.get_flow_position(fei.wfid)
72
+ #
73
+ # shortcut version
74
+
75
+ #l.each do |fexp|
76
+ # puts " - #{fexp.fei.to_debug_s}"
77
+ #end
78
+
79
+ assert l.size == 3
80
+
81
+ wi = sp.first_workitem
82
+
83
+ sp.forward(wi)
84
+
85
+ assert sp.size == 0
86
+ end
87
+
88
+ end
89
+
@@ -0,0 +1,65 @@
1
+
2
+ #
3
+ # Testing OpenWFE
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Mon Oct 9 22:19:44 JST 2006
8
+ #
9
+
10
+ require 'find'
11
+ require 'fileutils'
12
+
13
+ require 'openwfe/def'
14
+ require 'openwfe/listeners/listeners'
15
+ require 'openwfe/participants/participants'
16
+
17
+ require 'flowtestbase'
18
+
19
+
20
+ class FlowTest28 < Test::Unit::TestCase
21
+ include FlowTestBase
22
+
23
+ #def teardown
24
+ #end
25
+
26
+ #def setup
27
+ #end
28
+
29
+ #
30
+ # TEST 0
31
+
32
+ class TestDefinition0 < ProcessDefinition
33
+ def make
34
+ _sequence do
35
+ _participant :fp
36
+ _print "done"
37
+ end
38
+ end
39
+ end
40
+
41
+ #def xxxx_fp_0
42
+ def test_fp_0
43
+
44
+ FileUtils.mkdir("./work/in") unless File.exist? "./work/in"
45
+
46
+ @engine.register_participant("fp", OpenWFE::FileParticipant)
47
+ @engine.add_workitem_listener(OpenWFE::FileListener, "500")
48
+
49
+ fei = @engine.launch(TestDefinition0)
50
+
51
+ sleep 0.1
52
+
53
+ Find.find("./work/out/") do |path|
54
+ next unless path.match ".*\.yaml$"
55
+ FileUtils.mv(path, "./work/in/")
56
+ end
57
+
58
+ sleep 0.7
59
+
60
+ assert_equal \
61
+ engine.get_expression_storage.size, 1
62
+ end
63
+
64
+ end
65
+
@@ -0,0 +1,95 @@
1
+
2
+ #
3
+ # Testing OpenWFE
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Mon Oct 9 22:19:44 JST 2006
8
+ #
9
+
10
+ require 'openwfe/def'
11
+ require 'openwfe/workitem'
12
+ require 'openwfe/worklist/storeparticipant'
13
+
14
+ require 'flowtestbase'
15
+
16
+
17
+ class FlowTest29 < Test::Unit::TestCase
18
+ include FlowTestBase
19
+
20
+ #def teardown
21
+ #end
22
+
23
+ #def setup
24
+ #end
25
+
26
+ DEFHOST = "http://openwferu.rubyforge.org/defs"
27
+
28
+ #
29
+ # TEST 0
30
+
31
+ #def xxxx_httprb_0
32
+ def test_httprb_0
33
+
34
+ li = OpenWFE::LaunchItem.new
35
+ li.wfdurl = "#{DEFHOST}/testdef.rb"
36
+
37
+ dotest(
38
+ li,
39
+ """a
40
+ b
41
+ c""")
42
+ end
43
+
44
+
45
+ #
46
+ # TEST 1
47
+
48
+ class MainDefinition1 < OpenWFE::ProcessDefinition
49
+ def make
50
+ sequence do
51
+ _print "A"
52
+ subprocess :ref => "#{DEFHOST}/testdef.rb"
53
+ _print "C"
54
+ end
55
+ end
56
+ end
57
+
58
+ #def xxxx_httprb_1
59
+ def test_httprb_1
60
+ dotest(
61
+ MainDefinition1,
62
+ """A
63
+ a
64
+ b
65
+ c
66
+ C""")
67
+ end
68
+
69
+
70
+ #
71
+ # TEST 2
72
+
73
+ class MainDefinition2 < OpenWFE::ProcessDefinition
74
+ def make
75
+ sequence do
76
+ _print "-1"
77
+ subprocess :ref => "#{DEFHOST}/testdef.xml"
78
+ _print "3"
79
+ end
80
+ end
81
+ end
82
+
83
+ #def xxxx_httprb_2
84
+ def test_httprb_2
85
+ dotest(
86
+ MainDefinition2,
87
+ """-1
88
+ 0
89
+ 1
90
+ 2
91
+ 3""")
92
+ end
93
+
94
+ end
95
+
@@ -0,0 +1,197 @@
1
+
2
+ #
3
+ # Testing OpenWFE
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Mon Oct 9 22:19:44 JST 2006
8
+ #
9
+
10
+ require 'yaml'
11
+ require 'socket'
12
+
13
+ require 'openwfe/def'
14
+ require 'openwfe/listeners/socketlisteners'
15
+ require 'openwfe/participants/socketparticipants'
16
+
17
+ require 'flowtestbase'
18
+
19
+
20
+ class FlowTest30 < Test::Unit::TestCase
21
+ include FlowTestBase
22
+
23
+ #def teardown
24
+ #end
25
+
26
+ #def setup
27
+ #end
28
+
29
+
30
+ #
31
+ # TEST 0
32
+
33
+ class TestDefinition0 < ProcessDefinition
34
+ def make
35
+ _print "${f:message}"
36
+ end
37
+ end
38
+
39
+ #def xxxx_sl_0
40
+ def test_sl_0
41
+
42
+ sl = OpenWFE::SocketListener.new(
43
+ "socket_listener", @engine.application_context, 7008)
44
+
45
+ @engine.add_workitem_listener(sl)
46
+
47
+ li = LaunchItem.new(TestDefinition0.do_make)
48
+ li.message = "ok"
49
+ s = YAML.dump(li)
50
+
51
+ socket = TCPSocket.new("localhost", 7008)
52
+ socket.puts(s)
53
+ socket.close_write
54
+
55
+ reply = socket.gets
56
+ socket.close
57
+
58
+ #puts ">>>#{reply}<<<"
59
+ assert (reply.match "^.fei .*0.$")
60
+
61
+ trace = @tracer.to_s
62
+
63
+ assert_equal trace, "ok"
64
+ end
65
+
66
+
67
+ #
68
+ # TEST 1
69
+
70
+ #def xxxx_sl_1
71
+ def test_sl_1
72
+
73
+ @engine.add_workitem_listener(OpenWFE::SocketListener)
74
+
75
+ li = LaunchItem.new(TestDefinition0.do_make)
76
+ li.message = "ok1"
77
+ s = YAML.dump(li)
78
+
79
+ socket = TCPSocket.new("localhost", 7007)
80
+ socket.puts(s)
81
+ socket.close_write
82
+
83
+ reply = socket.gets
84
+ socket.close
85
+
86
+ #puts ">>>#{reply}<<<"
87
+ assert (reply.match "^.fei .*0.$")
88
+
89
+ trace = @tracer.to_s
90
+
91
+ assert_equal trace, "ok1"
92
+ end
93
+
94
+
95
+ #
96
+ # TEST 2
97
+
98
+ #def xxxx_sl_2
99
+ def test_sl_2
100
+
101
+ @engine.add_workitem_listener(OpenWFE::SocketListener)
102
+
103
+ li = LaunchItem.new(TestDefinition0.do_make)
104
+ li.message = "ok2"
105
+ s = YAML.dump(li)
106
+
107
+ socket = TCPSocket.new("localhost", 7007)
108
+ socket.puts("XmlEncoder 777")
109
+ socket.puts
110
+ socket.puts(s)
111
+ socket.close_write
112
+
113
+ reply = socket.gets
114
+ socket.close
115
+
116
+ #puts ">>>#{reply}<<<"
117
+ assert (reply.match "^.fei .*0.$")
118
+
119
+ trace = @tracer.to_s
120
+
121
+ assert_equal trace, "ok2"
122
+ end
123
+
124
+
125
+ #
126
+ # TEST 3
127
+
128
+ #def xxxx_sl_3
129
+ def test_sl_3
130
+
131
+ @engine.add_workitem_listener(OpenWFE::SocketListener)
132
+
133
+ li = LaunchItem.new(TestDefinition0.do_make)
134
+
135
+ trace = ""
136
+
137
+ 1.upto(4) do |i|
138
+ trace << "#{i}\n"
139
+ li.message = i
140
+ send_li(li)
141
+ end
142
+ 1.upto(3) do |i|
143
+ trace << "#{i}\n"
144
+ li.message = i
145
+ send_li_sp(li)
146
+ end
147
+ 1.upto(3) do |i|
148
+ trace << "#{i}\n"
149
+ li.message = i
150
+ send_li_xsp(li)
151
+ end
152
+ 1.upto(3) do |i|
153
+ trace << "#{i}\n"
154
+ li.message = i
155
+ send_li_ssp(li)
156
+ end
157
+ 1.upto(3) do |i|
158
+ trace << "#{i}\n"
159
+ li.message = i
160
+ send_li_sxsp(li)
161
+ end
162
+
163
+ trace = trace.strip
164
+
165
+ assert_equal @tracer.to_s, trace
166
+ end
167
+
168
+ def send_li (li)
169
+
170
+ socket = TCPSocket.new("localhost", 7007)
171
+
172
+ socket.puts(YAML.dump(li))
173
+ socket.close_write
174
+
175
+ reply = socket.gets
176
+ socket.close
177
+ end
178
+
179
+ def send_li_sp (li)
180
+ sp = OpenWFE::SocketParticipant.new("localhost", 7007)
181
+ sp.consume(li)
182
+ end
183
+
184
+ def send_li_xsp (li)
185
+ sp = OpenWFE::XmlSocketParticipant.new("localhost", 7007)
186
+ sp.consume(li)
187
+ end
188
+
189
+ def send_li_ssp (li)
190
+ OpenWFE::SocketParticipant.dispatch("localhost", 7007, li)
191
+ end
192
+
193
+ def send_li_sxsp (li)
194
+ OpenWFE::XmlSocketParticipant.dispatch("localhost", 7007, li)
195
+ end
196
+ end
197
+