Sha256: 11113c6abaca1def46af0a44784fef6845ea7751b6cbf0e0762b44eba716c408
Contents?: true
Size: 1.23 KB
Versions: 6
Compression:
Stored size: 1.23 KB
Contents
$:.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, one of which is an arbiter, to be running # on the local host. class ReplicaSetNodeTypeTest < Test::Unit::TestCase include Mongo def setup @conn = Mongo::Connection.multi([['localhost', 27017], ['localhost', 27018], ['localhost', 27019]]) @db = @conn.db(MONGO_TEST_DB) @db.drop_collection("test-sets") @coll = @db.collection("test-sets") end def test_correct_node_types p @conn.primary p @conn.secondaries p @conn.arbiters assert_equal 1, @conn.secondaries.length assert_equal 1, @conn.arbiters.length old_secondary = @conn.secondaries.first old_primary = @conn.primary puts "Please disconnect the current primary and reconnect so that it becomes secondary." gets # Insert something to rescue the connection failure. rescue_connection_failure do @coll.insert({:a => 30}, :safe => true) end assert_equal 1, @conn.secondaries.length assert_equal 1, @conn.arbiters.length assert_equal old_primary, @conn.secondaries.first assert_equal old_secondary, @conn.primary end end
Version data entries
6 entries across 6 versions & 1 rubygems