Skip to content

Instantly share code, notes, and snippets.

@antirez
Created May 5, 2011 10:58
Show Gist options
  • Save antirez/956876 to your computer and use it in GitHub Desktop.
Save antirez/956876 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'redis'
def random_data
r = rand(2)
if r == 0
return rand(10000)
elsif r == 1
return "x"*rand(520)
end
end
r = Redis.new
1000000.times {
cmd = []
r.del(:mylist)
begin
2000.times {
c = rand(7)
if c == 0 or c == 1
data = random_data()
cmd << "LPUSH mylist #{data}"
r.lpush(:mylist,data)
elsif c == 2 or c == 3
data = random_data()
cmd << "RPUSH mylist #{data}"
r.rpush(:mylist,data)
elsif c == 4
cmd << "RPOP mylist"
r.rpop(:mylist)
elsif c == 5
cmd << "LPOP mylist"
r.lpop(:mylist)
else
len = r.llen(:mylist).to_i
ele = r.lindex(:mylist,rand(len))
cmd << "LREM mylist #{ele}"
r.lrem(:mylist,ele,1)
end
}
r.ping
rescue
puts cmd.join("\n")
f = File.open("/tmp/bug.txt","w")
f.write(cmd.join("\n"))
f.close
puts "** Bug found **"
exit
end
}
DEL mylist
RPUSH mylist 934
RPUSH mylist xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
LPOP mylist
RPUSH mylist 563
LPUSH mylist xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment