Sha256: 26b1ccba85444942df9401dae89df2953bdd58a621e241d6163cf1039184b1e2

Contents?: true

Size: 852 Bytes

Versions: 2

Compression:

Stored size: 852 Bytes

Contents

require 'spec_helper'

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
    # namespaces = [
    #   described_class::PROCESSOR_NAMESPACE,
    #   described_class::HEARTBEAT_NAMESPACE
    # ]

    # Sidekiq.redis do |it|
    #   namespaces.flat_map {|namespace|
    #     it.keys(namespace + '*')
    #   }.each {|key| it.del key }
    # end

    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.busy.should == 2

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sidekiq-limit_fetch-1.6 spec/sidekiq/limit_fetch/global/monitor_spec.rb
sidekiq-limit_fetch-1.5 spec/sidekiq/limit_fetch/global/monitor_spec.rb