test: add retry logic for eventloopdelay histogram sampling #61796
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.
Summary
Fixes flaky
test-performance-eventloopdelaytest on sharedlibs builds.Problem
On some build configurations (e.g., Ubuntu 24.04 sharedlibs), the histogram may not record valid samples (
min > 0) after the initial spinning period. The test fails with:The previous fix (PR #61629) added
setImmediateto allow samples to be recorded, but this wasn't sufficient for all configurations.Solution
Add a retry mechanism that checks if valid samples have been recorded (
count > 0 && min > 0 && max > 0). If not, the test will spin the event loop additional times (up to 3 retries) before asserting.This ensures the test passes on slower or differently-configured systems where event loop delay sampling may take longer to produce measurable results.
Verification
Tested locally with
python3 tools/test.py --repeat 30- all passed.Refs: nodejs/reliability#1461