don't risk being stuck in readonly

This commit is contained in:
Sam 2017-10-25 13:22:50 +11:00
parent 877b7be579
commit 7ca8853861

View File

@ -19,20 +19,26 @@ describe ApplicationRequest do
ApplicationRequest.last_flush = Time.now.utc ApplicationRequest.last_flush = Time.now.utc
end end
it 'works even if redis is in readonly' do context "readonly test" do
disable_date_flush! after do
$redis.slaveof("no", "one")
end
inc(:http_total) it 'works even if redis is in readonly' do
inc(:http_total) disable_date_flush!
$redis.slaveof("127.0.0.1", 666) inc(:http_total)
inc(:http_total)
# flush will be deferred no error raised $redis.slaveof("127.0.0.1", 666)
inc(:http_total, autoflush: 3)
$redis.slaveof("no", "one")
inc(:http_total, autoflush: 3) # flush will be deferred no error raised
expect(ApplicationRequest.http_total.first.count).to eq(3) inc(:http_total, autoflush: 3)
$redis.slaveof("no", "one")
inc(:http_total, autoflush: 3)
expect(ApplicationRequest.http_total.first.count).to eq(3)
end
end end
it 'logs nothing for an unflushed increment' do it 'logs nothing for an unflushed increment' do