From 734edf6c65b9ff2445337d823d22ec1bb2c4f65d Mon Sep 17 00:00:00 2001 From: Mike Dirolf Date: Thu, 27 Aug 2009 15:20:27 -0400 Subject: [PATCH] add a little test script for autoreconnection with pairing --- bin/autoreconnect.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 bin/autoreconnect.rb diff --git a/bin/autoreconnect.rb b/bin/autoreconnect.rb new file mode 100644 index 0000000..0ced579 --- /dev/null +++ b/bin/autoreconnect.rb @@ -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