Skip to content

Commit 6bbf5df

Browse files
committed
IGNITE-24385 Add minor changes to SqlPlanHistoryIntegrationTest
1 parent c3a6dfa commit 6bbf5df

File tree

1 file changed

+27
-48
lines changed

1 file changed

+27
-48
lines changed

modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SqlPlanHistoryIntegrationTest.java

Lines changed: 27 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -269,28 +269,33 @@ public void testSqlFieldsCrossCacheQueryFailed() throws Exception {
269269
*/
270270
@Test
271271
public void testSqlFieldsQueryWithReducePhase() throws Exception {
272-
runQueryWithReducePhase(() -> {
273-
try {
274-
startGridsMultiThreaded(1, 2);
272+
assumeTrue("Map/reduce queries are only applicable to H2 engine",
273+
sqlEngine == IndexingQueryEngineConfiguration.ENGINE_NAME);
275274

276-
awaitPartitionMapExchange();
275+
assumeFalse("Only distributed queries have map and reduce phases", loc);
277276

278-
cacheQuery(new SqlFieldsQuery(SQL_WITH_REDUCE_PHASE).setDistributedJoins(true), "pers");
277+
startTestGrid();
279278

280-
checkSqlPlanHistory(3);
281-
}
282-
catch (Exception e) {
283-
throw new RuntimeException(e);
284-
}
279+
try {
280+
startGridsMultiThreaded(1, 2);
281+
282+
awaitPartitionMapExchange();
283+
284+
cacheQuery(new SqlFieldsQuery(SQL_WITH_REDUCE_PHASE).setDistributedJoins(true), "pers");
285+
286+
checkSqlPlanHistory(3);
285287

286288
for (int i = 1; i <= 2; i++) {
287289
List<SqlPlanHistoryView> sqlPlansOnMapNode = getSqlPlanHistory(grid(i));
288290

289-
assertTrue(sqlPlansOnMapNode.size() == 2);
291+
assertTrue(waitForCondition(() -> sqlPlansOnMapNode.size() == 2, 1000));
290292

291293
checkMetrics(sqlPlansOnMapNode);
292294
}
293-
});
295+
}
296+
catch (Exception e) {
297+
throw new RuntimeException(e);
298+
}
294299
}
295300

296301
/** Checks successful SqlQuery. */
@@ -378,27 +383,21 @@ public void testPlanHistoryEviction() throws Exception {
378383
public void testEntryReplacement() throws Exception {
379384
startTestGrid();
380385

381-
long firstPlanTS = 0;
386+
long firstTs;
382387

383-
for (int i = 0; i < 2; i++) {
384-
cacheQuery(new SqlFieldsQuery(SQL), "A");
388+
cacheQuery(new SqlFieldsQuery(SQL), "A");
385389

386-
if (i == 0) {
387-
assertTrue(waitForCondition(() -> !getSqlPlanHistory().isEmpty(), 1000));
390+
assertTrue(waitForCondition(() -> !getSqlPlanHistory().isEmpty(), 1000));
388391

389-
firstPlanTS = F.first(getSqlPlanHistory()).lastStartTime().getTime();
392+
firstTs = F.first(getSqlPlanHistory()).lastStartTime().getTime();
390393

391-
long ts0 = U.currentTimeMillis();
394+
long curTs = U.currentTimeMillis();
392395

393-
assertTrue(waitForCondition(() -> (U.currentTimeMillis() != ts0), 1000));
394-
}
395-
else {
396-
long firstPlanTS0 = firstPlanTS;
396+
assertTrue(waitForCondition(() -> (U.currentTimeMillis() != curTs), 1000));
397397

398-
assertTrue(waitForCondition(() ->
399-
F.first(getSqlPlanHistory()).lastStartTime().getTime() > firstPlanTS0, 1000));
400-
}
401-
}
398+
cacheQuery(new SqlFieldsQuery(SQL), "A");
399+
400+
assertTrue(waitForCondition(() -> F.first(getSqlPlanHistory()).lastStartTime().getTime() > firstTs, 1000));
402401
}
403402

404403
/** Checks that SQL plan history stays empty if the grid is started with a zero history size. */
@@ -494,21 +493,7 @@ public void runQueryWithoutPlan(Query qry) throws Exception {
494493

495494
cacheQuery(qry, "A");
496495

497-
checkSqlPlanHistory(0);
498-
}
499-
500-
/**
501-
* @param task Test task to execute.
502-
*/
503-
public void runQueryWithReducePhase(Runnable task) throws Exception {
504-
assumeTrue("Map/reduce queries are only applicable to H2 engine",
505-
sqlEngine == IndexingQueryEngineConfiguration.ENGINE_NAME);
506-
507-
assumeFalse("Only distributed queries have map and reduce phases", loc);
508-
509-
startTestGrid();
510-
511-
task.run();
496+
assertTrue(getSqlPlanHistory().isEmpty());
512497
}
513498

514499
/**
@@ -625,9 +610,6 @@ public List<SqlPlanHistoryView> getSqlPlanHistory(IgniteEx node) {
625610
* @param size Number of SQL plan entries expected to be in the history.
626611
*/
627612
public void checkSqlPlanHistory(int size) throws Exception {
628-
if (size == 0)
629-
return;
630-
631613
assertTrue(waitForCondition(() -> getSqlPlanHistory().size() == size, 1000));
632614

633615
checkMetrics(getSqlPlanHistory());
@@ -640,9 +622,6 @@ public void checkSqlPlanHistory(int size) throws Exception {
640622
* @param isSimpleQry Simple query flag.
641623
*/
642624
public void checkSqlPlanHistoryDml(int size, boolean isSimpleQry) {
643-
if (size == 0)
644-
return;
645-
646625
List<SqlPlanHistoryView> sqlPlans = getSqlPlanHistory();
647626

648627
assertNotNull(sqlPlans);

0 commit comments

Comments
 (0)