minor: testing fixes, cleaning output

This commit is contained in:
Tyler Brock 2012-04-04 16:44:01 -04:00
parent c992369918
commit d42eee278b
7 changed files with 21 additions and 15 deletions

View File

@ -139,11 +139,11 @@ module Mongo
if @connect == 'direct'
opts[:slave_ok] = true
else
opts[:read_secondary] = true
opts[:read] = :secondary
end
end
opts[:rs_name] = @replicaset if @replicaset
opts[:name] = @replicaset if @replicaset
opts
end

View File

@ -175,8 +175,8 @@ class TestConnection < Test::Unit::TestCase
end
seeds = @conn.seeds
assert_equal 2, seeds.length
assert_equal ['foo', 27017], nodes[0]
assert_equal ['bar', 27018], nodes[1]
assert_equal ['foo', 27017], seeds[0]
assert_equal ['bar', 27018], seeds[1]
end
def test_fsync_lock

View File

@ -15,11 +15,11 @@ class ComplexConnectTest < Test::Unit::TestCase
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]]
)
@conn = ReplSetConnection.new([
"#{@rs.host}:#{@rs.ports[2]}",
"#{@rs.host}:#{@rs.ports[1]}",
"#{@rs.host}:#{@rs.ports[0]}",
])
@conn['test']['foo'].insert({:a => 1})
assert @conn['test']['foo'].find_one

View File

@ -99,7 +99,9 @@ class ConnectTest < Test::Unit::TestCase
end
def test_connect_with_connection_string
@conn = Connection.from_uri("mongodb://#{@rs.host}:#{@rs.ports[0]},#{@rs.host}:#{@rs.ports[1]}?replicaset=#{@rs.name}")
silently do
@conn = Connection.from_uri("mongodb://#{@rs.host}:#{@rs.ports[0]},#{@rs.host}:#{@rs.ports[1]}?replicaset=#{@rs.name}")
end
assert @conn.is_a?(ReplSetConnection)
assert @conn.connected?
end
@ -117,7 +119,9 @@ class ConnectTest < Test::Unit::TestCase
end
def test_connect_with_full_connection_string
@conn = Connection.from_uri("mongodb://#{@rs.host}:#{@rs.ports[0]},#{@rs.host}:#{@rs.ports[1]}?replicaset=#{@rs.name};safe=true;w=2;fsync=true;slaveok=true")
silently do
@conn = Connection.from_uri("mongodb://#{@rs.host}:#{@rs.ports[0]},#{@rs.host}:#{@rs.ports[1]}?replicaset=#{@rs.name};safe=true;w=2;fsync=true;slaveok=true")
end
assert @conn.is_a?(ReplSetConnection)
assert @conn.connected?
assert_equal 2, @conn.safe[:w]

View File

@ -26,7 +26,7 @@ class ReplicaSetQueryTest < Test::Unit::TestCase
assert results.any? {|r| r['a'] == a}, "Could not find record for a => #{a}"
end
puts "Benchmark before failover: #{benchmark_queries}"
#puts "Benchmark before failover: #{benchmark_queries}"
@rs.kill_primary
@ -37,7 +37,7 @@ class ReplicaSetQueryTest < Test::Unit::TestCase
assert results.any? {|r| r['a'] == a}, "Could not find record for a => #{a}"
end
puts "Benchmark after failover: #{benchmark_queries}"
#puts "Benchmark after failover: #{benchmark_queries}"
end
end

View File

@ -87,7 +87,7 @@ class ReadPreferenceTest < Test::Unit::TestCase
results = []
rescue_connection_failure do
puts "@coll.find().each"
#puts "@coll.find().each"
@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}"

View File

@ -10,9 +10,10 @@ class ReplicaSetRefreshTest < Test::Unit::TestCase
def teardown
@rs.restart_killed_nodes
@conn.close if @conn
@conn.close if defined?(@conn)
end
=begin
def test_connect_speed
Benchmark.bm do |x|
x.report("Connect") do
@ -31,6 +32,7 @@ class ReplicaSetRefreshTest < Test::Unit::TestCase
end
end
end
=end
def test_connect_and_manual_refresh_with_secondaries_down
@rs.kill_all_secondaries