Sha256: 136f6e10d79b9bfb27dcd69d527931f3b7e3971eb5d3acaa2056cea816c4ea22

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 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 to be running on local host.
class ConnectTest < Test::Unit::TestCase
  include Mongo

  def test_connect_bad_name
    assert_raise_error(ReplicaSetConnectionError, "expected 'wrong-repl-set-name'") do
      Mongo::Connection.multi([['localhost', 27017], ['localhost', 27018], ['localhost', 27019]],
        :name => "wrong-repl-set-name")
    end
  end

  def test_connect
    @conn = Mongo::Connection.multi([['localhost', 27017], ['localhost', 27018], ['localhost', 27019]],
                                    :name => "foo")
    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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongo-1.1.3 test/replica_sets/connect_test.rb
mongo-1.1.2 test/replica_sets/connect_test.rb