test/internals_test.rb in redis-2.2.2 vs test/internals_test.rb in redis-3.0.0.rc1

- old
+ new

@@ -33,24 +33,15 @@ assert_nothing_raised do Redis.new(OPTIONS.merge(:timeout => 0)) end end -# Don't use assert_raise because Timeour::Error in 1.8 inherits -# Exception instead of StandardError (on 1.9). test "Connection timeout" do - # EM immediately raises CONNREFUSED next if driver == :synchrony - result = false - - begin + assert_raise Redis::CannotConnectError do Redis.new(OPTIONS.merge(:host => "10.255.255.254", :timeout => 0.1)).ping - rescue Timeout::Error - result = true - ensure - assert result end end test "Retry when first read raises ECONNRESET" do $request = 0 @@ -78,11 +69,11 @@ end end redis_mock(:ping => command) do redis = Redis.connect(:port => 6380, :timeout => 0.1) - assert_raise Errno::ECONNRESET do + assert_raise Redis::ConnectionError do redis.without_reconnect do redis.ping end end @@ -101,11 +92,11 @@ end end redis_mock(:ping => command) do redis = Redis.connect(:port => 6380, :timeout => 0.1) - assert_raise Errno::ECONNRESET do + assert_raise Redis::ConnectionError do redis.ping end assert !redis.client.connected? end @@ -121,11 +112,11 @@ end end redis_mock(:ping => command) do redis = Redis.connect(:port => 6380, :timeout => 0.1) - assert_raise Errno::ECONNRESET do + assert_raise Redis::ConnectionError do redis.pipelined do redis.ping redis.ping # Second #read times out end end @@ -136,25 +127,26 @@ assert_nothing_raised do Redis.new(OPTIONS.merge(:path => "/tmp/redis.sock")).ping end end -# Using a mock server in a thread doesn't work here (possibly because blocking -# socket ops, raw socket timeouts and Ruby's thread scheduling don't mix). -test "Bubble EAGAIN without retrying" do - cmd = %{(sleep 0.3; echo "+PONG\r\n") | nc -l 6380} - IO.popen(cmd) do |_| - sleep 0.1 # Give nc a little time to start listening - redis = Redis.connect(:port => 6380, :timeout => 0.1) - - begin - assert_raise(Errno::EAGAIN) { redis.ping } - ensure - # Explicitly close connection so nc can quit - redis.client.disconnect - - # Make the reactor loop do a tick to really close - EM::Synchrony.sleep(0) if driver == :synchrony - end - end -end - +# if driver == :ruby || driver == :hiredis +# # Using a mock server in a thread doesn't work here (possibly because blocking +# # socket ops, raw socket timeouts and Ruby's thread scheduling don't mix). +# test "Bubble EAGAIN without retrying" do +# cmd = %{(sleep 0.3; echo "+PONG\r\n") | nc -l 6380} +# IO.popen(cmd) do |_| +# sleep 0.1 # Give nc a little time to start listening +# redis = Redis.connect(:port => 6380, :timeout => 0.1) +# +# begin +# assert_raise(Errno::EAGAIN) { redis.ping } +# ensure +# # Explicitly close connection so nc can quit +# redis.client.disconnect +# +# # Make the reactor loop do a tick to really close +# EM::Synchrony.sleep(0) if driver == :synchrony +# end +# end +# end +# end