blob: 754cc5a4ef681914a4025650b0614e09437942bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
require 'spec_helper'
require 'fetch_shared_examples'
require 'sidekiq/base_reliable_fetch'
require 'sidekiq/semi_reliable_fetch'
require 'sidekiq/capsule'
require 'sidekiq/config'
require 'redis'
describe Sidekiq::SemiReliableFetch do
include_examples 'a Sidekiq fetcher'
describe '#retrieve_work' do
let(:queues) { ['stuff_to_do'] }
let(:options) { { queues: queues } }
let(:config) { Sidekiq::Config.new(options) }
let(:capsule) { Sidekiq::Capsule.new("default", config) }
let(:fetcher) { described_class.new(capsule) }
before { config.queues = queues }
context 'timeout config' do
before do
stub_env('SIDEKIQ_SEMI_RELIABLE_FETCH_TIMEOUT', timeout)
end
context 'when the timeout is not configured' do
let(:timeout) { nil }
it 'brpops with the default timeout timeout' do
Sidekiq.redis do |conn|
expect(conn).to receive(:blocking_call)
.with(conn.read_timeout + 5, 'brpop', 'queue:stuff_to_do', 5).once.and_call_original
fetcher.retrieve_work
end
end
end
context 'when the timeout is set in the env' do
let(:timeout) { '6' }
it 'brpops with the default timeout timeout' do
Sidekiq.redis do |conn|
expect(conn).to receive(:blocking_call)
.with(conn.read_timeout + 6, 'brpop', 'queue:stuff_to_do', 6).once.and_call_original
fetcher.retrieve_work
end
end
end
end
end
end
|