about summary refs log tree commit homepage
path: root/test/test_mogilefs_integration.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-11-08 02:45:40 +0000
committerEric Wong <normalperson@yhbt.net>2011-11-08 02:45:40 +0000
commit1a5b3487e5a38a4897a6461b3907cd6bde501e0c (patch)
treeed354bc6398343262ea104b1d2f718dd080e5a37 /test/test_mogilefs_integration.rb
parentfd5098ba0825d5ee603265a40e8c62b97191b7b6 (diff)
downloadmogilefs-client-1a5b3487e5a38a4897a6461b3907cd6bde501e0c.tar.gz
This was added in MogileFS 2.45
Diffstat (limited to 'test/test_mogilefs_integration.rb')
-rw-r--r--test/test_mogilefs_integration.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/test_mogilefs_integration.rb b/test/test_mogilefs_integration.rb
index cf8d178..f5915bd 100644
--- a/test/test_mogilefs_integration.rb
+++ b/test/test_mogilefs_integration.rb
@@ -79,4 +79,44 @@ class TestMogileFSIntegration < TestMogIntegration
     devids.each { |devid| assert_kind_of Integer, devid }
     assert_equal res["devcount"], devids.size
   end
+
+  def test_file_debug
+    assert_equal 3, @client.store_content("file_debug", "default", "BUG")
+    a = @client.file_debug("file_debug")
+    b = @client.file_debug(:key => "file_debug")
+    fid = @client.file_info("file_debug")["fid"]
+    c = @client.file_debug(fid)
+    d = @client.file_debug(:fid => fid)
+
+    [ a, b, c, d ].each do |res|
+      assert_equal fid, res["fid_fid"]
+      assert_equal 0, res["fid_classid"]
+      assert_equal "file_debug", res["fid_dkey"]
+      assert_equal 3, res["fid_length"]
+      assert_kind_of Array, res["devids"]
+      assert_kind_of Integer, res["devids"][0]
+      res["devids"].each do |devid|
+        uri = URI.parse(res["devpath_#{devid}"])
+        assert_equal "http", uri.scheme
+      end
+      assert_equal "default", res["fid_class"]
+    end
+    @client.delete("file_debug")
+    rv = @client.file_debug(fid)
+    assert rv.keys.grep(/\Afid_/).empty?, rv.inspect
+  end
+
+  def test_file_debug_in_progress
+    rv = @client.new_file("file_debug_in_progress") do |http_file|
+      http_file << "ZZZZ"
+      dests = http_file.instance_variable_get(:@dests)
+      dests[0][1] =~ %r{/(\d+)\.fid\z}
+      fid = $1.to_i
+      rv = @client.file_debug(fid)
+      devids = dests.map { |x| x[0].to_i }.sort
+      assert_equal devids, rv["tempfile_devids"].sort
+      assert_equal "file_debug_in_progress", rv["tempfile_dkey"]
+    end
+    assert_equal 4, rv
+  end
 end