diff options
Diffstat (limited to 'test/test_mogilefs.rb')
-rw-r--r-- | test/test_mogilefs.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/test_mogilefs.rb b/test/test_mogilefs.rb index 7e8e3a2..249c2d6 100644 --- a/test/test_mogilefs.rb +++ b/test/test_mogilefs.rb @@ -605,6 +605,36 @@ class TestMogileFS__MogileFS < TestMogileFS assert_equal received[0], received[1] end + def test_idempotent_command_slow + ip = "127.0.0.1" + a = TCPServer.new(ip, 0) + hosts = [ "#{ip}:#{a.addr[1]}" ] + timeout = 1 + args = { :hosts => hosts, :domain => "foo", :timeout => timeout } + c = MogileFS::MogileFS.new(args) + received = [] + secs = timeout + 1 + th = Thread.new do + loop { + x = a.accept + 2.times do |i| + line = x.gets + %r{key=(\w+)} =~ line + sleep secs + secs = 0 + x.write("OK paths=1&path1=http://0/#{$1}\r\n") + end + x.close + } + end + expect1 = %w(http://0/a) + assert_equal expect1, c.get_paths("a") + expect2 = %w(http://0/b) + assert_equal expect2, c.get_paths("b") + a.close + th.kill + end + def test_idempotent_command_response_truncated ip = "127.0.0.1" a, b = TCPServer.new(ip, 0), TCPServer.new(ip, 0) |