openwferu 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/examples/engine_template.rb +182 -0
  2. data/examples/openwferu.rb +6 -7
  3. data/lib/openwfe/contextual.rb +8 -6
  4. data/lib/openwfe/engine/engine.rb +49 -14
  5. data/lib/openwfe/expool/expressionpool.rb +48 -17
  6. data/lib/openwfe/expool/history.rb +64 -14
  7. data/lib/openwfe/expool/journal.rb +66 -28
  8. data/lib/openwfe/expool/journal_replay.rb +190 -48
  9. data/lib/openwfe/expool/wfidgen.rb +51 -6
  10. data/lib/openwfe/expressions/condition.rb +49 -5
  11. data/lib/openwfe/expressions/environment.rb +9 -37
  12. data/lib/openwfe/expressions/expressionmap.rb +15 -1
  13. data/lib/openwfe/expressions/fe_concurrence.rb +4 -4
  14. data/lib/openwfe/expressions/fe_cron.rb +1 -5
  15. data/lib/openwfe/expressions/fe_do.rb +96 -26
  16. data/lib/openwfe/expressions/fe_equals.rb +190 -0
  17. data/lib/openwfe/expressions/fe_fqv.rb +25 -7
  18. data/lib/openwfe/expressions/fe_if.rb +262 -0
  19. data/lib/openwfe/expressions/fe_iterator.rb +3 -4
  20. data/lib/openwfe/expressions/fe_losfor.rb +0 -1
  21. data/lib/openwfe/expressions/fe_misc.rb +4 -5
  22. data/lib/openwfe/expressions/fe_participant.rb +2 -3
  23. data/lib/openwfe/expressions/fe_raw.rb +71 -31
  24. data/lib/openwfe/expressions/fe_reserve.rb +141 -0
  25. data/lib/openwfe/expressions/fe_sequence.rb +0 -1
  26. data/lib/openwfe/expressions/fe_sleep.rb +3 -58
  27. data/lib/openwfe/expressions/fe_subprocess.rb +6 -5
  28. data/lib/openwfe/expressions/fe_value.rb +20 -121
  29. data/lib/openwfe/expressions/fe_wait.rb +79 -0
  30. data/lib/openwfe/expressions/fe_when.rb +31 -96
  31. data/lib/openwfe/expressions/flowexpression.rb +112 -19
  32. data/lib/openwfe/expressions/raw_prog.rb +8 -116
  33. data/lib/openwfe/expressions/simplerep.rb +197 -0
  34. data/lib/openwfe/expressions/time.rb +266 -0
  35. data/lib/openwfe/expressions/timeout.rb +2 -2
  36. data/lib/openwfe/flowexpressionid.rb +22 -0
  37. data/lib/openwfe/listeners/socketlisteners.rb +15 -1
  38. data/lib/openwfe/participants/participantmap.rb +12 -1
  39. data/lib/openwfe/participants/participants.rb +7 -1
  40. data/lib/openwfe/rudefinitions.rb +1 -6
  41. data/lib/openwfe/service.rb +8 -0
  42. data/lib/openwfe/util/irb.rb +86 -0
  43. data/lib/openwfe/util/ometa.rb +3 -3
  44. data/lib/openwfe/util/safe.rb +26 -34
  45. data/lib/openwfe/util/scheduler.rb +133 -76
  46. data/lib/openwfe/utils.rb +1 -1
  47. data/lib/openwfe/version.rb +2 -2
  48. data/lib/openwfe/workitem.rb +38 -0
  49. data/lib/openwfe/worklist/storeparticipant.rb +27 -2
  50. data/test/console_test.rb +15 -0
  51. data/test/flowtestbase.rb +20 -28
  52. data/test/ft_12_blockparticipant.rb +24 -0
  53. data/test/ft_14b_subprocess.rb +18 -0
  54. data/test/ft_22_history.rb +22 -1
  55. data/test/ft_23_when.rb +29 -2
  56. data/test/ft_23b_when.rb +17 -0
  57. data/test/ft_23c_wait.rb +87 -0
  58. data/test/ft_2_concurrence.rb +15 -14
  59. data/test/ft_2b_concurrence.rb +4 -4
  60. data/test/ft_32_journal.rb +29 -6
  61. data/test/ft_32b_journal.rb +76 -0
  62. data/test/ft_36_subprocids.rb +96 -0
  63. data/test/ft_37_pnames.rb +55 -0
  64. data/test/ft_38_tag.rb +128 -0
  65. data/test/ft_39_reserve.rb +119 -0
  66. data/test/ft_3_equals.rb +20 -1
  67. data/test/ft_40_defined.rb +72 -0
  68. data/test/ft_41_case.rb +124 -0
  69. data/test/ft_4_misc.rb +17 -0
  70. data/test/ft_5_time.rb +15 -20
  71. data/test/ft_7_lose.rb +2 -3
  72. data/test/ft_8_forget.rb +1 -1
  73. data/test/ft_tests.rb +9 -0
  74. data/test/hparticipant_test.rb +47 -1
  75. data/test/nut_0_irb.rb +20 -0
  76. data/test/raw_prog_test.rb +6 -0
  77. data/test/safely_test.rb +31 -41
  78. data/test/wfid_test.rb +43 -0
  79. metadata +21 -4
  80. data/lib/openwfe/expressions/fe_utils.rb +0 -151
@@ -0,0 +1,87 @@
1
+
2
+ #
3
+ # Testing OpenWFEru
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+
8
+ require 'flowtestbase'
9
+ require 'openwfe/def'
10
+
11
+ include OpenWFE
12
+
13
+
14
+
15
+ class FlowTest23c < 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 Wait0c < ProcessDefinition
29
+ sequence do
30
+ concurrence do
31
+ sequence do
32
+ wait :until => "${done} == true", :frequency => "2s"
33
+ _print "after when"
34
+ end
35
+ sequence do
36
+ _sleep "1s"
37
+ _print "before done"
38
+ _set :variable => "done", :value => "true"
39
+ end
40
+ end
41
+ _print "over"
42
+ end
43
+ end
44
+
45
+ def test_0
46
+ dotest(
47
+ Wait0c,
48
+ """before done
49
+ after when
50
+ over""",
51
+ true)
52
+ end
53
+
54
+ #
55
+ # Test 1
56
+ #
57
+
58
+ class Wait1c < ProcessDefinition
59
+ sequence do
60
+ concurrence do
61
+ sequence do
62
+ wait :frequency => "2s" do
63
+ equals :variable_value => "done", :other_value => "true"
64
+ end
65
+ _print "after when"
66
+ end
67
+ sequence do
68
+ _sleep "1s"
69
+ _print "before done"
70
+ _set :variable => "done", :value => "true"
71
+ end
72
+ end
73
+ _print "over"
74
+ end
75
+ end
76
+
77
+ def test_1
78
+ dotest(
79
+ Wait1c,
80
+ """before done
81
+ after when
82
+ over""",
83
+ true)
84
+ end
85
+
86
+ end
87
+
@@ -37,7 +37,7 @@ class FlowTest2 < Test::Unit::TestCase
37
37
  </concurrence>
38
38
  </process-definition>''',
39
39
  "a",
40
- 0.03,
40
+ true,
41
41
  false)
42
42
  end
43
43
 
@@ -53,7 +53,8 @@ class FlowTest2 < Test::Unit::TestCase
53
53
  <print>b</print>
54
54
  </concurrence>
55
55
  </process-definition>''',
56
- "b")
56
+ "b",
57
+ true)
57
58
  end
58
59
 
59
60
  #def xxxx_con_3
@@ -65,7 +66,8 @@ class FlowTest2 < Test::Unit::TestCase
65
66
  <set variable="over" value="true" />
66
67
  </concurrence>
67
68
  </process-definition>''',
68
- "a")
69
+ "a",
70
+ true)
69
71
  end
70
72
 
71
73
  #def xxxx_con_4
@@ -82,7 +84,7 @@ class FlowTest2 < Test::Unit::TestCase
82
84
  </process-definition>''',
83
85
  """b
84
86
  a""",
85
- 2)
87
+ true)
86
88
  end
87
89
 
88
90
  #def xxxx_con_5
@@ -99,26 +101,25 @@ a""",
99
101
  </process-definition>''',
100
102
  """b
101
103
  a""",
102
- 2)
104
+ true)
103
105
  end
104
106
 
105
107
  class TestDefinition6 < ProcessDefinition
106
- def make
107
- process_definition :name => "con", :revision => "6" do
108
- concurrence :over_if => "1 == 1" do
109
- sequence do
110
- _sleep :for => "350"
111
- _print "a"
112
- end
113
- _print "b"
108
+ sequence do
109
+ concurrence :over_if => "1 == 1" do
110
+ sequence do
111
+ _sleep :for => "350"
112
+ _print "a"
114
113
  end
114
+ _print "b"
115
115
  end
116
+ _print "c"
116
117
  end
117
118
  end
118
119
 
119
120
  #def xxxx_con_6
120
121
  def test_con_6
121
- dotest(TestDefinition6, "b")
122
+ dotest(TestDefinition6, "b\nc")
122
123
  end
123
124
 
124
125
  end
@@ -101,7 +101,7 @@ class FlowTest2b < Test::Unit::TestCase
101
101
  true
102
102
  true
103
103
  true""",
104
- 0.25)
104
+ true)
105
105
 
106
106
  dotest(
107
107
  TestDefinition1.new("highest", "mix"),
@@ -109,7 +109,7 @@ true""",
109
109
  true
110
110
  true
111
111
  true""",
112
- 0.25)
112
+ true)
113
113
 
114
114
  dotest(
115
115
  TestDefinition1.new("lowest", "override"),
@@ -117,13 +117,13 @@ true""",
117
117
 
118
118
 
119
119
  true""",
120
- 0.25)
120
+ true)
121
121
 
122
122
  dotest(
123
123
  TestDefinition1.new("highest", "override"),
124
124
  """alpha
125
125
  true""",
126
- 0.25)
126
+ true)
127
127
  end
128
128
 
129
129
  def test_rawprog
@@ -28,15 +28,18 @@ class FlowTest32 < Test::Unit::TestCase
28
28
  # TEST 0
29
29
 
30
30
  class TestDefinition0 < ProcessDefinition
31
- concurrence do
32
- #sequence do
31
+ #concurrence do
32
+ sequence do
33
+ #set :variable => "//toto", :value => "nada"
33
34
  participant :alpha
34
35
  bravo
35
36
  end
36
37
  end
37
38
 
38
- #def xxxx_flowname_0
39
- def test_flowname_0
39
+ #def xxxx_journal_0
40
+ def test_journal_0
41
+
42
+ @engine.application_context[:keep_journals] = true
40
43
 
41
44
  @engine.init_service("journal", Journal)
42
45
 
@@ -51,9 +54,29 @@ class FlowTest32 < Test::Unit::TestCase
51
54
 
52
55
  journal_service = @engine.application_context["journal"]
53
56
 
54
- fn = journal_service.workdir + "/" + fei.wfid + ".journal"
57
+ fn = journal_service.donedir + "/" + fei.wfid + ".journal"
58
+
59
+ #journal_service.analyze fn
60
+
61
+ #sleep(10)
62
+
63
+ assert_equal @engine.get_expression_storage.size, 1
64
+
65
+ journal_service.replay fn, 18
66
+ #
67
+ # replay at offset 18 without "refiring"
68
+ #
69
+ # flow waits
70
+
71
+ assert_equal @engine.get_expression_storage.size, 6
72
+
73
+ journal_service.replay fn, 18, true
74
+ #
75
+ # replay at offset 18 with "refiring"
76
+ #
77
+ # flow resumes
55
78
 
56
- journal_service.replay fn
79
+ assert_equal @engine.get_expression_storage.size, 1
57
80
  end
58
81
 
59
82
  end
@@ -0,0 +1,76 @@
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 FlowTest32b < Test::Unit::TestCase
19
+ include FlowTestBase
20
+
21
+ #def teardown
22
+ #end
23
+
24
+ #def setup
25
+ #end
26
+
27
+ #
28
+ # TEST 0
29
+
30
+ class TestDefinition0 < ProcessDefinition
31
+ sequence do
32
+ participant :alpha
33
+ participant :bravo
34
+ end
35
+ end
36
+
37
+ #def xxxx_journal_0
38
+ def test_journal_0
39
+
40
+ #@engine.application_context[:keep_journals] = true
41
+
42
+ @engine.init_service "journal", Journal
43
+
44
+ @engine.register_participant(:alpha) do |wi|
45
+ @tracer << "alpha\n"
46
+ sleep(90)
47
+ end
48
+ @engine.register_participant(:bravo) do |wi|
49
+ @tracer << "bravo\n"
50
+ end
51
+
52
+ journal_service = @engine.application_context["journal"]
53
+
54
+ fei = dotest(TestDefinition0, "alpha\nbravo")
55
+
56
+ return
57
+
58
+ fn = journal_service.donedir + "/" + fei.wfid + ".journal"
59
+
60
+ #journal_service.analyze fn
61
+
62
+ #sleep(10)
63
+
64
+ assert_equal @engine.get_expression_storage.size, 1
65
+
66
+ journal_service.replay fn, 18
67
+
68
+ assert_equal @engine.get_expression_storage.size, 6
69
+
70
+ journal_service.replay fn, 18, true
71
+
72
+ assert_equal @engine.get_expression_storage.size, 1
73
+ end
74
+
75
+ end
76
+
@@ -0,0 +1,96 @@
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
+
15
+ class FlowTest36 < Test::Unit::TestCase
16
+ include FlowTestBase
17
+
18
+ #def teardown
19
+ #end
20
+
21
+ #def setup
22
+ #end
23
+
24
+ #
25
+ # TEST 0
26
+
27
+ class TestSubProcId0 < ProcessDefinition
28
+ concurrence do
29
+ subproc
30
+ subproc
31
+ end
32
+ process_definition :name => :subproc do
33
+ sequence do
34
+ #reval "puts fei"
35
+ check
36
+ end
37
+ end
38
+ end
39
+
40
+ class TestSubProcId1 < ProcessDefinition
41
+ concurrence do
42
+ subprocess :ref => "subproc"
43
+ subprocess :ref => :subproc
44
+ end
45
+ process_definition :name => :subproc do
46
+ sequence do
47
+ #reval "puts fei"
48
+ check
49
+ end
50
+ end
51
+ end
52
+
53
+ def test_subprocid_0
54
+
55
+ feis = {}
56
+
57
+ @engine.register_participant(:check) do |fexp, wi|
58
+ #puts fexp.fei.to_debug_s
59
+ feis[fexp.fei] = true
60
+ end
61
+
62
+ @engine.launch(TestSubProcId0)
63
+ @engine.launch(TestSubProcId1)
64
+
65
+ sleep 1
66
+
67
+ assert_equal feis.keys.size, 4
68
+ end
69
+
70
+
71
+ #
72
+ # TEST about Iterator
73
+
74
+ class TestIteratorSubId0 < ProcessDefinition
75
+ iterator :on_value => "a, b", :to_variable => "v" do
76
+ check
77
+ end
78
+ end
79
+
80
+ def test_iterator_subid_0
81
+
82
+ feis = {}
83
+
84
+ @engine.register_participant(:check) do |fexp, wi|
85
+ #puts fexp.fei.to_debug_s
86
+ feis[fexp.fei] = true
87
+ end
88
+
89
+ @engine.launch(TestIteratorSubId0)
90
+ #puts @tracer
91
+
92
+ assert_equal feis.keys.size, 2
93
+ end
94
+
95
+ end
96
+
@@ -0,0 +1,55 @@
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
+
15
+ class FlowTest37 < Test::Unit::TestCase
16
+ include FlowTestBase
17
+
18
+ #def teardown
19
+ #end
20
+
21
+ #def setup
22
+ #end
23
+
24
+ DEF0 = '''
25
+ <process-definition name="pnames" revision="0">
26
+ <sequence>
27
+ <participant ref="sps" />
28
+ <participant ref="sps_1" />
29
+ </sequence>
30
+ </process-definition>
31
+ '''.strip
32
+
33
+ class TestPnames1 < OpenWFE::ProcessDefinition
34
+ sequence do
35
+ participant :ref => "sps"
36
+ participant :ref => "sps_1"
37
+ end
38
+ end
39
+
40
+ def test_pnames
41
+
42
+ @engine.register_participant("sps") do |fexp, wi|
43
+ @tracer << "sps\n"
44
+ end
45
+ @engine.register_participant("sps_1") do |fexp, wi|
46
+ @tracer << "sps_1\n"
47
+ end
48
+
49
+ dotest(DEF0, "sps\nsps_1")
50
+
51
+ dotest(TestPnames1, "sps\nsps_1")
52
+ end
53
+
54
+ end
55
+
data/test/ft_38_tag.rb ADDED
@@ -0,0 +1,128 @@
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
+
15
+ class FlowTest38 < Test::Unit::TestCase
16
+ include FlowTestBase
17
+
18
+ #def teardown
19
+ #end
20
+
21
+ #def setup
22
+ #end
23
+
24
+ #
25
+ # test 0
26
+ #
27
+
28
+ class TestTag0 < OpenWFE::ProcessDefinition
29
+ concurrence do
30
+ sequence :tag => "seq0" do
31
+ _sleep "1s"
32
+ _print "hello"
33
+ end
34
+ _undo :ref => "seq0"
35
+ _print "blah"
36
+ end
37
+ end
38
+
39
+ def test_tag_0
40
+
41
+ dotest(TestTag0, "blah", true)
42
+ end
43
+
44
+
45
+ #
46
+ # test 1
47
+ #
48
+
49
+ class TestTag1 < OpenWFE::ProcessDefinition
50
+ concurrence do
51
+ sequence :tag => "seq0" do
52
+ count
53
+ _sleep "1s"
54
+ _print "hello"
55
+ end
56
+ _redo :ref => "seq0"
57
+ _print "blah"
58
+ end
59
+ end
60
+
61
+ #def xxxx_tag_1
62
+ def test_tag_1
63
+
64
+ count = 0
65
+
66
+ @engine.register_participant(:count) do
67
+ count += 1
68
+ end
69
+
70
+ dotest(TestTag1, "blah\nhello", true)
71
+
72
+ assert_equal count, 2
73
+ end
74
+
75
+
76
+ #
77
+ # test 2
78
+ #
79
+
80
+ class TestTag2 < OpenWFE::ProcessDefinition
81
+ sequence do
82
+ sequence :tag => "seq0" do
83
+ count
84
+ _print "hello"
85
+ end
86
+ _redo :ref => "seq0"
87
+ _print "blah"
88
+ end
89
+ end
90
+
91
+ #def xxxx_tag_2
92
+ def test_tag_2
93
+
94
+ count = 0
95
+
96
+ @engine.register_participant(:count) do
97
+ count += 1
98
+ end
99
+
100
+ dotest(TestTag2, "hello\nblah", true)
101
+
102
+ assert_equal count, 1
103
+ end
104
+
105
+
106
+ #
107
+ # test 3
108
+ #
109
+
110
+ class TestTag3 < OpenWFE::ProcessDefinition
111
+ sequence do
112
+ sequence :tag => "seq0" do
113
+ _print "1"
114
+ undo :ref => "seq0"
115
+ _print "2"
116
+ end
117
+ _print "3"
118
+ end
119
+ end
120
+
121
+ #def xxxx_tag_3
122
+ def test_tag_3
123
+
124
+ dotest TestTag3, "1\n3"
125
+ end
126
+
127
+ end
128
+