Skip to content

Conversation

@LucasEby
Copy link
Contributor

@LucasEby LucasEby commented Nov 11, 2025

Fixes #24970

Motivation

The PR on my fork was already approved: LucasEby#11

Several tests in this suite compare double values directly using equality assertions. These assertions occasionally fail due to minor inaccuracies introduced by floating-point rounding and double-precision limitations in Java’s IEEE 754 representation. Such discrepancies are expected when performing arithmetic operations on floating-point numbers and can lead to flaky test behavior.

Modifications

A small tolerance (delta) of 1e-5 was added to each double comparison. This delta is at least two orders of magnitude smaller than the smallest compared values, ensuring that it does not affect the logical correctness of the tests. The same delta is already used consistently in another method within the same test class. The tests remain the same, we are just being more careful about double precision issues when comparing values to avoid preventable flaky failures.

Verifying this change

  • Make sure that the change passes the CI checks.

This change is already covered by existing tests, such as

  • org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedderTest#testNoOwnerLoadData
  • org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedderTest#testEmptyTopBundlesLoadData
  • org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedderTest#testRecentlyUnloadedBrokers
  • org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedderTest#testRecentlyUnloadedBundles
  • org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedderTest#testSheddingExcludedNamespaces
  • org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedderTest#testBundlesWithIsolationPolicies
  • org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedderTest#testBundlesWithAntiAffinityGroup
  • org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedderTest#testTargetStd
  • org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedderTest#testSingleTopBundlesLoadData
  • org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedderTest#testBundleThroughputLargerThanOffloadThreshold
  • org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedderTest#testZeroBundleThroughput
  • org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedderTest#testTargetStdAfterTransfer
  • org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedderTest#testMinBrokerWithLowTraffic
  • org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedderTest#testMinBrokerWithLowerLoadThanAvg
  • org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedderTest#testMaxNumberOfTransfersPerShedderCycle
  • org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedderTest#testLoadBalancerSheddingConditionHitCountThreshold
  • org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedderTest#testRemainingTopBundles
  • org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedderTest#testLoadMoreThan100
  • org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedderTest#testHighVarianceLoadStats
  • org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedderTest#testLowVarianceLoadStats

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: LucasEby#11

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Nov 11, 2025
Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.33%. Comparing base (c4f125c) to head (6b5770f).
⚠️ Report is 15 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##             master   #24972       +/-   ##
=============================================
+ Coverage     38.77%   74.33%   +35.55%     
- Complexity    13380    34041    +20661     
=============================================
  Files          1856     1920       +64     
  Lines        145342   150138     +4796     
  Branches      16886    17414      +528     
=============================================
+ Hits          56353   111601    +55248     
+ Misses        81459    29652    -51807     
- Partials       7530     8885     +1355     
Flag Coverage Δ
inttests 26.16% <ø> (-0.25%) ⬇️
systests 22.86% <ø> (+0.01%) ⬆️
unittests 73.86% <ø> (+38.86%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 1421 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lhotari lhotari added this to the 4.2.0 milestone Nov 11, 2025
@lhotari lhotari merged commit bd9d81d into apache:master Nov 11, 2025
117 of 123 checks passed
lhotari pushed a commit that referenced this pull request Nov 11, 2025
lhotari pushed a commit that referenced this pull request Nov 11, 2025
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Nov 13, 2025
… Rounding Flakiness (apache#24972)

(cherry picked from commit bd9d81d)
(cherry picked from commit fa8bbf4)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Nov 14, 2025
… Rounding Flakiness (apache#24972)

(cherry picked from commit bd9d81d)
(cherry picked from commit fa8bbf4)
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.

Flaky-test: TransferShedderTest has Multiple Methods Failing due to Double Rounding

3 participants