From dadc2ad81f8c57a03400585187c3405c96713198 Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Tue, 7 Nov 2023 20:59:35 -0600 Subject: [PATCH] Fix sporadic failures testing with JRuby (#1012) * 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 --- spec/concurrent/atomic/cyclic_barrier_spec.rb | 1 + spec/concurrent/edge/erlang_actor_spec.rb | 2 +- spec/spec_helper.rb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/concurrent/atomic/cyclic_barrier_spec.rb b/spec/concurrent/atomic/cyclic_barrier_spec.rb index 3a2bb2426..8ed899d67 100644 --- a/spec/concurrent/atomic/cyclic_barrier_spec.rb +++ b/spec/concurrent/atomic/cyclic_barrier_spec.rb @@ -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 diff --git a/spec/concurrent/edge/erlang_actor_spec.rb b/spec/concurrent/edge/erlang_actor_spec.rb index ed94607dc..5ab7c4e48 100644 --- a/spec/concurrent/edge/erlang_actor_spec.rb +++ b/spec/concurrent/edge/erlang_actor_spec.rb @@ -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 }, diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2a8fbc54a..d191183f6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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