[fix][test] Fix flaky ModularLoadManagerImplTest and IsolatedBookieEnsemblePlacementPolicyTest#25496
Merged
merlimat merged 3 commits intoapache:masterfrom Apr 8, 2026
Conversation
…semblePlacementPolicyTest - ModularLoadManagerImplTest.testRemoveNonExistBundleData: Replace exact bundle count assertion with upper-bound check since not all bundles may have data written in the metadata store at the time of the check. - IsolatedBookieEnsemblePlacementPolicyTest.testSecondaryIsolationGroupsBookies: Use consistent rack assignments across bookie groups to avoid non-deterministic rack resolution when the same bookie appears in multiple groups with different rack values. HashMap iteration order determined which rack assignment won, causing flaky failures in the rack-aware ensemble placement.
…ause The previous fix weakened assertEquals(bundleNumbers, bundles.size()) to assertTrue(bundles.size() <= bundleNumbers), which hides the real problem and changes the test's original intention. Root cause: writeResourceQuotasToZooKeeper() calls updateBundleData() which reads from loadData.getBrokerData(). If the ZK notification from lm2's writeBrokerDataOnZooKeeper hasn't been processed yet by lm1's executor, lm1's loadData only contains bundles from one broker, so fewer than 8 bundles get written to the metadata store. Fix: call lm1.updateAll() before writeResourceQuotasToZooKeeper() to ensure lm1 has fetched both brokers' data from the metadata store. This preserves the original strict assertion that all 8 bundles are present.
merlimat
approved these changes
Apr 8, 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.
Motivation
Fix two flaky tests that fail intermittently on master.
ModularLoadManagerImplTest.testRemoveNonExistBundleData: The test creates a namespace with 8 bundles and asserts that all 8 bundles have data in the metadata store after
writeResourceQuotasToZooKeeper(). The flakiness occurs becausewriteResourceQuotasToZooKeeper()internally callsupdateBundleData()which reads bundle stats fromloadData.getBrokerData(). If the ZooKeeper notification from the second broker'swriteBrokerDataOnZooKeeper()hasn't been processed yet,loadDataonly contains bundles from one broker, so fewer than 8 bundles get written. The fix ensureslm1.updateAll()is called before writing bundle data so that lm1 has fetched both brokers' data from the metadata store.IsolatedBookieEnsemblePlacementPolicyTest.testSecondaryIsolationGroupsBookies: Bookies were configured with conflicting rack assignments across groups (e.g., BOOKIE1 was rack0 in default but rack1 in primaryGroup). Since
BookieRackAffinityMappingprocesses groups via HashMap iteration (non-deterministic order), the final rack for each bookie varied between runs, causing rack diversity constraint failures.Modifications
lm1.updateAll()beforewriteResourceQuotasToZooKeeper()to ensure lm1 has loaded both brokers' data from the metadata store. This fixes the root cause (missing broker data in loadData) and preserves the original strictassertEquals(bundleNumbers, bundles.size())assertion that verifies all bundles are present.Verifying this change
This change is already covered by existing tests, such as
ModularLoadManagerImplTest.testRemoveNonExistBundleDataandIsolatedBookieEnsemblePlacementPolicyTest.testSecondaryIsolationGroupsBookies.Does this pull request potentially affect one of the following parts: