Sha256: 79d1e70d82e316b39fd6e58b50a469bf2695bfb13c20a6b99ea7c7a07e8d47ff

Contents?: true

Size: 1.12 KB

Versions: 132

Compression:

Stored size: 1.12 KB

Contents

require './test/test_helper'

# NOTE: these tests are run only if we can connect to a single MongoDB in slave mode.
class SlaveConnectionTest < Test::Unit::TestCase
  include Mongo

  def self.connect_to_slave
    @@host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
    @@port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
    conn = Connection.new(@@host, @@port, :slave_ok => true)
    response = conn['admin'].command(:ismaster => 1)
    Mongo::Support.ok?(response) && response['ismaster'] != 1
  end

  if self.connect_to_slave
    puts "Connected to slave; running slave tests."

    def test_connect_to_slave
      assert_raise Mongo::ConnectionFailure do
        @db = Connection.new(@@host, @@port, :slave_ok => false).db('ruby-mongo-demo')
      end
    end

    def test_slave_ok_sent_to_queries
      @con = Connection.new(@@host, @@port, :slave_ok => true)
      assert_equal true, @con.slave_ok?
    end
  else
    puts "Not connected to slave; skipping slave connection tests."

    def test_slave_ok_false_on_queries
      @conn = Connection.new(@@host, @@port)
      assert !@conn.slave_ok?
    end
  end
end

Version data entries

132 entries across 86 versions & 7 rubygems

Version Path
mongo-1.5.2 test/auxillary/slave_connection_test.rb
mongo-1.5.1 test/auxillary/slave_connection_test.rb
mongo-1.5.0 test/auxillary/slave_connection_test.rb
mongo-1.5.0.rc0 test/auxillary/slave_connection_test.rb
jmongo-1.1.5 test/auxillary/slave_connection_test.rb
jmongo-1.1.4 test/auxillary/slave_connection_test.rb
jmongo-1.1.3 test/auxillary/slave_connection_test.rb
jmongo-1.1.2 test/auxillary/slave_connection_test.rb
jmongo-1.1.1 test/auxillary/slave_connection_test.rb
jmongo-1.1.0 test/auxillary/slave_connection_test.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/mongo-1.3.1/test/auxillary/slave_connection_test.rb
mongo-1.4.0 test/auxillary/slave_connection_test.rb
jonbell-mongo-1.3.1.2 test/auxillary/slave_connection_test.rb
mongo-lyon-1.2.4 test/auxillary/slave_connection_test.rb
mongo-1.3.1 test/auxillary/slave_connection_test.rb
mongo-1.3.0 test/auxillary/slave_connection_test.rb
mongo-1.3.0.rc0 test/auxillary/slave_connection_test.rb
mongo-1.2.4 test/auxillary/slave_connection_test.rb
mongo-1.2.3 test/auxillary/slave_connection_test.rb
mongo-1.2.2 test/auxillary/slave_connection_test.rb