RUBY-379 RUBY-381 test

This commit is contained in:
Kyle Banker 2011-12-05 16:16:06 -05:00
parent b6ff77fcbc
commit e0f44ca41d
1 changed files with 13 additions and 4 deletions

View File

@ -62,13 +62,22 @@ class ConnectTest < Test::Unit::TestCase
end
def test_connect_with_primary_stepped_down
self.rs.step_down_primary
@conn = ReplSetConnection.new([self.rs.host, self.rs.ports[0]], [self.rs.host, self.rs.ports[1]],
[self.rs.host, self.rs.ports[2]])
@conn[MONGO_TEST_DB]['bar'].save({:a => 1}, {:safe => {:w => 3}})
assert @conn[MONGO_TEST_DB]['bar'].find_one
primary = Mongo::Connection.new(@conn.primary_pool.host, @conn.primary_pool.port)
primary['admin'].command({:replSetStepDown => 60})
assert @conn.connected?
assert_raise_error Mongo::ConnectionFailure, "not master" do
@conn[MONGO_TEST_DB]['bar'].find_one
end
assert !@conn.connected?
rescue_connection_failure do
@conn = ReplSetConnection.new([self.rs.host, self.rs.ports[0]], [self.rs.host, self.rs.ports[1]],
[self.rs.host, self.rs.ports[2]])
@conn[MONGO_TEST_DB]['bar'].find_one
end
assert @conn.connected?
end
def test_connect_with_connection_string