add a little test script for autoreconnection with pairing

This commit is contained in:
Mike Dirolf 2009-08-27 15:20:27 -04:00
parent f6cb2972d5
commit 734edf6c65
1 changed files with 26 additions and 0 deletions

26
bin/autoreconnect.rb Normal file
View File

@ -0,0 +1,26 @@
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'mongo'
db = Mongo::Connection.new({:left => ["localhost", 27017], :right => ["localhost", 27018]}, nil, :auto_reconnect => true).db("ruby_test")
db['test'].clear
10.times do |i|
db['test'].save("x" => i)
end
while true do
begin
exit() if not db['test'].count() == 10
x = 0
db['test'].find().each do |doc|
x += doc['x']
end
exit() if not x == 45
print "."
STDOUT.flush
sleep 1
rescue
sleep 1
end
end