test: stabilize QueryVirtualStorageTest metric assertions - #19886
Open
FrankChen021 wants to merge 3 commits into
Open
test: stabilize QueryVirtualStorageTest metric assertions#19886FrankChen021 wants to merge 3 commits into
FrankChen021 wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR stabilizes QueryVirtualStorageTest.testQueryPartials by replacing race-prone “wait for one next event” latches with aggregate-based waits when asserting cumulative virtual storage metrics, aligning the waiting strategy with how StorageMonitor emits and resets interval stats.
Changes:
- Replaced
LatchableEmitter.waitForNextEventwaits withLatchableEmitter.waitForEventAggregatefor cumulative metric thresholds (e.g., load begin count, hit count). - Added aggregate waits for several additional VSF metrics before reading cumulative sums to reduce timing-related flakes.
Suppressed comments (1)
embedded-tests/src/test/java/org/apache/druid/testing/embedded/query/QueryVirtualStorageTest.java:276
- Similar to the read metrics,
StorageMonitoremitsVSF_EVICT_COUNTandVSF_EVICT_BYTESas separate events. Waiting only forVSF_EVICT_COUNTcan release before the bytes event is processed, making the immediateVSF_EVICT_BYTES > 0assertion flaky. Add an aggregate wait forVSF_EVICT_BYTESbefore asserting.
event -> event.hasMetricName(StorageMonitor.VSF_EVICT_COUNT),
aggregate -> aggregate.hasSumAtLeast(1)
);
Assertions.assertTrue(emitter.getMetricEventLongSum(StorageMonitor.VSF_EVICT_COUNT) > 0);
Assertions.assertTrue(emitter.getMetricEventLongSum(StorageMonitor.VSF_EVICT_BYTES) > 0);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
GWphua
approved these changes
Aug 5, 2026
FrankChen021
commented
Aug 5, 2026
FrankChen021
left a comment
Member
Author
There was a problem hiding this comment.
| Severity | Findings |
|---|---|
| P0 | 0 |
| P1 | 0 |
| P2 | 1 |
| P3 | 0 |
| Total | 1 |
| Severity | Findings |
|---|---|
| P0 | 0 |
| P1 | 0 |
| P2 | 1 |
| P3 | 0 |
| Total | 1 |
Reviewed 1 of 1 changed files.
This is an automated review by Codex GPT-5.6-Sol
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.
Summary
QueryVirtualStorageTest.testQueryPartials.waitForNextEventcalls withLatchableEmitter.waitForEventAggregatewaits where the test reads cumulative metric totals.Root cause
StorageMonitoremits virtual storage metrics on periodic monitor ticks and resets the interval statistics after each tick. The test previously waited for only one future matching event withwaitForNextEvent, then read a cumulative total. If that event represented an interval before the final segment load completed, the test could observe 23 loads even though a later metric event would bring the cumulative total to the required 24.waitForEventAggregateevaluates already-processed matching events and continues collecting future matching events until the requested cumulative threshold is reached. The fix therefore removes the timing race while retaining the expected thresholds.Evidence
QueryVirtualStorageTest.testQueryPartialsfailed at the first load assertion withexpected 24 but only got 23.This is a test-stability fix found while validating the JUnit 5 migration. It does not migrate JUnit, change production behavior, or change the expected metric thresholds. Related to #13948.
Validation
mvn -ntp test -pl embedded-tests -am -Dtest="org.apache.druid.testing.embedded.query.QueryVirtualStorageTest#testQueryPartials" -Dsurefire.failIfNoSpecifiedTests=false -Pskip-static-checks -Dweb.console.skip=true -T1C— 1 test, 0 failures, 0 errors, 0 skipped; full reactorBUILD SUCCESS.mvn -ntp -pl embedded-tests -am -DskipTests -Dweb.console.skip=true -Dcheckstyle.skip=false -Dspotbugs.skip=false checkstyle:check spotbugs:check -T1C—BUILD SUCCESS; Checkstyle reported 0 violations and SpotBugs reported no bugs/errors.git diff --check— passed.