Sha256: d89bcaabe34f22cb5a1cc0e0fe254abe4f7eb503978a165c2a5c1f771fb4d280

Contents?: true

Size: 1002 Bytes

Versions: 1

Compression:

Stored size: 1002 Bytes

Contents

require 'test_helper'

# A Worker Daemon needs to be running to perform this integration test.
class FailingWorkUnitsTest < Test::Unit::TestCase

  should "retry work units when they fail" do
    browser = Rack::Test::Session.new(Rack::MockSession.new(CloudCrowd::App))
    
    browser.post '/jobs', :json => {
      'action'  => 'failure_testing',
      'inputs'  => ['one', 'two', 'three'],
      'options' => {}
    }.to_json
    assert browser.last_response.ok? 
    
    job = CloudCrowd::Job.last
    (CloudCrowd.config[:work_unit_retries] - 1).times do
      job.work_units.each {|unit| unit.fail('failed', 10) }
    end
    assert job.reload.percent_complete == 0
    job.work_units.reload.each_with_index do |unit, i|
      assert unit.processing?
      assert unit.attempts == CloudCrowd.config[:work_unit_retries] - 1
      unit.fail('failed', 10)
      assert unit.job.any_work_units_failed? if i == 0
    end
    assert job.reload.failed?
    assert job.work_units.count == 0
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
documentcloud-cloud-crowd-0.0.4 test/acceptance/test_failing_work_units.rb