openwferu 0.9.7 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/engine_template.rb +182 -0
- data/examples/openwferu.rb +6 -7
- data/lib/openwfe/contextual.rb +8 -6
- data/lib/openwfe/engine/engine.rb +49 -14
- data/lib/openwfe/expool/expressionpool.rb +48 -17
- data/lib/openwfe/expool/history.rb +64 -14
- data/lib/openwfe/expool/journal.rb +66 -28
- data/lib/openwfe/expool/journal_replay.rb +190 -48
- data/lib/openwfe/expool/wfidgen.rb +51 -6
- data/lib/openwfe/expressions/condition.rb +49 -5
- data/lib/openwfe/expressions/environment.rb +9 -37
- data/lib/openwfe/expressions/expressionmap.rb +15 -1
- data/lib/openwfe/expressions/fe_concurrence.rb +4 -4
- data/lib/openwfe/expressions/fe_cron.rb +1 -5
- data/lib/openwfe/expressions/fe_do.rb +96 -26
- data/lib/openwfe/expressions/fe_equals.rb +190 -0
- data/lib/openwfe/expressions/fe_fqv.rb +25 -7
- data/lib/openwfe/expressions/fe_if.rb +262 -0
- data/lib/openwfe/expressions/fe_iterator.rb +3 -4
- data/lib/openwfe/expressions/fe_losfor.rb +0 -1
- data/lib/openwfe/expressions/fe_misc.rb +4 -5
- data/lib/openwfe/expressions/fe_participant.rb +2 -3
- data/lib/openwfe/expressions/fe_raw.rb +71 -31
- data/lib/openwfe/expressions/fe_reserve.rb +141 -0
- data/lib/openwfe/expressions/fe_sequence.rb +0 -1
- data/lib/openwfe/expressions/fe_sleep.rb +3 -58
- data/lib/openwfe/expressions/fe_subprocess.rb +6 -5
- data/lib/openwfe/expressions/fe_value.rb +20 -121
- data/lib/openwfe/expressions/fe_wait.rb +79 -0
- data/lib/openwfe/expressions/fe_when.rb +31 -96
- data/lib/openwfe/expressions/flowexpression.rb +112 -19
- data/lib/openwfe/expressions/raw_prog.rb +8 -116
- data/lib/openwfe/expressions/simplerep.rb +197 -0
- data/lib/openwfe/expressions/time.rb +266 -0
- data/lib/openwfe/expressions/timeout.rb +2 -2
- data/lib/openwfe/flowexpressionid.rb +22 -0
- data/lib/openwfe/listeners/socketlisteners.rb +15 -1
- data/lib/openwfe/participants/participantmap.rb +12 -1
- data/lib/openwfe/participants/participants.rb +7 -1
- data/lib/openwfe/rudefinitions.rb +1 -6
- data/lib/openwfe/service.rb +8 -0
- data/lib/openwfe/util/irb.rb +86 -0
- data/lib/openwfe/util/ometa.rb +3 -3
- data/lib/openwfe/util/safe.rb +26 -34
- data/lib/openwfe/util/scheduler.rb +133 -76
- data/lib/openwfe/utils.rb +1 -1
- data/lib/openwfe/version.rb +2 -2
- data/lib/openwfe/workitem.rb +38 -0
- data/lib/openwfe/worklist/storeparticipant.rb +27 -2
- data/test/console_test.rb +15 -0
- data/test/flowtestbase.rb +20 -28
- data/test/ft_12_blockparticipant.rb +24 -0
- data/test/ft_14b_subprocess.rb +18 -0
- data/test/ft_22_history.rb +22 -1
- data/test/ft_23_when.rb +29 -2
- data/test/ft_23b_when.rb +17 -0
- data/test/ft_23c_wait.rb +87 -0
- data/test/ft_2_concurrence.rb +15 -14
- data/test/ft_2b_concurrence.rb +4 -4
- data/test/ft_32_journal.rb +29 -6
- data/test/ft_32b_journal.rb +76 -0
- data/test/ft_36_subprocids.rb +96 -0
- data/test/ft_37_pnames.rb +55 -0
- data/test/ft_38_tag.rb +128 -0
- data/test/ft_39_reserve.rb +119 -0
- data/test/ft_3_equals.rb +20 -1
- data/test/ft_40_defined.rb +72 -0
- data/test/ft_41_case.rb +124 -0
- data/test/ft_4_misc.rb +17 -0
- data/test/ft_5_time.rb +15 -20
- data/test/ft_7_lose.rb +2 -3
- data/test/ft_8_forget.rb +1 -1
- data/test/ft_tests.rb +9 -0
- data/test/hparticipant_test.rb +47 -1
- data/test/nut_0_irb.rb +20 -0
- data/test/raw_prog_test.rb +6 -0
- data/test/safely_test.rb +31 -41
- data/test/wfid_test.rb +43 -0
- metadata +21 -4
- data/lib/openwfe/expressions/fe_utils.rb +0 -151
@@ -91,11 +91,20 @@ module OpenWFE
|
|
91
91
|
# regenerate_latest_report()
|
92
92
|
# end
|
93
93
|
#
|
94
|
+
# The scheduler has a "exit_when_no_more_jobs" attribute. When set to
|
95
|
+
# 'true', the scheduler will exit as soon as there are no more jobs to
|
96
|
+
# run.
|
97
|
+
# Use with care though, if you create a scheduler, set this attribute
|
98
|
+
# to true and start the scheduler, the scheduler will immediately exit.
|
99
|
+
# This attribute is best used indirectly : the method
|
100
|
+
# join_until_no_more_jobs() wraps it.
|
101
|
+
#
|
94
102
|
class Scheduler
|
95
103
|
include MonitorMixin
|
96
104
|
|
97
105
|
attr_accessor \
|
98
|
-
:precision
|
106
|
+
:precision,
|
107
|
+
:exit_when_no_more_jobs
|
99
108
|
|
100
109
|
def initialize
|
101
110
|
|
@@ -110,6 +119,9 @@ module OpenWFE
|
|
110
119
|
#
|
111
120
|
# every 250ms, the scheduler wakes up
|
112
121
|
|
122
|
+
@exit_when_no_more_jobs = false
|
123
|
+
@dont_reschedule_every = false
|
124
|
+
|
113
125
|
@last_cron_minute = -1
|
114
126
|
|
115
127
|
@stopped = false
|
@@ -123,7 +135,6 @@ module OpenWFE
|
|
123
135
|
@scheduler_thread = Thread.new do
|
124
136
|
while true
|
125
137
|
break if @stopped
|
126
|
-
#print "."; $stdout.flush
|
127
138
|
step
|
128
139
|
sleep(@precision)
|
129
140
|
end
|
@@ -134,6 +145,7 @@ module OpenWFE
|
|
134
145
|
# The scheduler is stoppable via sstop()
|
135
146
|
#
|
136
147
|
def sstop
|
148
|
+
|
137
149
|
@stopped = true
|
138
150
|
end
|
139
151
|
|
@@ -144,64 +156,33 @@ module OpenWFE
|
|
144
156
|
# Joins on the scheduler thread
|
145
157
|
#
|
146
158
|
def join
|
159
|
+
|
147
160
|
@scheduler_thread.join
|
148
161
|
end
|
149
162
|
|
150
163
|
#
|
151
|
-
#
|
152
|
-
#
|
164
|
+
# Like join() but takes care of setting the 'exit_when_no_more_jobs'
|
165
|
+
# attribute of this scheduler to true before joining.
|
166
|
+
# Thus the scheduler will exit (and the join terminates) as soon as
|
167
|
+
# there aren't no more 'at' (or 'every') jobs in the scheduler.
|
153
168
|
#
|
154
|
-
|
169
|
+
# Currently used only in unit tests.
|
170
|
+
#
|
171
|
+
def join_until_no_more_jobs
|
155
172
|
|
156
|
-
|
173
|
+
@exit_when_no_more_jobs = true
|
174
|
+
join
|
157
175
|
end
|
158
176
|
|
159
177
|
#
|
160
|
-
#
|
178
|
+
# Schedules a job by specifying at which time it should trigger.
|
179
|
+
# Returns the a job_id that can be used to unschedule the job.
|
161
180
|
#
|
162
|
-
def
|
163
|
-
synchronize do
|
164
|
-
|
165
|
-
#puts "0 at is '#{at.to_s}' (#{at.class})"
|
166
|
-
|
167
|
-
at = OpenWFE::to_ruby_time(at) \
|
168
|
-
if at.kind_of? String
|
169
|
-
|
170
|
-
at = OpenWFE::to_gm_time(at) \
|
171
|
-
if at.kind_of? DateTime
|
172
|
-
|
173
|
-
at = at.to_f \
|
174
|
-
if at.kind_of? Time
|
175
|
-
|
176
|
-
#puts "1 at is '#{at.to_s}' (#{at.class})"}"
|
177
|
-
|
178
|
-
b = to_block(schedulable, params, &block)
|
179
|
-
job = AtEntry.new(at, at_id, &b)
|
180
|
-
|
181
|
-
if at < (Time.new.to_f + @precision)
|
182
|
-
job.trigger()
|
183
|
-
return nil
|
184
|
-
end
|
185
|
-
|
186
|
-
return push(job) \
|
187
|
-
if @pending_jobs.length < 1
|
188
|
-
|
189
|
-
# shortcut : check if the new job is posterior to
|
190
|
-
# the last job pending
|
191
|
-
|
192
|
-
return push(job) \
|
193
|
-
if at >= @pending_jobs.last.at
|
194
|
-
|
195
|
-
for i in 0...@pending_jobs.length
|
196
|
-
if at <= @pending_jobs[i].at
|
197
|
-
return push(job, i)
|
198
|
-
end
|
199
|
-
end
|
181
|
+
def schedule_at (at, schedulable=nil, params=nil, &block)
|
200
182
|
|
201
|
-
|
202
|
-
end
|
183
|
+
sschedule_at(false, at, nil, schedulable, params, &block)
|
203
184
|
end
|
204
|
-
|
185
|
+
|
205
186
|
|
206
187
|
#
|
207
188
|
# Schedules a job by stating in how much time it should trigger.
|
@@ -231,28 +212,8 @@ module OpenWFE
|
|
231
212
|
#
|
232
213
|
def schedule_every (freq, schedulable=nil, params=nil, &block)
|
233
214
|
|
234
|
-
|
235
|
-
end
|
236
|
-
|
237
|
-
#
|
238
|
-
# Do not call directly.
|
239
|
-
#
|
240
|
-
def schedule_every_with_id (freq, at_id, schedulable, params, &block)
|
241
|
-
|
242
|
-
f = duration_to_f(freq)
|
243
|
-
|
244
|
-
job_id = schedule_at_with_id(Time.new.to_f + f, at_id) do |eid, at|
|
245
|
-
if schedulable
|
246
|
-
schedulable.trigger(params)
|
247
|
-
else
|
248
|
-
block.call eid, at
|
249
|
-
end
|
250
|
-
schedule_every_with_id(f, eid, schedulable, params, &block)
|
251
|
-
end
|
252
|
-
|
253
|
-
job_id
|
215
|
+
sschedule_every(freq, nil, schedulable, params, &block)
|
254
216
|
end
|
255
|
-
protected :schedule_every_with_id
|
256
217
|
|
257
218
|
#
|
258
219
|
# Unschedules an 'at' or a 'cron' job identified by the id
|
@@ -317,12 +278,10 @@ module OpenWFE
|
|
317
278
|
#
|
318
279
|
# is a job with the same id already scheduled ?
|
319
280
|
|
320
|
-
if cron_id
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
"under same name '#{cron_id}'"
|
325
|
-
end
|
281
|
+
if cron_id and unschedule(cron_id)
|
282
|
+
ldebug do
|
283
|
+
"schedule() unscheduled previous job "+
|
284
|
+
"under same name '#{cron_id}'"
|
326
285
|
end
|
327
286
|
end
|
328
287
|
|
@@ -368,7 +327,8 @@ module OpenWFE
|
|
368
327
|
end
|
369
328
|
|
370
329
|
#
|
371
|
-
# Returns the number of currently pending jobs in this scheduler
|
330
|
+
# Returns the number of currently pending jobs in this scheduler
|
331
|
+
# ('at' jobs and 'every' jobs).
|
372
332
|
#
|
373
333
|
def pending_job_count
|
374
334
|
@pending_jobs.size
|
@@ -381,6 +341,20 @@ module OpenWFE
|
|
381
341
|
@cron_entries.size
|
382
342
|
end
|
383
343
|
|
344
|
+
#
|
345
|
+
# Returns the current count of 'every' jobs scheduled.
|
346
|
+
#
|
347
|
+
def every_job_count
|
348
|
+
@pending_jobs.select { |j| j.is_a?(EveryEntry) }.size
|
349
|
+
end
|
350
|
+
|
351
|
+
#
|
352
|
+
# Returns the current count of 'at' jobs scheduled (not 'every').
|
353
|
+
#
|
354
|
+
def at_job_count
|
355
|
+
@pending_jobs.select { |j| j.instance_of?(AtEntry) }.size
|
356
|
+
end
|
357
|
+
|
384
358
|
#
|
385
359
|
# Returns true if the given string seems to be a cron string.
|
386
360
|
#
|
@@ -390,6 +364,74 @@ module OpenWFE
|
|
390
364
|
|
391
365
|
protected
|
392
366
|
|
367
|
+
def sschedule_at (
|
368
|
+
is_every, at, at_id, schedulable=nil, params=nil, &block)
|
369
|
+
|
370
|
+
synchronize do
|
371
|
+
|
372
|
+
#puts "0 at is '#{at.to_s}' (#{at.class})"
|
373
|
+
|
374
|
+
at = OpenWFE::to_ruby_time(at) \
|
375
|
+
if at.kind_of? String
|
376
|
+
|
377
|
+
at = OpenWFE::to_gm_time(at) \
|
378
|
+
if at.kind_of? DateTime
|
379
|
+
|
380
|
+
at = at.to_f \
|
381
|
+
if at.kind_of? Time
|
382
|
+
|
383
|
+
#puts "1 at is '#{at.to_s}' (#{at.class})"}"
|
384
|
+
|
385
|
+
jobClass = AtEntry
|
386
|
+
jobClass = EveryEntry if is_every
|
387
|
+
|
388
|
+
b = to_block(schedulable, params, &block)
|
389
|
+
job = jobClass.new(at, at_id, &b)
|
390
|
+
|
391
|
+
if at < (Time.new.to_f + @precision)
|
392
|
+
job.trigger()
|
393
|
+
return nil
|
394
|
+
end
|
395
|
+
|
396
|
+
return push(job) \
|
397
|
+
if @pending_jobs.length < 1
|
398
|
+
|
399
|
+
# shortcut : check if the new job is posterior to
|
400
|
+
# the last job pending
|
401
|
+
|
402
|
+
return push(job) \
|
403
|
+
if at >= @pending_jobs.last.at
|
404
|
+
|
405
|
+
for i in 0...@pending_jobs.length
|
406
|
+
if at <= @pending_jobs[i].at
|
407
|
+
return push(job, i)
|
408
|
+
end
|
409
|
+
end
|
410
|
+
|
411
|
+
return push(job)
|
412
|
+
end
|
413
|
+
end
|
414
|
+
|
415
|
+
def sschedule_every (freq, at_id, schedulable, params, &block)
|
416
|
+
|
417
|
+
f = duration_to_f(freq)
|
418
|
+
|
419
|
+
job_id = sschedule_at(
|
420
|
+
true, Time.new.to_f + f, at_id) do |eid, at|
|
421
|
+
|
422
|
+
if schedulable
|
423
|
+
schedulable.trigger(params)
|
424
|
+
else
|
425
|
+
block.call eid, at
|
426
|
+
end
|
427
|
+
|
428
|
+
sschedule_every(f, eid, schedulable, params, &block) \
|
429
|
+
unless @dont_reschedule_every
|
430
|
+
end
|
431
|
+
|
432
|
+
job_id
|
433
|
+
end
|
434
|
+
|
393
435
|
#
|
394
436
|
# Ensures that a duration is a expressed as a Float instance.
|
395
437
|
#
|
@@ -448,9 +490,21 @@ module OpenWFE
|
|
448
490
|
#
|
449
491
|
def step
|
450
492
|
synchronize do
|
493
|
+
|
451
494
|
now = Time.new
|
452
495
|
minute = now.min
|
453
496
|
|
497
|
+
if @exit_when_no_more_jobs
|
498
|
+
|
499
|
+
if @pending_jobs.size < 1
|
500
|
+
|
501
|
+
@stopped = true
|
502
|
+
return
|
503
|
+
end
|
504
|
+
|
505
|
+
@dont_reschedule_every = true if at_job_count < 1
|
506
|
+
end
|
507
|
+
|
454
508
|
#
|
455
509
|
# cron entries
|
456
510
|
|
@@ -577,6 +631,9 @@ module OpenWFE
|
|
577
631
|
end
|
578
632
|
end
|
579
633
|
|
634
|
+
class EveryEntry < AtEntry
|
635
|
+
end
|
636
|
+
|
580
637
|
class CronEntry < Entry
|
581
638
|
|
582
639
|
attr_accessor \
|
data/lib/openwfe/utils.rb
CHANGED
data/lib/openwfe/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
#--
|
3
|
-
# Copyright (c) 2007, John Mettraux, OpenWFE.org
|
3
|
+
# Copyright (c) 2005-2007, John Mettraux, OpenWFE.org
|
4
4
|
# All rights reserved.
|
5
5
|
#
|
6
6
|
# Redistribution and use in source and binary forms, with or without
|
@@ -34,5 +34,5 @@
|
|
34
34
|
#
|
35
35
|
|
36
36
|
module OpenWFE
|
37
|
-
OPENWFERU_VERSION = '0.9.
|
37
|
+
OPENWFERU_VERSION = '0.9.8'
|
38
38
|
end
|
data/lib/openwfe/workitem.rb
CHANGED
@@ -49,6 +49,12 @@ require 'openwfe/rest/definitions'
|
|
49
49
|
|
50
50
|
module OpenWFE
|
51
51
|
|
52
|
+
#
|
53
|
+
# The convention for the result of some expressions is to store
|
54
|
+
# their result in a workitem field named "__result__".
|
55
|
+
#
|
56
|
+
FIELD_RESULT = "__result__"
|
57
|
+
|
52
58
|
#
|
53
59
|
# WORKITEMS
|
54
60
|
#
|
@@ -280,6 +286,38 @@ module OpenWFE
|
|
280
286
|
wi.filter = h[:filter]
|
281
287
|
wi
|
282
288
|
end
|
289
|
+
|
290
|
+
#
|
291
|
+
# Sets the '__result__' field of this workitem
|
292
|
+
#
|
293
|
+
def set_result (result)
|
294
|
+
@attributes[FIELD_RESULT] = result
|
295
|
+
end
|
296
|
+
|
297
|
+
#
|
298
|
+
# Makes sure the '__result__' field of this workitem is empty.
|
299
|
+
#
|
300
|
+
def unset_result
|
301
|
+
@attributes.delete FIELD_RESULT
|
302
|
+
end
|
303
|
+
|
304
|
+
#
|
305
|
+
# Just a shortcut (for consistency) of
|
306
|
+
#
|
307
|
+
# workitem.attributes["__result__"]
|
308
|
+
#
|
309
|
+
def get_result
|
310
|
+
@attributes[FIELD_RESULT]
|
311
|
+
end
|
312
|
+
|
313
|
+
#
|
314
|
+
# Returns true or false.
|
315
|
+
#
|
316
|
+
def get_boolean_result
|
317
|
+
r = get_result
|
318
|
+
return false unless r
|
319
|
+
return (r == true or r == "true")
|
320
|
+
end
|
283
321
|
end
|
284
322
|
|
285
323
|
#
|
@@ -73,10 +73,14 @@ module OpenWFE
|
|
73
73
|
# Called by the engine (the participant expression) when handing
|
74
74
|
# out a workitem (to this participant).
|
75
75
|
#
|
76
|
+
# This method can also be used when delegating a workitem from
|
77
|
+
# one store participant to the other.
|
78
|
+
#
|
76
79
|
def consume (workitem)
|
77
80
|
|
78
81
|
self[workitem.flow_expression_id] = workitem
|
79
82
|
end
|
83
|
+
alias :push :consume
|
80
84
|
|
81
85
|
#
|
82
86
|
# Called by the participant expression when this participant is
|
@@ -112,7 +116,9 @@ module OpenWFE
|
|
112
116
|
raise "Workitem not found in #{self.class}, cannot forward." \
|
113
117
|
unless self.has_key? workitem.flow_expression_id
|
114
118
|
|
115
|
-
self.delete(workitem.flow_expression_id)
|
119
|
+
#self.delete(workitem.flow_expression_id)
|
120
|
+
self.delete(workitem)
|
121
|
+
|
116
122
|
reply_to_engine(workitem)
|
117
123
|
end
|
118
124
|
|
@@ -121,6 +127,25 @@ module OpenWFE
|
|
121
127
|
#
|
122
128
|
alias :proceed :forward
|
123
129
|
|
130
|
+
#
|
131
|
+
# This delete() method accepts a workitem or simply its FlowExpressionId
|
132
|
+
# identifier.
|
133
|
+
#
|
134
|
+
def delete (wi_or_fei)
|
135
|
+
fei = wi_or_fei
|
136
|
+
fei = fei.fei if fei.is_a? InFlowWorkItem
|
137
|
+
super fei
|
138
|
+
end
|
139
|
+
|
140
|
+
#
|
141
|
+
# A convenience method for delegating a workitem to another
|
142
|
+
# store participant.
|
143
|
+
#
|
144
|
+
def delegate (wi_or_fei, other_store_participant)
|
145
|
+
wi = delete(wi_or_fei)
|
146
|
+
other_store_participant.push(wi)
|
147
|
+
end
|
148
|
+
|
124
149
|
#
|
125
150
|
# Returns all the workitems for a given workflow instance id.
|
126
151
|
# If no workflow_instance_id is given, all the workitems will be
|
@@ -143,7 +168,7 @@ module OpenWFE
|
|
143
168
|
# consecutive calls to this method might not return the same workitem
|
144
169
|
# (except if the store is empty or contains 1! workitem).
|
145
170
|
#
|
146
|
-
def first_workitem
|
171
|
+
def first_workitem
|
147
172
|
|
148
173
|
result = nil
|
149
174
|
|
data/test/flowtestbase.rb
CHANGED
@@ -57,6 +57,17 @@ module FlowTestBase
|
|
57
57
|
require 'pp'; pp workitem
|
58
58
|
puts
|
59
59
|
end
|
60
|
+
|
61
|
+
@engine.register_participant('test-.*', PrintParticipant.new())
|
62
|
+
|
63
|
+
@engine.register_participant('block-participant') do |workitem|
|
64
|
+
@tracer << "the block participant received a workitem"
|
65
|
+
@tracer << "\n"
|
66
|
+
end
|
67
|
+
|
68
|
+
@engine.register_participant('p-toto') do |workitem|
|
69
|
+
@tracer << "toto"
|
70
|
+
end
|
60
71
|
end
|
61
72
|
|
62
73
|
def teardown
|
@@ -89,35 +100,10 @@ module FlowTestBase
|
|
89
100
|
#
|
90
101
|
# dotest()
|
91
102
|
#
|
92
|
-
def dotest (flowDef, expectedTrace,
|
103
|
+
def dotest (flowDef, expectedTrace, join=false, allowRemainingExpressions=false)
|
93
104
|
|
94
105
|
@tracer.clear
|
95
106
|
|
96
|
-
@engine.register_participant('test-.*', PrintParticipant.new())
|
97
|
-
|
98
|
-
@engine.register_participant('block-participant') do |workitem|
|
99
|
-
@tracer << "the block participant received a workitem"
|
100
|
-
@tracer << "\n"
|
101
|
-
end
|
102
|
-
|
103
|
-
@engine.register_participant('p-toto') do |workitem|
|
104
|
-
@tracer << "toto"
|
105
|
-
end
|
106
|
-
|
107
|
-
# @engine.register_participant(
|
108
|
-
# 'eno',
|
109
|
-
# EmailNotificationParticipant.new(
|
110
|
-
# "googlemail.l.google.com",
|
111
|
-
# 25,
|
112
|
-
# "eno@outoftheblue.co.jp",
|
113
|
-
# """Subject: test 0
|
114
|
-
#
|
115
|
-
#0 : ${r:Time.new}
|
116
|
-
#1 : ${f:customer_name}
|
117
|
-
# """))
|
118
|
-
|
119
|
-
# register unique tracing participant
|
120
|
-
|
121
107
|
li = if flowDef.kind_of? OpenWFE::LaunchItem
|
122
108
|
flowDef
|
123
109
|
else
|
@@ -126,7 +112,8 @@ module FlowTestBase
|
|
126
112
|
|
127
113
|
fei = @engine.launch(li)
|
128
114
|
|
129
|
-
sleep(
|
115
|
+
#sleep(sleep_time)
|
116
|
+
@engine.get_scheduler.join_until_no_more_jobs if join
|
130
117
|
|
131
118
|
trace = @tracer.to_s
|
132
119
|
|
@@ -146,9 +133,14 @@ module FlowTestBase
|
|
146
133
|
assert \
|
147
134
|
result,
|
148
135
|
"flow failed : trace doesn't correspond to any expected traces"
|
136
|
+
elsif expectedTrace.kind_of? Regexp
|
137
|
+
|
138
|
+
assert \
|
139
|
+
trace.match(expectedTrace)
|
149
140
|
else
|
141
|
+
|
150
142
|
assert \
|
151
|
-
trace == expectedTrace,
|
143
|
+
trace == expectedTrace,
|
152
144
|
"""flow failed :
|
153
145
|
|
154
146
|
'#{trace}'
|
@@ -69,5 +69,29 @@ done.""")
|
|
69
69
|
"""bp1a : OpenWFE::ParticipantExpression""")
|
70
70
|
end
|
71
71
|
|
72
|
+
|
73
|
+
#
|
74
|
+
# Test 2
|
75
|
+
#
|
76
|
+
|
77
|
+
class BpDef2 < OpenWFE::ProcessDefinition
|
78
|
+
sequence do
|
79
|
+
bp
|
80
|
+
_print "${f:__result__}"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_bp_2
|
85
|
+
|
86
|
+
@engine.register_participant("bp") do |fexp, wi|
|
87
|
+
"a string result"
|
88
|
+
#
|
89
|
+
# the 'return' value of a block participant is stored
|
90
|
+
# in the "__result__" field of the workitem
|
91
|
+
end
|
92
|
+
|
93
|
+
dotest(BpDef2, "a string result")
|
94
|
+
end
|
95
|
+
|
72
96
|
end
|
73
97
|
|
data/test/ft_14b_subprocess.rb
CHANGED
@@ -111,5 +111,23 @@ rei A""")
|
|
111
111
|
c d""")
|
112
112
|
end
|
113
113
|
|
114
|
+
|
115
|
+
#
|
116
|
+
# TEST 3
|
117
|
+
|
118
|
+
class SubTest3 < OpenWFE::ProcessDefinition
|
119
|
+
|
120
|
+
subprocess "c", "d", :ref => :sub1
|
121
|
+
|
122
|
+
process_definition :name => :sub1 do
|
123
|
+
_print "${0} ${1}"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
#def xxxx_sub_3
|
128
|
+
def test_sub_3
|
129
|
+
dotest(SubTest3, "c d")
|
130
|
+
end
|
131
|
+
|
114
132
|
end
|
115
133
|
|
data/test/ft_22_history.rb
CHANGED
@@ -62,9 +62,30 @@ c""")
|
|
62
62
|
# (history.entries.size == 36),
|
63
63
|
# "invalid history count : #{history.entries.size}"
|
64
64
|
assert \
|
65
|
-
|
65
|
+
history.entries.size == 22,
|
66
66
|
"invalid history count : #{history.entries.size}"
|
67
67
|
end
|
68
68
|
|
69
|
+
def test_history_1
|
70
|
+
|
71
|
+
@engine.init_service("history", FileHistory)
|
72
|
+
|
73
|
+
dotest(
|
74
|
+
TestDefinition0,
|
75
|
+
"""a
|
76
|
+
b
|
77
|
+
c""")
|
78
|
+
|
79
|
+
@engine.ac["history"].output_file.flush
|
80
|
+
|
81
|
+
linecount = File.open("work/history.log") do |f|
|
82
|
+
f.readlines.size
|
83
|
+
end
|
84
|
+
|
85
|
+
assert \
|
86
|
+
linecount == 22,
|
87
|
+
"invalid history count : #{linecount}"
|
88
|
+
end
|
89
|
+
|
69
90
|
end
|
70
91
|
|
data/test/ft_23_when.rb
CHANGED
@@ -43,8 +43,35 @@ class FlowTest23 < Test::Unit::TestCase
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_0
|
46
|
-
|
47
|
-
|
46
|
+
dotest(TestDefinition0, "done\nok", true)
|
47
|
+
end
|
48
|
+
|
49
|
+
#
|
50
|
+
# Test 1
|
51
|
+
#
|
52
|
+
|
53
|
+
class TestWhen1 < ProcessDefinition
|
54
|
+
concurrence do
|
55
|
+
_when :frequency => "2s" do
|
56
|
+
sequence do
|
57
|
+
#reval "puts '___ equals : ' + fei.wfid"
|
58
|
+
_equals :value => "${done}", :other_value => "true"
|
59
|
+
end
|
60
|
+
sequence do
|
61
|
+
#reval "puts '___ consequence : ' + fei.wfid"
|
62
|
+
_print "ok"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
sequence do
|
66
|
+
_sleep "500"
|
67
|
+
_set :variable => "done", :value => "true"
|
68
|
+
_print "done"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_1
|
74
|
+
dotest(TestWhen1, "done\nok", true)
|
48
75
|
end
|
49
76
|
|
50
77
|
end
|
data/test/ft_23b_when.rb
CHANGED
@@ -42,5 +42,22 @@ class FlowTest23b < Test::Unit::TestCase
|
|
42
42
|
dotest(TestDefinition0, "ok", 5)
|
43
43
|
end
|
44
44
|
|
45
|
+
|
46
|
+
#
|
47
|
+
# Test 1
|
48
|
+
#
|
49
|
+
|
50
|
+
class TestWait23b1 < ProcessDefinition
|
51
|
+
concurrence do
|
52
|
+
_when :test => "true == true" do
|
53
|
+
end
|
54
|
+
_print "ok"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_1
|
59
|
+
dotest(TestWait23b1, "ok", true)
|
60
|
+
end
|
61
|
+
|
45
62
|
end
|
46
63
|
|