Skip to content

Commit

Permalink
Fix sporadic failures testing with JRuby (#1012)
Browse files Browse the repository at this point in the history
* Wait for blockers to proceed

If this spec proceeds to reset the barrier before there are any
waiters, the reset will not trigger them and the spec will fail.
This at least tries to ensure that the waiter is there and will
be interrupted as expected.

* Bump join timeout up for slower system

On slower or heavily-loaded systems, such as CI, this join may
need more than one second. Give it ten before giving up and
raising an error.

* Use repeat_until_success to wait for waiters

This avoids getting stuck and waiting forever if something goes
awry.

* Also skip on JRuby until we can fix sporadic failures
  • Loading branch information
headius authored Nov 8, 2023
1 parent 42d2766 commit dadc2ad
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions spec/concurrent/atomic/cyclic_barrier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ module Concurrent
end

start_latch.wait(1)
repeat_until_success { expect(barrier.number_waiting).to eq 1 }
barrier.reset

expect(barrier).not_to be_broken
Expand Down
2 changes: 1 addition & 1 deletion spec/concurrent/edge/erlang_actor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@
end

specify "timing out" do
skip('flaky on truffleruby') if Concurrent.on_truffleruby?
skip('flaky on truffleruby and jruby') if Concurrent.on_truffleruby? || Concurrent.on_jruby?

count_down = Concurrent::CountDownLatch.new
body = { on_thread: -> { m = receive; count_down.wait; reply m },
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def requires=(paths)
config.after :each do
while defined?(@created_threads) && @created_threads && (thread = (@created_threads.pop(true) rescue nil))
thread.kill
thread_join = thread.join(1.0)
thread_join = thread.join(10.0)
expect(thread_join).not_to be_nil, thread.inspect
end
end
Expand Down

0 comments on commit dadc2ad

Please sign in to comment.