1 # -*- encoding: binary -*-
5 class TestMogileFSLargePipe < Test::Unit::TestCase
10 @client = MogileFS::MogileFS.new(:hosts => @trackers, :domain => @domain)
13 alias teardown teardown_mogilefs
15 def test_large_pipe_test
16 junk = File.open("/dev/urandom") { |fp| fp.read(1024) }
20 sha1 = Digest::SHA1.new
28 assert_equal(nr * junk.size, @client.store_file("a", nil, r))
31 @client.get_file_data("a") do |rd|
32 assert_equal(nr * junk.size, @client.store_file("b", nil, rd))
34 a = Thread.new { @client.get_file_data("a") { |rd| sha1read(rd) } }
35 b = Thread.new { @client.get_file_data("b") { |rd| sha1read(rd) } }
41 # We should be able to open FIFOs
45 x!("mkfifo", tmp_path)
47 File.open(tmp_path, "wb") do |wr|
48 nr.times { wr.write(junk) }
51 assert_equal(nr * junk.size, @client.store_file("fifo", nil, tmp_path))
52 _, status = Process.waitpid2(pid)
53 assert status.success?, status.inspect
54 fifo_sha1 = @client.get_file_data("fifo") { |rd| sha1read(rd) }
55 assert_equal sha1, fifo_sha1
61 while rd.read(16384, buf)