diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-07-03 07:50:00 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-07-10 00:56:26 +0000 |
commit | 2c24cf070dfc9341462fcba59fab4c6b7b330938 (patch) | |
tree | a400fb4e51613138d8eb9b3ee177a151bc842d9d /test/mgmt-iostat.rb | |
parent | b600fc854d2a813dc7cf08eb58590ada90db4c02 (diff) | |
download | cmogstored-2c24cf070dfc9341462fcba59fab4c6b7b330938.tar.gz |
This only triggered if the (undocumented) --worker-processes option is used. This assertion is no longer valid as of commit d5a52618ca1f9b5d7f6998716fbfe7714f927112 (refactor handling of "server aio_threads = " command)
Diffstat (limited to 'test/mgmt-iostat.rb')
-rw-r--r-- | test/mgmt-iostat.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/mgmt-iostat.rb b/test/mgmt-iostat.rb index 905430c..6171ded 100644 --- a/test/mgmt-iostat.rb +++ b/test/mgmt-iostat.rb @@ -3,6 +3,7 @@ # Copyright (C) 2012-2013, Eric Wong <normalperson@yhbt.net> # License: GPLv3 or later (see COPYING for details) require 'test/test_helper' +require 'timeout' class TestMgmtIostat < Test::Unit::TestCase TEST_PATH = File.dirname(__FILE__) + ":#{ENV['PATH']}" @@ -37,6 +38,44 @@ class TestMgmtIostat < Test::Unit::TestCase FileUtils.rm_rf(@tmpdir) end + def __test_iostat_dies(workers = false) + Dir.mkdir "#@tmpdir/dev666" + err = Tempfile.new('err') + @pid = fork do + ENV["PATH"] = TEST_PATH + ENV["MOG_IOSTAT_CMD"] = "#{iostat_mock} #{@iostat_pid.path} slow" + $stderr.reopen(err.path, 'a') + @cmd << workers if workers + exec(*@cmd) + end + iostat_pid = nil + Timeout.timeout(30) do + begin + iostat_pid = @iostat_pid.read.to_i + end while iostat_pid == 0 && sleep(0.05) + Process.kill(:TERM, iostat_pid) + end + + expect = %r{iostat done \(pid=#{iostat_pid}, status=\d} + Timeout.timeout(30) do + loop do + stderr = File.read(err.path) + break if stderr =~ expect + sleep 0.05 + end + end + ensure + err.close! + end + + def test_iostat_dies + __test_iostat_dies + end + + def test_iostat_dies_with_workers + __test_iostat_dies("--worker-processes=1") + end + def test_iostat_fast Dir.mkdir "#@tmpdir/dev666" @pid = fork do |