Sha256: e00a95bb3d634e89962c30b2381e43619823bc8308a5ef7d78a0375bfebd2d1e

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require './test/replica_sets/rs_test_helper'

class ComplexConnectTest < Test::Unit::TestCase
  
  def setup
    ensure_rs
  end

  def teardown
    @rs.restart_killed_nodes
    @conn.close if defined?(@conn) && @conn
  end

  def test_complex_connect
    primary = Connection.new(@rs.host, @rs.ports[0])

    @conn = ReplSetConnection.new([
      "#{@rs.host}:#{@rs.ports[2]}",
      "#{@rs.host}:#{@rs.ports[1]}",
      "#{@rs.host}:#{@rs.ports[0]}",
    ])

    version = @conn.server_version

    @conn['test']['foo'].insert({:a => 1})
    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?(@rs.ports[2].to_s)
    end

    assert_raise ConnectionFailure do
      primary['admin'].command({:replSetReconfig => config})
    end
    @rs.ensure_up

    force_stepdown = BSON::OrderedHash.new
    force_stepdown[:replSetStepDown] = 1
    force_stepdown[:force] = true

    assert_raise ConnectionFailure do
      primary['admin'].command(force_stepdown)
    end

    # isMaster is currently broken in 2.1+ when called on removed nodes
    if version < "2.1"
      rescue_connection_failure do
        assert @conn['test']['foo'].find_one
      end

      assert @conn['test']['foo'].find_one
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongo-1.7.1 test/replica_sets/complex_connect_test.rb
mongo-1.7.0 test/replica_sets/complex_connect_test.rb
mongo-1.7.0.rc0 test/replica_sets/complex_connect_test.rb