Sha256: 4dfcff3c27ba2a2f1f29beba605a03d6c87564eb74a416c6c78f96bae2c4b994

Contents?: true

Size: 890 Bytes

Versions: 1

Compression:

Stored size: 890 Bytes

Contents

class MultithreadingTest < Minitest::Test
  CustomError = Class.new StandardError

  def setup
    @operation = Orchestra::Operation.new do
      node :map_thread_ids do
        iterates_over :list
        provides :thread_ids
        perform do |item|
          raise CustomError, "blow up" if item == :blow_up
          Thread.current.object_id
        end
      end

      self.result = :thread_ids
    end

    @conductor = Orchestra::Conductor.new
    @conductor.thread_count = 5
  end

  def test_multithreading
    list = (1..100).to_a

    thread_ids = @conductor.perform @operation, :list => list

    assert thread_ids.uniq.size > 2, "performance must be spread across threads"
  end

  def test_exception_during_multithreading
    list = (1..100).to_a
    list[23] = :blow_up

    assert_raises CustomError do
      @conductor.perform @operation, :list => list
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ntl-orchestra-0.9.1 test/integration/multithreading_test.rb