Skip to content

Comments

[fix][test] Add Delta Tolerance in Double-Precision Assertions to Fix Rounding Flakiness#11

Open
LucasEby wants to merge 1 commit intomasterfrom
fix-TransferShredderTest
Open

[fix][test] Add Delta Tolerance in Double-Precision Assertions to Fix Rounding Flakiness#11
LucasEby wants to merge 1 commit intomasterfrom
fix-TransferShredderTest

Conversation

@LucasEby
Copy link
Owner

@LucasEby LucasEby commented Nov 10, 2025

Fixes apache#24970

Motivation

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:

@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@LucasEby LucasEby force-pushed the fix-TransferShredderTest branch from aa477f6 to 6b5770f Compare November 10, 2025 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants