RUBY-190 bug fix for unavailable nodes on Connection#multi
This commit is contained in:
parent
9098070502
commit
e416e05fc7
@ -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
|
||||
|
38
test/replica_sets/connect_test.rb
Normal file
38
test/replica_sets/connect_test.rb
Normal 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
|
Loading…
Reference in New Issue
Block a user