Sha256: 819927f83ba11cc5a39784657a7a941c7bf373e2dadb53b94c5604f4333e20d9

Contents?: true

Size: 947 Bytes

Versions: 2

Compression:

Stored size: 947 Bytes

Contents

require 'spec_helper'

Thread.abort_on_exception = true

describe Sidekiq::LimitFetch::Global::Monitor do
  let(:queues) { double dynamic?: false }
  let(:monitor) { described_class.start! queues, 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

2 entries across 2 versions & 1 rubygems

Version Path
sidekiq-limit_fetch-2.4.1 spec/sidekiq/limit_fetch/global/monitor_spec.rb
sidekiq-limit_fetch-2.4.0 spec/sidekiq/limit_fetch/global/monitor_spec.rb