about summary refs log tree commit homepage
path: root/test/test_fresh.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-02-05 21:57:59 +0000
committerEric Wong <normalperson@yhbt.net>2013-02-05 22:16:01 +0000
commit3c73f6b434a4c226c09e31c6ba3b034cb314b3fb (patch)
tree131e6d934cc2b8fa9da5949c23eb9a4dba07d8b7 /test/test_fresh.rb
parent3dd52026434fe89a1ef5110fc5fe568cdd4df819 (diff)
downloadmogilefs-client-3c73f6b434a4c226c09e31c6ba3b034cb314b3fb.tar.gz
In single tracker configurations, a restarted tracker may cause
send()/write() failure on the TCP socket.  Retry immediately in
this case, since there's no danger even for non-idempotent
tracker requests.
Diffstat (limited to 'test/test_fresh.rb')
-rw-r--r--test/test_fresh.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/test_fresh.rb b/test/test_fresh.rb
index 706783e..5f420de 100644
--- a/test/test_fresh.rb
+++ b/test/test_fresh.rb
@@ -165,4 +165,36 @@ class TestMogFresh < Test::Unit::TestCase
       end
     end
   end if IO.respond_to?(:copy_stream)
+
+  def test_single_tracker_restart
+    add_host_device_domain
+    client = MogileFS::MogileFS.new :hosts => @hosts, :domain => @domain
+
+    data = "data"
+    client.store_content("key", "default", data)
+    listing = client.list_keys
+    assert_instance_of Array, listing
+
+    # restart the tracker
+    s = TCPSocket.new(@test_host, @tracker_port)
+    s.write "!shutdown\r\n"
+    s.flush # just in case, MRI (at least) syncs by default
+    assert_nil s.gets
+
+    start_tracker
+
+    # transparent retry
+    listing2 = client.list_keys
+    assert_instance_of Array, listing2
+    assert_equal listing, listing2
+    assert_equal([['key'], 'key'], listing)
+
+    # kill the tracker
+    s = TCPSocket.new(@test_host, @tracker_port)
+    s.write "!shutdown\r\n"
+    s.flush # just in case, MRI (at least) syncs by default
+    assert_nil s.gets
+    @mogilefsd_pid = nil
+    assert_raises(MogileFS::UnreachableBackendError) { client.list_keys }
+  end
 end