Sha256: 5b54d210aaea0b8b2f0107ccbc903838df3a9782c8cb72249840c8848de82704

Contents?: true

Size: 1.66 KB

Versions: 3

Compression:

Stored size: 1.66 KB

Contents

require 'sidekiq-status'

class StubJob
  include Sidekiq::Worker
  include Sidekiq::Status::Worker

  sidekiq_options 'retry' => false

  def perform(*args)
  end
end

class ExpiryJob < StubJob
  def expiration
    15
  end
end

class LongJob < StubJob
  def perform(*args)
    sleep args[0] || 0.25
  end
end

class DataJob < StubJob
  def perform
    sleep 0.1
    store({data: 'meow'})
    retrieve(:data).should == 'meow'
    sleep 0.1
  end
end

class ProgressJob < StubJob
  def perform
    total 500
    at 100, 'howdy, partner?'
    sleep 0.1
  end
end

class ConfirmationJob < StubJob
  def perform(*args)
    Sidekiq.redis do |conn|
      conn.publish "job_messages_#{jid}", "while in #perform, status = #{conn.hget "sidekiq:status:#{jid}", :status}"
    end
  end
end

class NoStatusConfirmationJob
  include Sidekiq::Worker
  def perform(id)
    Sidekiq.redis do |conn|
      conn.set "NoStatusConfirmationJob_#{id}", "done"
    end
  end
end

class FailingJob < StubJob
  def perform
    raise StandardError
  end
end

class RetryAndFailJob < StubJob
  sidekiq_options retry: 1

  def perform
    raise StandardError
  end
end

class FailingHardJob < StubJob
  def perform
    raise Exception
  end
end

class ExitedJob < StubJob
  def perform
    raise SystemExit
  end
end

class InterruptedJob < StubJob
  def perform
    raise Interrupt
  end
end

class RetriedJob < StubJob

  sidekiq_options 'retry' => true
  sidekiq_retry_in do |count| 3 end # 3 second delay > job timeout in test suite

  def perform()
    Sidekiq.redis do |conn|
      key = "RetriedJob_#{jid}"
      unless conn.exists key
        conn.set key, 'tried'
        raise StandardError
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sidekiq-status-1.1.1 spec/support/test_jobs.rb
sidekiq-status-1.1.0 spec/support/test_jobs.rb
sidekiq-status-1.0.2 spec/support/test_jobs.rb