about summary refs log tree commit homepage
path: root/test/test_fresh.rb
diff options
context:
space:
mode:
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