Skip to content

[9.4](backport #50872) [libbeat/common] Stabilize flaky TestRound assertions#50879

Merged
mauri870 merged 1 commit into
9.4from
mergify/bp/9.4/pr-50872
May 22, 2026
Merged

[9.4](backport #50872) [libbeat/common] Stabilize flaky TestRound assertions#50879
mauri870 merged 1 commit into
9.4from
mergify/bp/9.4/pr-50872

Conversation

@mergify
Copy link
Copy Markdown
Contributor

@mergify mergify Bot commented May 22, 2026

Summary

This updates libbeat/common/math_test.go to make TestRound robust against platform-dependent floating point representation differences.

What changed

  • Converted TestRound into table-driven subtests for clearer case coverage.
  • Replaced exact float equality assertions with assert.InDelta(..., 1e-10, ...).
  • Added assertion messages to make failures more actionable.

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/common

Related: #50869

Note

🔒 Integrity filter blocked 2 items

The following items were blocked because they don't meet the GitHub integrity level.

To allow these resources, lower min-integrity in your GitHub frontmatter:

tools:
  github:
    min-integrity: approved  # merged | approved | unapproved | none

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).

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)
@mergify mergify Bot requested a review from a team as a code owner May 22, 2026 17:52
@mergify mergify Bot added the backport label May 22, 2026
@mergify mergify Bot requested review from belimawr and rdner and removed request for a team May 22, 2026 17:52
@botelastic botelastic Bot added the needs_team Indicates that the issue/PR needs a Team:* label label May 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)
  • /test : Run the Buildkite pipeline.

@github-actions github-actions Bot added Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team skip-changelog ai labels May 22, 2026
@botelastic botelastic Bot removed the needs_team Indicates that the issue/PR needs a Team:* label label May 22, 2026
@infra-vault-gh-plugin-prod
Copy link
Copy Markdown

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@mauri870 mauri870 enabled auto-merge (squash) May 22, 2026 19:26
@mauri870 mauri870 merged commit e98b93d into 9.4 May 22, 2026
205 checks passed
@mauri870 mauri870 deleted the mergify/bp/9.4/pr-50872 branch May 22, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant