Sha256: be86876044360203e14855dc3a28e99ec72afa788766de6ef4a9c0142b507f4c

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

#
# testing ruote
#
# Mon Dec 28 19:13:02 JST 2009
#

require File.join(File.dirname(__FILE__), 'concurrent_base')


class CtCancelTest < Test::Unit::TestCase
  include ConcurrentBase

  def test_collision

    pdef = Ruote.process_definition do
      sequence do
        alpha
      end
    end

    alpha = @engine0.register_participant :alpha do |workitem|
      # let reply immediately
    end

    #noisy

    wfid = @engine0.launch(pdef)

    @engine0.step 6

    @engine1.cancel_expression(
      { 'engine_id' => 'engine', 'wfid' => wfid, 'expid' => '0_0' })

    msgs = nil
    loop do
      msgs = @storage.get_msgs
      break if msgs.size == 2
      #p msgs.collect { |m| m['fei']['expid'] }.uniq
      #break if
      #  msgs.size == 2 &&
      #  msgs.collect { |m| m['fei']['expid'] }.uniq == %w[ 0_0 ]
    end

    #msgs.each { |m| p m }
    #puts

    t1 = Thread.new { @engine0.do_step(msgs[1]) }
    t0 = Thread.new { @engine1.do_step(msgs[0]) }
    t1.join
    t0.join

    #puts

    @engine0.step 4

    sleep 0.010

    assert_equal 0, @storage.get_msgs.size

    exps = @storage.get_many('expressions')
    exps.each { |exp|
      p [ exp['fei']['expid'], exp['original_tree'] ]
    } if exps.size > 0

    assert_equal 0, exps.size
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruote-2.1.1 test/functional/ct_2_cancel.rb