Skip to content

Commit a105ff6

Browse files
committed
simplify flaky test
1 parent 67363c6 commit a105ff6

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

test/test_connection_pool.rb

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -159,36 +159,19 @@ def pool.checkout(options)
159159
super
160160
end
161161

162-
did_something = false
163-
164162
action = lambda do
165-
Timeout.timeout(0.02) do
163+
Timeout.timeout(0.01) do
166164
pool.with do |obj|
167-
did_something = true
168165
# Timeout::Error will be triggered by any non-trivial Ruby code
169166
# executed here since it couldn't be raised during checkout.
170-
# It looks like setting the local variable above does not trigger
167+
# It looks like setting a local variable does not trigger
171168
# the Timeout check in MRI 2.2.1.
172169
obj.tap { obj.hash }
173170
end
174171
end
175172
end
176173

177-
if RUBY_ENGINE == "ruby"
178-
# These asserts rely on the Ruby implementation reaching `did_something =
179-
# true` before the interrupt is detected by the thread. Interrupt
180-
# detection timing is implementation-specific in practice, with JRuby,
181-
# Rubinius, and TruffleRuby all having different interrupt timings to MRI.
182-
# In fact they generally detect interrupts more quickly than MRI, so they
183-
# may not reach `did_something = true` before detecting the interrupt.
184-
185-
assert_raises Timeout::Error, &action
186-
187-
assert did_something
188-
else
189-
action.call
190-
end
191-
174+
assert_raises Timeout::Error, &action
192175
assert_equal 1, pool.available
193176
end
194177

0 commit comments

Comments
 (0)