forked from mongodb/mongo-ruby-driver
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RUBY-398 test case for this bug report
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) | ||
require './test/replica_sets/rs_test_helper' | ||
|
||
class ComplexConnectTest < Test::Unit::TestCase | ||
include ReplicaSetTest | ||
|
||
def teardown | ||
self.rs.restart_killed_nodes | ||
@conn.close if defined?(@conn) && @conn | ||
end | ||
|
||
def test_complex_connect | ||
primary = Connection.new(self.rs.host, self.rs.ports[0]) | ||
|
||
@conn = ReplSetConnection.new([self.rs.host, self.rs.ports[2]], [self.rs.host, self.rs.ports[1]], | ||
[self.rs.host, self.rs.ports[0]]) | ||
|
||
assert @conn['test']['foo'].find_one | ||
|
||
config = primary['local']['system.replset'].find_one | ||
config['version'] += 1 | ||
config['members'].delete_if do |member| | ||
member['host'].include?(self.rs.ports[2].to_s) | ||
end | ||
|
||
assert_raise ConnectionFailure do | ||
primary['admin'].command({:replSetReconfig => config}) | ||
end | ||
self.rs.ensure_up | ||
assert_raise ConnectionFailure do | ||
primary['admin'].command({:replSetStepDown => 1}) | ||
end | ||
|
||
rescue_connection_failure do | ||
assert @conn['test']['foo'].find_one | ||
end | ||
end | ||
end |