Sha256: 29679c50fd7181b8ca9559634ced00e7288bbbf68e1b7f4bb0c7774f4399b5b6

Contents?: true

Size: 897 Bytes

Versions: 11

Compression:

Stored size: 897 Bytes

Contents

require 'spec_helper'

Thread.abort_on_exception = true

describe Sidekiq::LimitFetch::Global::Monitor do
  let(:monitor) { described_class.start! ttl, timeout }
  let(:ttl) { 1 }
  let(:queue) { Sidekiq::Queue[name] }
  let(:name) { 'default' }

  before :each do
    monitor
  end

  after :each do
    monitor.kill
  end

  context 'old locks' do
    let(:timeout) { 0.5 }

    it 'should remove invalidated old locks' do
      2.times { queue.acquire }
      sleep 2*ttl
      queue.probed.should == 2

      described_class.stub :update_heartbeat
      sleep 2*ttl
      queue.probed.should == 0
    end

    it 'should remove invalid locks' do
      2.times { queue.acquire }
      described_class.stub :update_heartbeat
      Sidekiq.redis do |it|
        it.del Sidekiq::LimitFetch::Global::Monitor::PROCESS_SET
      end
      sleep 2*ttl
      queue.probed.should == 0
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
sidekiq-limit_fetch-2.3.0 spec/sidekiq/limit_fetch/global/monitor_spec.rb
sidekiq-limit_fetch-2.2.7 spec/sidekiq/limit_fetch/global/monitor_spec.rb
sidekiq-limit_fetch-2.2.6 spec/sidekiq/limit_fetch/global/monitor_spec.rb
sidekiq-limit_fetch-2.2.5 spec/sidekiq/limit_fetch/global/monitor_spec.rb
sidekiq-limit_fetch-2.2.4 spec/sidekiq/limit_fetch/global/monitor_spec.rb
sidekiq-limit_fetch-2.2.3 spec/sidekiq/limit_fetch/global/monitor_spec.rb
sidekiq-limit_fetch-2.2.2 spec/sidekiq/limit_fetch/global/monitor_spec.rb
sidekiq-limit_fetch-2.2.1 spec/sidekiq/limit_fetch/global/monitor_spec.rb
sidekiq-limit_fetch-2.2.0 spec/sidekiq/limit_fetch/global/monitor_spec.rb
sidekiq-limit_fetch-2.1.3 spec/sidekiq/limit_fetch/global/monitor_spec.rb
sidekiq-limit_fetch-2.1.2 spec/sidekiq/limit_fetch/global/monitor_spec.rb