test/functional/ct_2_cancel.rb in ruote-2.2.0 vs test/functional/ct_2_cancel.rb in ruote-2.3.0
- old
+ new
@@ -3,11 +3,11 @@
# testing ruote
#
# Mon Dec 28 19:13:02 JST 2009
#
-require File.join(File.dirname(__FILE__), 'concurrent_base')
+require File.expand_path('../concurrent_base', __FILE__)
class CtCancelTest < Test::Unit::TestCase
include ConcurrentBase
@@ -22,60 +22,71 @@
sequence do
alpha
end
end
- alpha = @engine0.register_participant :alpha do |workitem|
+ alpha = @dashboard0.register_participant :alpha do |workitem|
# let reply immediately
end
- noisy if ARGV.include?('-N')
+ wfid = @dashboard0.launch(pdef)
- wfid = @engine0.launch(pdef)
+ #
+ # test preparation...
- @engine0.step 7
+ @dashboard0.step 6
dispatched_seen = false
reply_msg = nil
+ #
+ # reach the point where the reply is coming (and the dispatched msg has
+ # passed)
+
loop do
- m = @engine0.next_msg
+ m = @dashboard0.next_msg
ma = m['action']
if ma == 'dispatched'
dispatched_seen = true
- @engine0.do_process(m)
+ @dashboard0.do_process(m)
break if reply_msg
elsif ma == 'reply'
reply_msg = m
- break
+ break if dispatched_seen
else
- @engine0.do_process(m)
+ @dashboard0.do_process(m)
end
end
- #p dispatched_seen
+ #
+ # inject the cancel message
- @engine0.cancel_expression(
+ @dashboard0.cancel_expression(
{ 'engine_id' => 'engine', 'wfid' => wfid, 'expid' => '0_0' })
- msgs = @engine0.gather_msgs
+ msgs = @dashboard0.gather_msgs
msgs = msgs - [ reply_msg ]
assert_equal 1, msgs.size
assert_equal 'cancel', msgs.first['action']
+ #
+ # trusting is good, checking is better
- t1 = Thread.new { @engine1.do_process(msgs.first) }
- t0 = Thread.new { @engine0.do_process(reply_msg) }
+ #
+ # try to force a collision between the reply msg and the cancel msg
+
+ t1 = Thread.new { @dashboard1.do_process(msgs.first) }
+ t0 = Thread.new { @dashboard0.do_process(reply_msg) }
t1.join
t0.join
loop do
- m = @engine0.next_msg
- @engine0.do_process(m)
+ m = @dashboard0.next_msg
+ @dashboard0.do_process(m)
break if m['action'] == 'terminated'
end
- assert_nil @engine0.process(wfid)
+ assert_nil @dashboard0.process(wfid)
end
end