mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test_rinda.rb: timeout all thread
* test/rinda/test_rinda.rb (test_do_reply): stop all threads and show backtraces. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9a9f5f0f93
commit
e9bb3b9d30
1 changed files with 22 additions and 5 deletions
|
@ -559,6 +559,15 @@ class TestRingServer < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_do_reply
|
def test_do_reply
|
||||||
|
tl0 = Thread.list
|
||||||
|
tl = nil
|
||||||
|
th = Thread.new(Thread.current) do |mth|
|
||||||
|
sleep 1
|
||||||
|
(tl = Thread.list - tl0).each {|t|t.raise(Timeout::Error)}
|
||||||
|
mth.raise(Timeout::Error)
|
||||||
|
end
|
||||||
|
tl0 << th
|
||||||
|
|
||||||
called = nil
|
called = nil
|
||||||
|
|
||||||
callback = proc { |ts|
|
callback = proc { |ts|
|
||||||
|
@ -567,11 +576,6 @@ class TestRingServer < Test::Unit::TestCase
|
||||||
|
|
||||||
callback = DRb::DRbObject.new callback
|
callback = DRb::DRbObject.new callback
|
||||||
|
|
||||||
th = Thread.new(Thread.current) do |mth|
|
|
||||||
sleep 15
|
|
||||||
mth.raise unless called
|
|
||||||
end
|
|
||||||
|
|
||||||
@ts.write [:lookup_ring, callback]
|
@ts.write [:lookup_ring, callback]
|
||||||
|
|
||||||
@rs.do_reply
|
@rs.do_reply
|
||||||
|
@ -585,6 +589,19 @@ class TestRingServer < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_same @ts, called
|
assert_same @ts, called
|
||||||
|
rescue Timeout::Error => e
|
||||||
|
if tl
|
||||||
|
bt = e.backtrace
|
||||||
|
tl.each do |t|
|
||||||
|
begin
|
||||||
|
t.value
|
||||||
|
rescue Timeout::Error => e
|
||||||
|
bt.unshift("")
|
||||||
|
bt[0, 0] = e.backtrace
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
raise Timeout::Error, "timeout", bt
|
||||||
ensure
|
ensure
|
||||||
th.kill if th
|
th.kill if th
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue