From a2467b46c719f2b51647881438be35abff54b349 Mon Sep 17 00:00:00 2001 From: Dmitry Pashkevich Date: Sat, 15 Aug 2026 16:16:45 +0000 Subject: [PATCH] ruby: Rejoin queue without worker history --- ruby/README.md | 2 +- ruby/lib/ci/queue/redis/worker.rb | 2 -- ruby/test/ci/queue/redis_test.rb | 8 +++----- ruby/test/integration/minitest_redis_test.rb | 7 ++++--- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/ruby/README.md b/ruby/README.md index 02e2107..6f8f649 100644 --- a/ruby/README.md +++ b/ruby/README.md @@ -46,7 +46,7 @@ minitest-queue --queue redis://example.com \ run -Itest test/**/*_test.rb ``` -Worker-history retries require the retry to retain its worker ID and queue build ID. Missing reservation history or suite chunk metadata fails the retry. The replay uses a local retry queue and does not rejoin the shared queue, so surviving workers must drain any remaining work. When centralized reporting is used, restarting every worker before the shared queue is exhausted fails the build rather than accepting an incomplete run. +Worker-history retries require the retry to retain its worker ID and queue build ID. A worker retried before reserving tests rejoins the shared queue, while missing suite chunk metadata fails the retry. Replaying existing history uses a local retry queue and does not rejoin the shared queue, so surviving workers must drain any remaining work. When centralized reporting is used, restarting every worker before the shared queue is exhausted fails the build rather than accepting an incomplete run. If you'd like to centralize the error reporting you can do so with: diff --git a/ruby/lib/ci/queue/redis/worker.rb b/ruby/lib/ci/queue/redis/worker.rb index fd53176..7338a45 100644 --- a/ruby/lib/ci/queue/redis/worker.rb +++ b/ruby/lib/ci/queue/redis/worker.rb @@ -541,8 +541,6 @@ def failed_test_ids(reservations) end def worker_history_test_ids(reservations) - raise WorkerHistoryError, "Reservation history is missing for worker #{worker_id}" if reservations.empty? - reservations.reverse.flat_map { |id| expand_reservation(id) }.uniq end diff --git a/ruby/test/ci/queue/redis_test.rb b/ruby/test/ci/queue/redis_test.rb index a99e8c8..d50ec39 100644 --- a/ruby/test/ci/queue/redis_test.rb +++ b/ruby/test/ci/queue/redis_test.rb @@ -71,12 +71,10 @@ def test_retry_queue_with_worker_history assert_equal original_order, poll(retry_queue) end - def test_worker_history_retry_requires_reservations - error = assert_raises(CI::Queue::Redis::WorkerHistoryError) do - @queue.retry_queue(selection: :worker_history) - end + def test_worker_history_retry_without_reservations_is_empty + retry_queue = @queue.retry_queue(selection: :worker_history) - assert_equal 'Reservation history is missing for worker 1', error.message + assert_predicate retry_queue, :exhausted? end def test_worker_history_retry_requires_complete_replay diff --git a/ruby/test/integration/minitest_redis_test.rb b/ruby/test/integration/minitest_redis_test.rb index 8f0eb3d..d03803b 100644 --- a/ruby/test/integration/minitest_redis_test.rb +++ b/ruby/test/integration/minitest_redis_test.rb @@ -232,13 +232,14 @@ def test_worker_history_retry_replays_all_reserved_tests assert_equal 'Ran 100 tests, 100 assertions, 0 failures, 0 errors, 0 skips, 0 requeues in X.XXs', output end - def test_worker_history_retry_fails_without_worker_reservations + def test_worker_history_retry_rejoins_queue_without_worker_reservations run_worker_history_worker(retry_count: 0, build_id: 'missing-history', worker_id: '1') out, = run_worker_history_worker(retry_count: 1, build_id: 'missing-history', worker_id: '2') - refute_predicate $?, :success? - assert_includes out, 'Reservation history is missing for worker 2' + assert_predicate $?, :success? + assert_includes out, "The retry queue does not contain any failure, we'll process the main queue instead." + assert_includes out, 'All tests were ran already' end def test_worker_history_retry_fails_when_replay_stops_early