RUBY-190 bug fix for unavailable nodes on Connection#multi

This commit is contained in:
Kyle Banker 2010-10-21 14:33:48 -04:00
parent 9098070502
commit e416e05fc7
2 changed files with 39 additions and 1 deletions

View File

@ -600,7 +600,7 @@ module Mongo
config = self['admin'].command({:ismaster => 1}, :sock => socket)
rescue OperationFailure, SocketError, SystemCallError, IOError => ex
close
close unless connected?
ensure
@nodes_tried << node
if config

View File

@ -0,0 +1,38 @@
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'mongo'
require 'test/unit'
require './test/test_helper'
# NOTE: This test expects a replica set of three nodes to be running on local host.
class ConnectTest < Test::Unit::TestCase
include Mongo
def test_connect
@conn = Mongo::Connection.multi([['localhost', 27017], ['localhost', 27018], ['localhost', 27019]])
assert @conn.connected?
end
def test_connect_with_first_node_down
puts "Please kill the node at 27017."
gets
@conn = Mongo::Connection.multi([['localhost', 27017], ['localhost', 27018], ['localhost', 27019]])
assert @conn.connected?
end
def test_connect_with_second_node_down
puts "Please kill the node at 27018."
gets
@conn = Mongo::Connection.multi([['localhost', 27017], ['localhost', 27018], ['localhost', 27019]])
assert @conn.connected?
end
def test_connect_with_third_node_down
puts "Please kill the node at 27019."
gets
@conn = Mongo::Connection.multi([['localhost', 27017], ['localhost', 27018], ['localhost', 27019]])
assert @conn.connected?
end
end