openwferu 0.9.10.653 → 0.9.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. data/README.txt +65 -33
  2. data/examples/README.txt +4 -0
  3. data/examples/flowtracing.rb +2 -0
  4. data/examples/homeworkreview.rb +2 -0
  5. data/examples/mano_tracker.rb +2 -0
  6. data/examples/openwferu.rb +3 -1
  7. data/examples/quotereporter.rb +2 -0
  8. data/examples/scheduler_cron_usage.rb +3 -1
  9. data/examples/scheduler_usage.rb +3 -1
  10. data/lib/openwfe/engine/engine.rb +15 -5
  11. data/lib/openwfe/expool/expressionpool.rb +30 -4
  12. data/lib/openwfe/expool/journal.rb +16 -18
  13. data/lib/openwfe/expool/journal_replay.rb +56 -8
  14. data/lib/openwfe/expool/wfidgen.rb +17 -8
  15. data/lib/openwfe/expressions/condition.rb +41 -26
  16. data/lib/openwfe/expressions/expressionmap.rb +7 -0
  17. data/lib/openwfe/expressions/fe_cancel.rb +1 -1
  18. data/lib/openwfe/expressions/fe_concurrence.rb +14 -5
  19. data/lib/openwfe/expressions/fe_cron.rb +3 -1
  20. data/lib/openwfe/expressions/fe_cursor.rb +1 -1
  21. data/lib/openwfe/expressions/fe_fqv.rb +58 -0
  22. data/lib/openwfe/expressions/fe_if.rb +1 -1
  23. data/lib/openwfe/expressions/fe_iterator.rb +5 -0
  24. data/lib/openwfe/expressions/fe_listen.rb +224 -0
  25. data/lib/openwfe/expressions/fe_misc.rb +32 -9
  26. data/lib/openwfe/expressions/fe_participant.rb +26 -6
  27. data/lib/openwfe/expressions/fe_sleep.rb +5 -7
  28. data/lib/openwfe/expressions/fe_timeout.rb +127 -0
  29. data/lib/openwfe/expressions/fe_when.rb +13 -1
  30. data/lib/openwfe/expressions/flowexpression.rb +4 -1
  31. data/lib/openwfe/expressions/time.rb +10 -27
  32. data/lib/openwfe/expressions/timeout.rb +23 -6
  33. data/lib/openwfe/flowexpressionid.rb +7 -6
  34. data/lib/openwfe/listeners/socketlisteners.rb +1 -1
  35. data/lib/openwfe/participants/enoparticipants.rb +103 -47
  36. data/lib/openwfe/participants/participant.rb +29 -3
  37. data/lib/openwfe/participants/participantmap.rb +10 -2
  38. data/lib/openwfe/participants/participants.rb +31 -19
  39. data/lib/openwfe/participants/socketparticipants.rb +3 -1
  40. data/lib/openwfe/rest/controlclient.rb +5 -18
  41. data/lib/openwfe/rest/oldrestservlet.rb +279 -0
  42. data/lib/openwfe/rest/restclient.rb +55 -25
  43. data/lib/openwfe/rest/worklistclient.rb +35 -44
  44. data/lib/openwfe/rest/xmlcodec.rb +79 -69
  45. data/lib/openwfe/rudefinitions.rb +15 -7
  46. data/lib/openwfe/storage/yamlextras.rb +3 -3
  47. data/lib/openwfe/util/observable.rb +64 -7
  48. data/lib/openwfe/util/scheduler.rb +107 -77
  49. data/lib/openwfe/util/workqueue.rb +5 -11
  50. data/lib/openwfe/utils.rb +3 -3
  51. data/lib/openwfe/version.rb +1 -2
  52. data/lib/openwfe/workitem.rb +3 -4
  53. data/lib/openwfe/worklist/oldrest.rb +244 -0
  54. data/lib/openwfe/worklist/storelocks.rb +288 -0
  55. data/lib/openwfe/worklist/storeparticipant.rb +4 -2
  56. data/lib/openwfe/worklist/worklist.rb +297 -0
  57. data/test/cron_test.rb +8 -9
  58. data/test/eno_test.rb +10 -13
  59. data/test/flowtestbase.rb +26 -17
  60. data/test/ft_15_iterator.rb +19 -0
  61. data/test/ft_23c_wait.rb +2 -2
  62. data/test/ft_2b_concurrence.rb +2 -2
  63. data/test/ft_30_socketlistener.rb +5 -1
  64. data/test/ft_32_journal.rb +1 -1
  65. data/test/ft_32c_journal.rb +102 -0
  66. data/test/ft_32d_journal.rb +85 -0
  67. data/test/ft_45_citerator.rb +25 -0
  68. data/test/ft_49_condition.rb +60 -2
  69. data/test/ft_4_misc.rb +15 -0
  70. data/test/ft_50_xml_attribute.rb +4 -4
  71. data/test/ft_53_null_noop_participant.rb +66 -0
  72. data/test/ft_54_listen.rb +223 -0
  73. data/test/ft_55_ptimeout.rb +64 -0
  74. data/test/ft_56_timeout.rb +55 -0
  75. data/test/ft_57_a.rb +109 -0
  76. data/test/ft_tests.rb +7 -0
  77. data/test/hparticipant_test.rb +3 -3
  78. data/test/obs_test.rb +115 -0
  79. data/test/orest_test.rb +224 -0
  80. data/test/pending.rb +24 -0
  81. data/test/rake_qtest.rb +5 -1
  82. data/test/rake_test.rb +4 -0
  83. data/test/scheduler_test.rb +31 -2
  84. data/test/sec_test.rb +7 -3
  85. data/test/slock_test.rb +82 -0
  86. metadata +19 -3
  87. data/test/ft_32b_journal.rb +0 -76
data/test/flowtestbase.rb CHANGED
@@ -20,7 +20,6 @@ require 'rutest_utils'
20
20
  include OpenWFE
21
21
 
22
22
 
23
- #$SLEEP_TIME = 0.100
24
23
  $WORKFLOW_ENGINE_CLASS = Engine
25
24
 
26
25
  persistence = ENV["__persistence__"]
@@ -28,10 +27,8 @@ persistence = ENV["__persistence__"]
28
27
  require "openwfe/engine/file_persisted_engine" if persistence
29
28
 
30
29
  if persistence == "pure-persistence"
31
- #$SLEEP_TIME = 0.999
32
30
  $WORKFLOW_ENGINE_CLASS = FilePersistedEngine
33
31
  elsif persistence == "cached-persistence"
34
- #$SLEEP_TIME = 0.250
35
32
  $WORKFLOW_ENGINE_CLASS = CachedFilePersistedEngine
36
33
  end
37
34
 
@@ -47,7 +44,7 @@ module FlowTestBase
47
44
 
48
45
  def setup
49
46
 
50
- @engine = $WORKFLOW_ENGINE_CLASS.new()
47
+ @engine = $WORKFLOW_ENGINE_CLASS.new
51
48
 
52
49
  @engine.application_context[:ruby_eval_allowed] = true
53
50
 
@@ -121,18 +118,6 @@ module FlowTestBase
121
118
 
122
119
  fei = @engine.launch(li)
123
120
 
124
- #if join == true
125
- # @engine.get_scheduler.join_until_no_more_jobs
126
- #elsif join.is_a?(Numeric)
127
- # sleep join
128
- #end
129
- #if join.is_a?(Numeric)
130
- # sleep join
131
- #elsif join == true
132
- # @engine.wait_for_engine
133
- #else
134
- # sleep $SLEEP_TIME
135
- #end
136
121
  if join.is_a?(Numeric)
137
122
  sleep join
138
123
  else
@@ -179,7 +164,7 @@ module FlowTestBase
179
164
  engine.get_expression_storages.each do |storage|
180
165
  storage.purge
181
166
  end
182
- return
167
+ return fei
183
168
  end
184
169
 
185
170
  exp_storage = engine.get_expression_storage
@@ -202,3 +187,27 @@ module FlowTestBase
202
187
 
203
188
  end
204
189
 
190
+ #
191
+ # A bunch of methods for testing the journal component
192
+ #
193
+ module JournalTestBase
194
+
195
+ def get_journal
196
+ @engine.get_journal
197
+ end
198
+
199
+ def get_error_count (wfid)
200
+
201
+ fn = get_journal.workdir + "/" + wfid + ".journal"
202
+
203
+ get_journal.flush_buckets
204
+
205
+ events = get_journal.load_events(fn)
206
+
207
+ error_count = 0
208
+ events.each { |evt| error_count += 1 if evt[0] == :error }
209
+
210
+ error_count
211
+ end
212
+ end
213
+
@@ -93,5 +93,24 @@ class FlowTest15 < Test::Unit::TestCase
93
93
  2 -- z""")
94
94
  end
95
95
 
96
+
97
+ #
98
+ # Test 3
99
+ #
100
+
101
+ class TestDefinition3 < OpenWFE::ProcessDefinition
102
+ sequence do
103
+ iterator :on_value => "", :to_field => "f0" do
104
+ _print "${f:__ip__} -- ${f:f0}"
105
+ end
106
+ _print "done."
107
+ end
108
+ end
109
+
110
+ #def xxxx_iterator_3
111
+ def test_iterator_3
112
+ dotest(TestDefinition3, "done.")
113
+ end
114
+
96
115
  end
97
116
 
data/test/ft_23c_wait.rb CHANGED
@@ -30,7 +30,7 @@ class FlowTest23c < Test::Unit::TestCase
30
30
  concurrence do
31
31
  sequence do
32
32
  wait :until => "${done} == true", :frequency => "2s"
33
- _print "after when"
33
+ _print "after wait"
34
34
  end
35
35
  sequence do
36
36
  _sleep "1s"
@@ -47,7 +47,7 @@ class FlowTest23c < Test::Unit::TestCase
47
47
  Wait0c,
48
48
  """
49
49
  before done
50
- after when
50
+ after wait
51
51
  over
52
52
  """.strip,
53
53
  3)
@@ -60,8 +60,8 @@ class FlowTest2b < Test::Unit::TestCase
60
60
  <print>${f:key}</print>
61
61
  </sequence>
62
62
  </process-definition>''',
63
- "charly",
64
- 0.25)
63
+ "charly")
64
+ #0.25)
65
65
  end
66
66
 
67
67
  #
@@ -116,11 +116,15 @@ class FlowTest30 < Test::Unit::TestCase
116
116
  socket.puts
117
117
  socket.close_write
118
118
 
119
+ assert (not socket.closed?)
120
+
121
+ sleep 0.100
122
+
119
123
  reply = socket.gets
120
124
  socket.close
121
125
 
122
126
  #puts ">>>#{reply}<<<"
123
- assert (reply.match "^.fei .*0.$")
127
+ assert_not_nil reply.match("^.fei .*0.$")
124
128
 
125
129
  sleep 0.100
126
130
 
@@ -83,7 +83,7 @@ class FlowTest32 < Test::Unit::TestCase
83
83
  #
84
84
  # flow resumes
85
85
 
86
- sleep 0.500
86
+ sleep 0.700
87
87
 
88
88
  assert_equal @engine.get_expression_storage.size, 1
89
89
  end
@@ -0,0 +1,102 @@
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
+
12
+ require 'flowtestbase'
13
+
14
+ require 'openwfe/expool/journal'
15
+
16
+
17
+
18
+ class FlowTest32c < Test::Unit::TestCase
19
+ include FlowTestBase
20
+ include JournalTestBase
21
+
22
+ #def teardown
23
+ #end
24
+
25
+ #def setup
26
+ #end
27
+
28
+
29
+ #
30
+ # TEST 0
31
+
32
+ class Test0 < ProcessDefinition
33
+ sequence do
34
+ participant :alpha
35
+ participant :nada
36
+ participant :bravo
37
+ end
38
+ end
39
+
40
+ #def xxxx_0
41
+ def test_0
42
+
43
+ @engine.application_context[:keep_journals] = true
44
+
45
+ @engine.init_service("journal", Journal)
46
+
47
+ @engine.register_participant(:alpha) do |wi|
48
+ @tracer << "alpha\n"
49
+ end
50
+
51
+ class << get_journal
52
+ public :flush_buckets
53
+ end
54
+
55
+ #fei = dotest(Test0, "alpha", 0.500, true)
56
+ li = LaunchItem.new Test0
57
+ fei = @engine.launch li
58
+ sleep 0.500
59
+
60
+ get_journal.flush_buckets
61
+
62
+ fn = get_journal.workdir + "/" + fei.wfid + ".journal"
63
+
64
+ #require 'pp'; pp get_journal.load_events(fn)[-1]
65
+
66
+ error_event = get_journal.load_events(fn)[-1]
67
+
68
+ assert_equal error_event[0], :error
69
+ assert_equal error_event[2].wfid, fei.wfid
70
+ assert_equal error_event[3], :do_apply
71
+
72
+ #
73
+ # replaying the error (should occur a second time)
74
+
75
+ get_journal.replay_at_error error_event
76
+
77
+ sleep 1.0
78
+
79
+ assert_equal get_error_count(fei.wfid), 2
80
+
81
+ #
82
+ # fixing the cause of the error and then replaying the error
83
+ # (should not occur)
84
+
85
+ @engine.register_participant(:nada) do |wi|
86
+ @tracer << "nada\n"
87
+ end
88
+ @engine.register_participant(:bravo) do |wi|
89
+ @tracer << "bravo\n"
90
+ end
91
+
92
+ assert_equal @tracer.to_s, "alpha"
93
+
94
+ get_journal.replay_at_error error_event
95
+
96
+ sleep 1.0
97
+
98
+ assert_equal @tracer.to_s, "alpha\nnada\nbravo"
99
+ end
100
+
101
+ end
102
+
@@ -0,0 +1,85 @@
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
+
12
+ require 'flowtestbase'
13
+
14
+ require 'openwfe/expool/journal'
15
+
16
+
17
+
18
+ class FlowTest32d < Test::Unit::TestCase
19
+ include FlowTestBase
20
+ include JournalTestBase
21
+
22
+ #def teardown
23
+ #end
24
+
25
+ #def setup
26
+ #end
27
+
28
+
29
+ #
30
+ # TEST 0
31
+
32
+ class Test0 < ProcessDefinition
33
+ sequence do
34
+ participant :alpha
35
+ participant :nada
36
+ participant :bravo
37
+ end
38
+ end
39
+
40
+ #def xxxx_0
41
+ def test_0
42
+
43
+ @engine.application_context[:keep_journals] = true
44
+
45
+ @engine.init_service("journal", Journal)
46
+
47
+ @engine.register_participant(:alpha) do |wi|
48
+ @tracer << "alpha\n"
49
+ end
50
+
51
+ class << get_journal
52
+ public :flush_buckets
53
+ end
54
+
55
+ #fei = dotest(Test0, "alpha", 0.500, true)
56
+ li = LaunchItem.new Test0
57
+ fei = @engine.launch li
58
+ sleep 0.500
59
+
60
+ get_journal.flush_buckets
61
+
62
+ fn = get_journal.workdir + "/" + fei.wfid + ".journal"
63
+
64
+ assert_equal get_error_count(fei.wfid), 1
65
+
66
+ @engine.register_participant(:nada) do |wi|
67
+ @tracer << "nada\n"
68
+ end
69
+ @engine.register_participant(:bravo) do |wi|
70
+ @tracer << "bravo\n"
71
+ end
72
+
73
+ assert_equal @tracer.to_s, "alpha"
74
+
75
+ get_journal.replay_at_last_error fei.wfid
76
+
77
+ sleep 1.0
78
+
79
+ assert_equal @tracer.to_s, "alpha\nnada\nbravo"
80
+
81
+ assert (not File.exist?(fn))
82
+ end
83
+
84
+ end
85
+
@@ -112,5 +112,30 @@ done.
112
112
  """.strip)
113
113
  end
114
114
 
115
+
116
+ #
117
+ # Test 3
118
+ #
119
+
120
+ class TestCase45a3 < ProcessDefinition
121
+ sequence do
122
+ concurrent_iterator :on_value => "", :to_field => "f" do
123
+ _print "${r:fei.sub_instance_id} - ${f:f}"
124
+ end
125
+ _print "done."
126
+ end
127
+ end
128
+
129
+ # test 'parked' for now
130
+
131
+ #def xxxx_3
132
+ def test_3
133
+ dotest(
134
+ TestCase45a3,
135
+ """
136
+ done.
137
+ """.strip)
138
+ end
139
+
115
140
  end
116
141
 
@@ -58,8 +58,66 @@ class FlowTest49 < Test::Unit::TestCase
58
58
  4 true
59
59
  5
60
60
  6
61
- """.strip,
62
- true)
61
+ """.strip)
62
+ end
63
+
64
+
65
+ #
66
+ # Test 1
67
+ #
68
+
69
+ class TestCondition49a1 < ProcessDefinition
70
+ sequence do
71
+ _if :test => "true and false and false"
72
+ _print "0 ${f:__result__}"
73
+ _if :rtest => "true and true and true"
74
+ _print "1 ${f:__result__}"
75
+ _if :rtest => "false or false or true"
76
+ _print "2 ${f:__result__}"
77
+ end
78
+ end
79
+
80
+ #def xxxx_0
81
+ def test_1
82
+
83
+ dotest(
84
+ TestCondition49a1,
85
+ """
86
+ 0
87
+ 1 true
88
+ 2 true
89
+ """.strip)
90
+ end
91
+
92
+
93
+ #
94
+ # Test 2
95
+ #
96
+
97
+ class TestCondition49a2 < ProcessDefinition
98
+ sequence do
99
+ _if :test => "true"
100
+ _print "0 ${f:__result__}"
101
+ _if :not => "false"
102
+ _print "1 ${f:__result__}"
103
+ _if :rnot => "1 > 3"
104
+ _print "2 ${f:__result__}"
105
+ _if :rnot => "1 > -1"
106
+ _print "3 ${f:__result__}"
107
+ end
108
+ end
109
+
110
+ #def xxxx_2
111
+ def test_2
112
+
113
+ dotest(
114
+ TestCondition49a2,
115
+ """
116
+ 0 true
117
+ 1 true
118
+ 2 true
119
+ 3
120
+ """.strip)
63
121
  end
64
122
 
65
123
  end
data/test/ft_4_misc.rb CHANGED
@@ -92,6 +92,21 @@ class FlowTest4 < Test::Unit::TestCase
92
92
  dotest(Reval4, "hello\n1")
93
93
  end
94
94
 
95
+ class Reval5 < OpenWFE::ProcessDefinition
96
+ sequence do
97
+ reval """
98
+ wi.customer_name = 'dubious'
99
+ 'surf'
100
+ """
101
+ _print "${f:customer_name}"
102
+ _print "${f:__result__}"
103
+ end
104
+ end
105
+
106
+ def test_reval_5
107
+ dotest Reval5, "dubious\nsurf"
108
+ end
109
+
95
110
  #
96
111
  # DRU tests
97
112
 
@@ -98,11 +98,11 @@ END
98
98
 
99
99
  workitem.result = REXML::Document.new PAT_XML
100
100
 
101
- s = OpenWFE::xml_encode workitem
101
+ s = OpenWFE::XmlCodec::encode workitem
102
102
 
103
103
  #puts s
104
104
 
105
- w = OpenWFE::xml_decode s
105
+ w = OpenWFE::XmlCodec::decode s
106
106
 
107
107
  #puts workitem.to_s
108
108
  #puts w.to_s
@@ -120,11 +120,11 @@ END
120
120
 
121
121
  workitem.result = workitem.result.root
122
122
 
123
- s = OpenWFE::xml_encode workitem
123
+ s = OpenWFE::XmlCodec::encode workitem
124
124
 
125
125
  #puts s
126
126
 
127
- w = OpenWFE::xml_decode s
127
+ w = OpenWFE::XmlCodec::decode s
128
128
 
129
129
  #puts workitem.to_s
130
130
  #puts w.to_s
@@ -0,0 +1,66 @@
1
+
2
+ #
3
+ # Testing OpenWFEru
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+
8
+ require 'flowtestbase'
9
+ require 'openwfe/def'
10
+ require 'openwfe/participants/participants'
11
+
12
+ include OpenWFE
13
+
14
+
15
+ class FlowTest53 < Test::Unit::TestCase
16
+ include FlowTestBase
17
+
18
+ #def setup
19
+ #end
20
+
21
+ #def teardown
22
+ #end
23
+
24
+ #
25
+ # Test 0
26
+ #
27
+
28
+ class Test0 < ProcessDefinition
29
+ sequence do
30
+ _print "a"
31
+ participant :ref => :null, :timeout => "1s"
32
+ _print "b"
33
+ end
34
+ end
35
+
36
+ #def xxxx_0
37
+ def test_0
38
+
39
+ @engine.register_participant :null, NullParticipant
40
+
41
+ dotest(Test0, "a\nb")
42
+ end
43
+
44
+
45
+ #
46
+ # Test 1
47
+ #
48
+
49
+ class Test1 < ProcessDefinition
50
+ sequence do
51
+ _print "a"
52
+ participant :ref => :noop
53
+ _print "b"
54
+ end
55
+ end
56
+
57
+ #def xxxx_1
58
+ def test_1
59
+
60
+ @engine.register_participant :noop, NoOperationParticipant
61
+
62
+ dotest(Test1, "a\nb")
63
+ end
64
+
65
+ end
66
+