minor: testing fixes, cleaning output
This commit is contained in:
parent
c992369918
commit
d42eee278b
|
@ -139,11 +139,11 @@ module Mongo
|
||||||
if @connect == 'direct'
|
if @connect == 'direct'
|
||||||
opts[:slave_ok] = true
|
opts[:slave_ok] = true
|
||||||
else
|
else
|
||||||
opts[:read_secondary] = true
|
opts[:read] = :secondary
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
opts[:rs_name] = @replicaset if @replicaset
|
opts[:name] = @replicaset if @replicaset
|
||||||
|
|
||||||
opts
|
opts
|
||||||
end
|
end
|
||||||
|
|
|
@ -175,8 +175,8 @@ class TestConnection < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
seeds = @conn.seeds
|
seeds = @conn.seeds
|
||||||
assert_equal 2, seeds.length
|
assert_equal 2, seeds.length
|
||||||
assert_equal ['foo', 27017], nodes[0]
|
assert_equal ['foo', 27017], seeds[0]
|
||||||
assert_equal ['bar', 27018], nodes[1]
|
assert_equal ['bar', 27018], seeds[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fsync_lock
|
def test_fsync_lock
|
||||||
|
|
|
@ -15,11 +15,11 @@ class ComplexConnectTest < Test::Unit::TestCase
|
||||||
def test_complex_connect
|
def test_complex_connect
|
||||||
primary = Connection.new(@rs.host, @rs.ports[0])
|
primary = Connection.new(@rs.host, @rs.ports[0])
|
||||||
|
|
||||||
@conn = ReplSetConnection.new(
|
@conn = ReplSetConnection.new([
|
||||||
[@rs.host, @rs.ports[2]],
|
"#{@rs.host}:#{@rs.ports[2]}",
|
||||||
[@rs.host, @rs.ports[1]],
|
"#{@rs.host}:#{@rs.ports[1]}",
|
||||||
[@rs.host, @rs.ports[0]]
|
"#{@rs.host}:#{@rs.ports[0]}",
|
||||||
)
|
])
|
||||||
|
|
||||||
@conn['test']['foo'].insert({:a => 1})
|
@conn['test']['foo'].insert({:a => 1})
|
||||||
assert @conn['test']['foo'].find_one
|
assert @conn['test']['foo'].find_one
|
||||||
|
|
|
@ -99,7 +99,9 @@ class ConnectTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_connect_with_connection_string
|
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.is_a?(ReplSetConnection)
|
||||||
assert @conn.connected?
|
assert @conn.connected?
|
||||||
end
|
end
|
||||||
|
@ -117,7 +119,9 @@ class ConnectTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_connect_with_full_connection_string
|
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.is_a?(ReplSetConnection)
|
||||||
assert @conn.connected?
|
assert @conn.connected?
|
||||||
assert_equal 2, @conn.safe[:w]
|
assert_equal 2, @conn.safe[:w]
|
||||||
|
|
|
@ -26,7 +26,7 @@ class ReplicaSetQueryTest < Test::Unit::TestCase
|
||||||
assert results.any? {|r| r['a'] == a}, "Could not find record for a => #{a}"
|
assert results.any? {|r| r['a'] == a}, "Could not find record for a => #{a}"
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Benchmark before failover: #{benchmark_queries}"
|
#puts "Benchmark before failover: #{benchmark_queries}"
|
||||||
|
|
||||||
@rs.kill_primary
|
@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}"
|
assert results.any? {|r| r['a'] == a}, "Could not find record for a => #{a}"
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Benchmark after failover: #{benchmark_queries}"
|
#puts "Benchmark after failover: #{benchmark_queries}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ class ReadPreferenceTest < Test::Unit::TestCase
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
rescue_connection_failure do
|
rescue_connection_failure do
|
||||||
puts "@coll.find().each"
|
#puts "@coll.find().each"
|
||||||
@coll.find.each {|r| results << r}
|
@coll.find.each {|r| results << r}
|
||||||
[20, 30, 40].each do |a|
|
[20, 30, 40].each do |a|
|
||||||
assert results.any? {|r| r['a'] == a}, "Could not find record for a => #{a}"
|
assert results.any? {|r| r['a'] == a}, "Could not find record for a => #{a}"
|
||||||
|
|
|
@ -10,9 +10,10 @@ class ReplicaSetRefreshTest < Test::Unit::TestCase
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
@rs.restart_killed_nodes
|
@rs.restart_killed_nodes
|
||||||
@conn.close if @conn
|
@conn.close if defined?(@conn)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
=begin
|
||||||
def test_connect_speed
|
def test_connect_speed
|
||||||
Benchmark.bm do |x|
|
Benchmark.bm do |x|
|
||||||
x.report("Connect") do
|
x.report("Connect") do
|
||||||
|
@ -31,6 +32,7 @@ class ReplicaSetRefreshTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
=end
|
||||||
|
|
||||||
def test_connect_and_manual_refresh_with_secondaries_down
|
def test_connect_and_manual_refresh_with_secondaries_down
|
||||||
@rs.kill_all_secondaries
|
@rs.kill_all_secondaries
|
||||||
|
|
Loading…
Reference in New Issue