Sha256: a2fc153c051279de1875f4ff7cadf75bfa895d00d16ff2f5cd25a72f9fb0ac96

Contents?: true

Size: 1.21 KB

Versions: 51

Compression:

Stored size: 1.21 KB

Contents

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

class ReplicaSetQueryTest < Test::Unit::TestCase

  def setup
    ensure_rs
    @conn = ReplSetConnection.new build_seeds(1)
    @db = @conn.db(MONGO_TEST_DB)
    @db.drop_collection("test-sets")
    @coll = @db.collection("test-sets")
  end

  def teardown
    @rs.restart_killed_nodes
    @conn.close if @conn
  end

  def test_query
    @coll.save({:a => 20}, :safe => {:w => 3})
    @coll.save({:a => 30}, :safe => {:w => 3})
    @coll.save({:a => 40}, :safe => {:w => 3})
    results = []
    @coll.find.each {|r| results << r}
    [20, 30, 40].each do |a|
      assert results.any? {|r| r['a'] == a}, "Could not find record for a => #{a}"
    end

    #puts "Benchmark before failover: #{benchmark_queries}"

    @rs.kill_primary

    results = []
    rescue_connection_failure do
      @coll.find.each {|r| results << r}
      [20, 30, 40].each do |a|
        assert results.any? {|r| r['a'] == a}, "Could not find record for a => #{a}"
      end

    #puts "Benchmark after failover: #{benchmark_queries}"
    end
  end

  def benchmark_queries
    t1 = Time.now
    10000.times { @coll.find_one }
    Time.now - t1
  end

end

Version data entries

51 entries across 51 versions & 2 rubygems

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