Skip to content

[fix][test] Fix flaky IsolatedBookieEnsemblePlacementPolicyTest.testMetadataStoreCases#25474

Merged
nodece merged 1 commit intoapache:masterfrom
merlimat:fix/flaky-testMetadataStoreCases
Apr 7, 2026
Merged

[fix][test] Fix flaky IsolatedBookieEnsemblePlacementPolicyTest.testMetadataStoreCases#25474
nodece merged 1 commit intoapache:masterfrom
merlimat:fix/flaky-testMetadataStoreCases

Conversation

@merlimat
Copy link
Copy Markdown
Contributor

@merlimat merlimat commented Apr 5, 2026

Motivation

IsolatedBookieEnsemblePlacementPolicyTest.testMetadataStoreCases is flaky because it uses Thread.sleep-based timing to control when CompletableFutures complete. On fast machines, the background thread can complete earlier than expected, causing getExcludedBookiesWithIsolationGroups to see the updated cache value before the test expects it.

Stack trace

IsolatedBookieEnsemblePlacementPolicyTest > testMetadataStoreCases FAILED
    java.lang.AssertionError: expected [true] but found [false]
        at org.testng.Assert.fail(Assert.java:110)
        at org.testng.Assert.failNotEquals(Assert.java:1577)
        at org.testng.Assert.assertTrue(Assert.java:56)
        at org.testng.Assert.assertTrue(Assert.java:66)
        at IsolatedBookieEnsemblePlacementPolicyTest.testMetadataStoreCases(IsolatedBookieEnsemblePlacementPolicyTest.java:212)

Modifications

Replace the Thread.sleep-based timing with manually-controlled CompletableFuture completion at the exact test points where the futures should transition from pending to complete. This eliminates the timing race entirely.

Documentation

  • doc-not-needed

…p timing with manual future completion

The test used Thread.sleep-based timing to control when CompletableFutures
complete, but on fast machines the thread can complete earlier than expected,
causing the test to see unexpected cache values. Replace with manually-
controlled future completion at the exact points needed.
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Apr 5, 2026
@nodece nodece merged commit 3982de0 into apache:master Apr 7, 2026
81 of 85 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/test doc-not-needed Your PR changes do not impact docs ready-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants