From b5576a7ecd5ef786502cb2d55cedf4fca26472ba Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Fri, 20 Jan 2012 10:56:39 -0500 Subject: [PATCH] RUBY-398 test case for this bug report --- test/replica_sets/complex_connect_test.rb | 38 +++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 test/replica_sets/complex_connect_test.rb diff --git a/test/replica_sets/complex_connect_test.rb b/test/replica_sets/complex_connect_test.rb new file mode 100644 index 0000000..b0f9829 --- /dev/null +++ b/test/replica_sets/complex_connect_test.rb @@ -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