diff --git a/ebean-test/src/test/java/io/ebean/xtest/base/DtoQueryPlanCaptureTest.java b/ebean-test/src/test/java/io/ebean/xtest/base/DtoQueryPlanCaptureTest.java index 225955e56..1bb2fc50c 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/base/DtoQueryPlanCaptureTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/base/DtoQueryPlanCaptureTest.java @@ -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();