Sha256: afe8c8247c68b53a88ccdfafd2920155d4575f8bf5ddc6eb590705a871d296be

Contents?: true

Size: 1017 Bytes

Versions: 3

Compression:

Stored size: 1017 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::Server))
    
    browser.post '/jobs', :job => {
      '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('{"output":"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

3 entries across 3 versions & 2 rubygems

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