[9.4](backport #50872) [libbeat/common] Stabilize flaky TestRound assertions#50879
Merged
Conversation
Use table-driven subtests and assert.InDelta in TestRound to avoid exact float equality comparisons on midpoint rounding cases that can vary by tiny representation differences across platforms. Assisted-By: GitHub Copilot CLI Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> (cherry picked from commit 0291d3b)
Contributor
🤖 GitHub commentsJust comment with:
|
|
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
mauri870
approved these changes
May 22, 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.
Summary
This updates
libbeat/common/math_test.goto makeTestRoundrobust against platform-dependent floating point representation differences.What changed
TestRoundinto table-driven subtests for clearer case coverage.assert.InDelta(..., 1e-10, ...).Why
The prior test used exact equality on decimal midpoint inputs (for example
0.50005), which can exhibit tiny representation variance and cause intermittent failures even when rounding behavior is correct.Validation
GOTOOLCHAIN=auto go test -count=5000 ./libbeat/common -run '^TestRound$'GOTOOLCHAIN=auto go test ./libbeat/commonRelated: #50869
Note
🔒 Integrity filter blocked 2 items
The following items were blocked because they don't meet the GitHub integrity level.
issue_read: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".issue_read: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".To allow these resources, lower
min-integrityin your GitHub frontmatter:What is this? | From workflow: Mention in Issue
Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.
This is an automatic backport of pull request #50872 done by [Mergify](https://mergify.com).