Test: Fix DtoQueryPlanCaptureTest by draining plans

This commit is contained in:
robin.bygrave
2026-06-11 20:28:10 +12:00
parent 4fab5dfe4b
commit 3ea9a5fa7f
@@ -72,10 +72,22 @@ class DtoQueryPlanCaptureTest extends BaseTestCase {
.findList();
}
private void drainCapturedPlans() {
QueryPlanRequest drain = new QueryPlanRequest();
drain.maxCount(100_000);
drain.maxTimeMillis(30_000);
DB.getDefault().metaInfo().queryPlanCollectNow(drain);
}
@Test
void nativeDtoQuery_capturesQueryPlan() {
ResetBasicData.reset();
// drain any query plans captured by earlier tests in the suite, otherwise the
// shared (process-global) capture map can exhaust the collect budget below before
// our plan is reached (order dependent, and slow to capture on Oracle).
drainCapturedPlans();
// build the plans first (default threshold -> no capture yet)
assertThat(runNative()).isNotEmpty();
runOrmBacked();
@@ -118,6 +130,9 @@ class DtoQueryPlanCaptureTest extends BaseTestCase {
void nativeDtoQuery_withProfileLocation_capturesQueryPlan() {
ResetBasicData.reset();
// drain stale captures first (see nativeDtoQuery_capturesQueryPlan)
drainCapturedPlans();
// build the plan first (default threshold -> no capture yet)
assertThat(runNativeWithLocation()).isNotEmpty();