Sha256: 603802bd9ea20c9baa545be802e2599fa3c61bede9424a45d81f7c0add93f375

Contents?: true

Size: 1.74 KB

Versions: 47

Compression:

Stored size: 1.74 KB

Contents

require './test/test_helper'
include Mongo

class PoolManagerTest < Test::Unit::TestCase

  context "Initialization: " do

    should "populate pools correctly" do
      TCPSocket.stubs(:new).returns(new_mock_socket)
      @db = new_mock_db

      @connection = stub("Connection")
      @connection.stubs(:connect_timeout).returns(5)
      @connection.stubs(:op_timeout).returns(5)
      @connection.stubs(:pool_size).returns(2)
      @connection.stubs(:pool_timeout).returns(100)
      @connection.stubs(:seeds).returns(['localhost:30000'])
      @connection.stubs(:socket_class).returns(TCPSocket)
      @connection.stubs(:[]).returns(@db)

      @connection.stubs(:replica_set_name).returns(nil)
      @connection.stubs(:log)
      @arbiters = ['localhost:27020']
      @hosts = ['localhost:27017', 'localhost:27018', 'localhost:27019',
        'localhost:27020']

      @db.stubs(:command).returns(
        # First call to get a socket.
        {'ismaster' => true, 'hosts' => @hosts, 'arbiters' => @arbiters},

        # Subsequent calls to configure pools.
        {'ismaster' => true, 'hosts' => @hosts, 'arbiters' => @arbiters},
        {'secondary' => true, 'hosts' => @hosts, 'arbiters' => @arbiters},
        {'secondary' => true, 'hosts' => @hosts, 'arbiters' => @arbiters},
        {'arbiterOnly' => true, 'hosts' => @hosts, 'arbiters' => @arbiters})

      seeds = [['localhost', 27017]]
      manager = Mongo::PoolManager.new(@connection, seeds)
      manager.connect

      assert_equal ['localhost', 27017], manager.primary
      assert_equal 27017, manager.primary_pool.port
      assert_equal 2, manager.secondaries.length
      assert_equal 27018, manager.secondary_pools[0].port
      assert_equal [['localhost', 27020]], manager.arbiters
    end

  end

end

Version data entries

47 entries across 47 versions & 2 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/mongo-1.6.2/test/unit/pool_manager_test.rb
classiccms-0.7.4 vendor/bundle/gems/mongo-1.6.2/test/unit/pool_manager_test.rb
classiccms-0.7.3 vendor/bundle/gems/mongo-1.6.2/test/unit/pool_manager_test.rb
classiccms-0.7.2 vendor/bundle/gems/mongo-1.6.2/test/unit/pool_manager_test.rb
classiccms-0.7.1 vendor/bundle/gems/mongo-1.6.2/test/unit/pool_manager_test.rb
classiccms-0.7.0 vendor/bundle/gems/mongo-1.6.2/test/unit/pool_manager_test.rb
classiccms-0.6.9 vendor/bundle/gems/mongo-1.6.2/test/unit/pool_manager_test.rb
classiccms-0.6.8 vendor/bundle/gems/mongo-1.6.2/test/unit/pool_manager_test.rb
classiccms-0.6.7 vendor/bundle/gems/mongo-1.6.2/test/unit/pool_manager_test.rb
classiccms-0.6.6 vendor/bundle/gems/mongo-1.6.2/test/unit/pool_manager_test.rb
classiccms-0.6.5 vendor/bundle/gems/mongo-1.6.2/test/unit/pool_manager_test.rb
classiccms-0.6.4 vendor/bundle/gems/mongo-1.6.2/test/unit/pool_manager_test.rb
classiccms-0.6.3 vendor/bundle/gems/mongo-1.6.2/test/unit/pool_manager_test.rb
classiccms-0.6.2 vendor/bundle/gems/mongo-1.6.2/test/unit/pool_manager_test.rb
classiccms-0.6.1 vendor/bundle/gems/mongo-1.6.2/test/unit/pool_manager_test.rb
classiccms-0.6.0 vendor/bundle/gems/mongo-1.6.2/test/unit/pool_manager_test.rb
classiccms-0.5.17 vendor/bundle/gems/mongo-1.6.2/test/unit/pool_manager_test.rb
classiccms-0.5.16 vendor/bundle/gems/mongo-1.6.2/test/unit/pool_manager_test.rb
classiccms-0.5.15 vendor/bundle/gems/mongo-1.6.2/test/unit/pool_manager_test.rb
classiccms-0.5.14 vendor/bundle/gems/mongo-1.6.2/test/unit/pool_manager_test.rb