Stamp per-worker-process execution metadata on test results - #420
Open
bitwise-aiden wants to merge 2 commits into
Open
Stamp per-worker-process execution metadata on test results#420bitwise-aiden wants to merge 2 commits into
bitwise-aiden wants to merge 2 commits into
Conversation
Adds three fields to each recorded result, stamped in the process that ran the test (worker-side, before any DRb send in embedding environments): - parallel_worker_pid: Process.pid at result creation - parallel_worker_test_index: 0-based per-process monotonic counter, incremented per execution (requeued runs get their own index), fork-safe - parallel_worker_id: injected by the embedding environment via Minitest::Queue.parallel_worker_id= or CI_QUEUE_PARALLEL_WORKER_ID; nil when not applicable Stamping is first-writer-wins: embedders that run tests in forked workers and transport results to a central reporting process (e.g. Rails parallel testing over DRb, where handle_test_result runs server-side) must call Minitest::Queue.stamp_parallel_worker_metadata in the worker before sending; pre-stamped results pass through reporting untouched. Otherwise the reporting-side stamp would carry the server's pid and an arrival-order index interleaved across workers. The fields are carried nil-safely through TestData#to_h into log/test_data.json (TestDataReporter unchanged), so per-worker-process execution order is reconstructable downstream: PARTITION BY parallel_worker_id, parallel_worker_pid ORDER BY parallel_worker_test_index Assisted-By: devx/77f6d45d-84ba-4c9e-983d-5ec948229a08
Assisted-By: devx/77f6d45d-84ba-4c9e-983d-5ec948229a08
FletcherDares
approved these changes
Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Stamps three per-worker-process execution metadata fields on every minitest result, carried nil-safely through
TestData#to_hintolog/test_data.json:parallel_worker_pid—Process.pidat result creation.parallel_worker_test_index— 0-based per-process monotonic counter, incremented per execution (requeued runs get their own index). Fork-safe: restarts when the pid changes, so each process incarnation gets a clean0,1,2,…sequence.parallel_worker_id— identifier injected by the embedding environment (e.g. a Rails parallel-testing worker number) viaMinitest::Queue.parallel_worker_id=orCI_QUEUE_PARALLEL_WORKER_ID;nilwhen not applicable.This makes per-worker-process execution order reconstructable downstream:
PARTITION BY job_id, parallel_worker_id, parallel_worker_pid ORDER BY parallel_worker_test_indexi.e. a SQL query can reproduce any worker's
test_order-w{N}-{pid}.logfrom warehouse rows — the prerequisite for warehouse-native test-pollution / requeue-overlap analysis.How
Minitest::ParallelWorkerMetadataaccessors module prepended toMinitest::Result(fields ride the result object through Marshal/DRb).Minitest::Queue.handle_test_result— in the process that ran the test for all in-process flows.handle_test_resultruns server-side) must callMinitest::Queue.stamp_parallel_worker_metadata(result)in the worker before sending. Pre-stamped results pass through reporting untouched — otherwise the reporting-side stamp would carry the server's pid and an arrival-order index interleaved across workers.Impact on existing consumers
TestDataReporteris structurally unchanged.test_order.log, and Redis build-status/error reports are untouched.Testing
TestDataunit tests for stamped/unstamped/accessor-less results.test_test_data_reporter: worker id from env, single pid, indexes exactly0..N-1, requeued execution ordered before its final run.Also bumps the version to 0.98.0 for release.