Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.

Commit

Permalink
Add failing spec simulating race condition.
Browse files Browse the repository at this point in the history
  • Loading branch information
marshall-lee committed Aug 21, 2015
1 parent bf8790b commit bd7451d
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions spec/redis/connection/celluloid_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,40 @@
expect { redis.shutdown }.not_to raise_error
end
end

describe "using inside Celluloid::IO" do
before do
class Incrementor
include Celluloid::IO

def initialize
@redis = Redis.new(:driver => :celluloid)
end

def increment!
sleep(rand / 10)
@redis.incr 'rabbits'
rescue
STDERR.puts "I cannot increment rabbits because of #{$!.inspect}!"
raise RuntimeError
end
end
end

let(:actor) {
Incrementor.new
}
let(:count) { 1000 }

it "just survives" do
redis = Redis.new
redis.set 'rabbits', 0

count.times do
actor.async.increment! rescue nil
end
sleep 10
expect(redis.get 'rabbits').to eq(count.to_s)
end
end
end

0 comments on commit bd7451d

Please sign in to comment.