From cd231d851145041f0638705403c48010deb400e3 Mon Sep 17 00:00:00 2001 From: Suneet Saldanha Date: Mon, 9 Nov 2020 17:34:27 -0800 Subject: [PATCH] Run integration test queries once (#10564) * Run integration test queries once * missed a few --- .../utils/AbstractTestQueryHelper.java | 67 +++++++++---------- .../duty/ITAutoCompactionTest.java | 2 +- .../indexer/AbstractITBatchIndexTest.java | 10 +-- .../AbstractITRealtimeIndexTaskTest.java | 4 +- .../indexer/AbstractStreamIndexingTest.java | 4 +- .../tests/indexer/ITAppendBatchIndexTest.java | 6 +- .../tests/indexer/ITCompactionTaskTest.java | 4 +- .../indexer/ITNestedQueryPushDownTest.java | 2 +- .../tests/query/ITBroadcastJoinQueryTest.java | 6 +- .../tests/query/ITSystemTableQueryTest.java | 2 +- .../druid/tests/query/ITTwitterQueryTest.java | 2 +- .../druid/tests/query/ITUnionQueryTest.java | 4 +- .../tests/query/ITWikipediaQueryTest.java | 2 +- 13 files changed, 55 insertions(+), 60 deletions(-) diff --git a/integration-tests/src/main/java/org/apache/druid/testing/utils/AbstractTestQueryHelper.java b/integration-tests/src/main/java/org/apache/druid/testing/utils/AbstractTestQueryHelper.java index 8cdad831e4b..abea14da8bb 100644 --- a/integration-tests/src/main/java/org/apache/druid/testing/utils/AbstractTestQueryHelper.java +++ b/integration-tests/src/main/java/org/apache/druid/testing/utils/AbstractTestQueryHelper.java @@ -65,23 +65,23 @@ public abstract class AbstractTestQueryHelper queries = @@ -92,10 +92,10 @@ public abstract class AbstractTestQueryHelper queries = @@ -105,35 +105,32 @@ public abstract class AbstractTestQueryHelper queries, int timesToRun) throws Exception + private void testQueries(String url, List queries) throws Exception { LOG.info("Running queries, url [%s]", url); - for (int i = 0; i < timesToRun; i++) { - LOG.info("Starting Iteration %d", i); - boolean failed = false; - for (QueryResultType queryWithResult : queries) { - LOG.info("Running Query %s", queryWithResult.getQuery()); - List> result = queryClient.query(url, queryWithResult.getQuery()); - if (!QueryResultVerifier.compareResults(result, queryWithResult.getExpectedResults())) { - LOG.error( - "Failed while executing query %s \n expectedResults: %s \n actualResults : %s", - queryWithResult.getQuery(), - jsonMapper.writeValueAsString(queryWithResult.getExpectedResults()), - jsonMapper.writeValueAsString(result) - ); - failed = true; - } else { - LOG.info("Results Verified for Query %s", queryWithResult.getQuery()); - } + boolean failed = false; + for (QueryResultType queryWithResult : queries) { + LOG.info("Running Query %s", queryWithResult.getQuery()); + List> result = queryClient.query(url, queryWithResult.getQuery()); + if (!QueryResultVerifier.compareResults(result, queryWithResult.getExpectedResults())) { + LOG.error( + "Failed while executing query %s \n expectedResults: %s \n actualResults : %s", + queryWithResult.getQuery(), + jsonMapper.writeValueAsString(queryWithResult.getExpectedResults()), + jsonMapper.writeValueAsString(result) + ); + failed = true; + } else { + LOG.info("Results Verified for Query %s", queryWithResult.getQuery()); } + } - if (failed) { - throw new ISE("one or more queries failed"); - } + if (failed) { + throw new ISE("one or more queries failed"); } } diff --git a/integration-tests/src/test/java/org/apache/druid/tests/coordinator/duty/ITAutoCompactionTest.java b/integration-tests/src/test/java/org/apache/druid/tests/coordinator/duty/ITAutoCompactionTest.java index ceaa1248ebe..5d1d55ba7b6 100644 --- a/integration-tests/src/test/java/org/apache/druid/tests/coordinator/duty/ITAutoCompactionTest.java +++ b/integration-tests/src/test/java/org/apache/druid/tests/coordinator/duty/ITAutoCompactionTest.java @@ -309,7 +309,7 @@ public class ITAutoCompactionTest extends AbstractIndexerTest fullDatasourceName ); - queryHelper.testQueriesFromString(queryResponseTemplate, 2); + queryHelper.testQueriesFromString(queryResponseTemplate); } private void submitCompactionConfig(Integer maxRowsPerSegment, Period skipOffsetFromLatest) throws Exception diff --git a/integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractITBatchIndexTest.java b/integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractITBatchIndexTest.java index d25e35f9de4..0873417ad49 100644 --- a/integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractITBatchIndexTest.java +++ b/integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractITBatchIndexTest.java @@ -130,11 +130,11 @@ public abstract class AbstractITBatchIndexTest extends AbstractIndexerTest submitTaskAndWait(taskSpec, fullDatasourceName, waitForNewVersion, waitForSegmentsToLoad); if (runTestQueries) { - doTestQuery(dataSource, queryFilePath, 2); + doTestQuery(dataSource, queryFilePath); } } - protected void doTestQuery(String dataSource, String queryFilePath, int timesToRun) + protected void doTestQuery(String dataSource, String queryFilePath) { try { String queryResponseTemplate; @@ -151,7 +151,7 @@ public abstract class AbstractITBatchIndexTest extends AbstractIndexerTest "%%DATASOURCE%%", dataSource + config.getExtraDatasourceNameSuffix() ); - queryHelper.testQueriesFromString(queryResponseTemplate, timesToRun); + queryHelper.testQueriesFromString(queryResponseTemplate); } catch (Exception e) { @@ -212,7 +212,7 @@ public abstract class AbstractITBatchIndexTest extends AbstractIndexerTest fullReindexDatasourceName ); - queryHelper.testQueriesFromString(queryResponseTemplate, 2); + queryHelper.testQueriesFromString(queryResponseTemplate); // verify excluded dimension is not reIndexed final List dimensions = clientInfoResourceTestClient.getDimensions( fullReindexDatasourceName, @@ -241,7 +241,7 @@ public abstract class AbstractITBatchIndexTest extends AbstractIndexerTest submitTaskAndWait(taskSpec, fullDatasourceName, false, true); try { - sqlQueryHelper.testQueriesFromFile(queryFilePath, 2); + sqlQueryHelper.testQueriesFromFile(queryFilePath); } catch (Exception e) { LOG.error(e, "Error while testing"); diff --git a/integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractITRealtimeIndexTaskTest.java b/integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractITRealtimeIndexTaskTest.java index 2083215d8a7..5d57328b11e 100644 --- a/integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractITRealtimeIndexTaskTest.java +++ b/integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractITRealtimeIndexTaskTest.java @@ -145,7 +145,7 @@ public abstract class AbstractITRealtimeIndexTaskTest extends AbstractIndexerTes // and some on historical. Which it is depends on where in the minute we were // when we started posting events. try { - this.queryHelper.testQueriesFromString(getRouterURL(), queryStr, 2); + this.queryHelper.testQueriesFromString(getRouterURL(), queryStr); } catch (Exception e) { throw new RuntimeException(e); @@ -164,7 +164,7 @@ public abstract class AbstractITRealtimeIndexTaskTest extends AbstractIndexerTes ); // queries should be answered by historical - this.queryHelper.testQueriesFromString(getRouterURL(), queryStr, 2); + this.queryHelper.testQueriesFromString(getRouterURL(), queryStr); } catch (Exception e) { throw new RuntimeException(e); diff --git a/integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractStreamIndexingTest.java b/integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractStreamIndexingTest.java index 9a1dbb32e62..40f5413ce35 100644 --- a/integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractStreamIndexingTest.java +++ b/integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractStreamIndexingTest.java @@ -482,7 +482,7 @@ public abstract class AbstractStreamIndexingTest extends AbstractIndexerTest final String querySpec = generatedTestConfig.getStreamQueryPropsTransform() .apply(getResourceAsString(QUERIES_FILE)); // this query will probably be answered from the indexing tasks but possibly from 2 historical segments / 2 indexing - this.queryHelper.testQueriesFromString(querySpec, 2); + this.queryHelper.testQueriesFromString(querySpec); LOG.info("Shutting down supervisor"); indexer.shutdownSupervisor(generatedTestConfig.getSupervisorId()); // Clear supervisor ID to not shutdown again. @@ -503,7 +503,7 @@ public abstract class AbstractStreamIndexingTest extends AbstractIndexerTest ); // this query will be answered by at least 1 historical segment, most likely 2, and possibly up to all 4 - this.queryHelper.testQueriesFromString(querySpec, 2); + this.queryHelper.testQueriesFromString(querySpec); } long getSumOfEventSequence(int numEvents) diff --git a/integration-tests/src/test/java/org/apache/druid/tests/indexer/ITAppendBatchIndexTest.java b/integration-tests/src/test/java/org/apache/druid/tests/indexer/ITAppendBatchIndexTest.java index 94e4d23f75c..8ba848ef8dc 100644 --- a/integration-tests/src/test/java/org/apache/druid/tests/indexer/ITAppendBatchIndexTest.java +++ b/integration-tests/src/test/java/org/apache/druid/tests/indexer/ITAppendBatchIndexTest.java @@ -98,17 +98,17 @@ public class ITAppendBatchIndexTest extends AbstractITBatchIndexTest // Submit initial ingestion task submitIngestionTaskAndVerify(indexDatasource, partitionsSpecList.get(0), false); verifySegmentsCountAndLoaded(indexDatasource, expectedSegmentCountList.get(0)); - doTestQuery(indexDatasource, INDEX_QUERIES_INITIAL_INGESTION_RESOURCE, 2); + doTestQuery(indexDatasource, INDEX_QUERIES_INITIAL_INGESTION_RESOURCE); // Submit append ingestion task submitIngestionTaskAndVerify(indexDatasource, partitionsSpecList.get(1), true); verifySegmentsCountAndLoaded(indexDatasource, expectedSegmentCountList.get(1)); - doTestQuery(indexDatasource, INDEX_QUERIES_POST_APPEND_PRE_COMPACT_RESOURCE, 2); + doTestQuery(indexDatasource, INDEX_QUERIES_POST_APPEND_PRE_COMPACT_RESOURCE); // Submit compaction task compactData(indexDatasource, COMPACTION_TASK); // Verification post compaction verifySegmentsCountAndLoaded(indexDatasource, expectedSegmentCountList.get(2)); verifySegmentsCompacted(indexDatasource, expectedSegmentCountList.get(2)); - doTestQuery(indexDatasource, INDEX_QUERIES_POST_APPEND_POST_COMPACT_RESOURCE, 2); + doTestQuery(indexDatasource, INDEX_QUERIES_POST_APPEND_POST_COMPACT_RESOURCE); } } diff --git a/integration-tests/src/test/java/org/apache/druid/tests/indexer/ITCompactionTaskTest.java b/integration-tests/src/test/java/org/apache/druid/tests/indexer/ITCompactionTaskTest.java index 006c18ececa..30c4a757aab 100644 --- a/integration-tests/src/test/java/org/apache/druid/tests/indexer/ITCompactionTaskTest.java +++ b/integration-tests/src/test/java/org/apache/druid/tests/indexer/ITCompactionTaskTest.java @@ -97,12 +97,12 @@ public class ITCompactionTaskTest extends AbstractIndexerTest ); - queryHelper.testQueriesFromString(queryResponseTemplate, 2); + queryHelper.testQueriesFromString(queryResponseTemplate); compactData(); // 4 segments across 2 days, compacted into 2 new segments (6 total) checkCompactionFinished(6); - queryHelper.testQueriesFromString(queryResponseTemplate, 2); + queryHelper.testQueriesFromString(queryResponseTemplate); checkCompactionIntervals(intervalsBeforeCompaction); } diff --git a/integration-tests/src/test/java/org/apache/druid/tests/indexer/ITNestedQueryPushDownTest.java b/integration-tests/src/test/java/org/apache/druid/tests/indexer/ITNestedQueryPushDownTest.java index 19e0626bac1..61ab91eb647 100644 --- a/integration-tests/src/test/java/org/apache/druid/tests/indexer/ITNestedQueryPushDownTest.java +++ b/integration-tests/src/test/java/org/apache/druid/tests/indexer/ITNestedQueryPushDownTest.java @@ -89,7 +89,7 @@ public class ITNestedQueryPushDownTest extends AbstractIndexerTest fullDatasourceName ); - queryHelper.testQueriesFromString(queryResponseTemplate, 2); + queryHelper.testQueriesFromString(queryResponseTemplate); } catch (Exception e) { LOG.error(e, "Error while testing"); diff --git a/integration-tests/src/test/java/org/apache/druid/tests/query/ITBroadcastJoinQueryTest.java b/integration-tests/src/test/java/org/apache/druid/tests/query/ITBroadcastJoinQueryTest.java index b7e2910a98d..66f98e85cee 100644 --- a/integration-tests/src/test/java/org/apache/druid/tests/query/ITBroadcastJoinQueryTest.java +++ b/integration-tests/src/test/java/org/apache/druid/tests/query/ITBroadcastJoinQueryTest.java @@ -95,8 +95,7 @@ public class ITBroadcastJoinQueryTest extends AbstractIndexerTest replaceJoinTemplate( getResourceAsString(BROADCAST_JOIN_METADATA_QUERIES_RESOURCE), BROADCAST_JOIN_DATASOURCE - ), - 1 + ) ); return true; } @@ -110,8 +109,7 @@ public class ITBroadcastJoinQueryTest extends AbstractIndexerTest // now do some queries queryHelper.testQueriesFromString( queryHelper.getQueryURL(config.getRouterUrl()), - replaceJoinTemplate(getResourceAsString(BROADCAST_JOIN_QUERIES_RESOURCE), BROADCAST_JOIN_DATASOURCE), - 1 + replaceJoinTemplate(getResourceAsString(BROADCAST_JOIN_QUERIES_RESOURCE), BROADCAST_JOIN_DATASOURCE) ); } finally { diff --git a/integration-tests/src/test/java/org/apache/druid/tests/query/ITSystemTableQueryTest.java b/integration-tests/src/test/java/org/apache/druid/tests/query/ITSystemTableQueryTest.java index 6beb9566624..f80b57ea9a0 100644 --- a/integration-tests/src/test/java/org/apache/druid/tests/query/ITSystemTableQueryTest.java +++ b/integration-tests/src/test/java/org/apache/druid/tests/query/ITSystemTableQueryTest.java @@ -63,7 +63,7 @@ public class ITSystemTableQueryTest public void testSystemTableQueries() { try { - this.queryHelper.testQueriesFromFile(SYSTEM_QUERIES_RESOURCE, 2); + this.queryHelper.testQueriesFromFile(SYSTEM_QUERIES_RESOURCE); } catch (Exception e) { throw new RuntimeException(e); diff --git a/integration-tests/src/test/java/org/apache/druid/tests/query/ITTwitterQueryTest.java b/integration-tests/src/test/java/org/apache/druid/tests/query/ITTwitterQueryTest.java index 402b1bbc731..f0ecaa011d9 100644 --- a/integration-tests/src/test/java/org/apache/druid/tests/query/ITTwitterQueryTest.java +++ b/integration-tests/src/test/java/org/apache/druid/tests/query/ITTwitterQueryTest.java @@ -52,7 +52,7 @@ public class ITTwitterQueryTest @Test public void testTwitterQueriesFromFile() throws Exception { - queryHelper.testQueriesFromFile(TWITTER_QUERIES_RESOURCE, 2); + queryHelper.testQueriesFromFile(TWITTER_QUERIES_RESOURCE); } } diff --git a/integration-tests/src/test/java/org/apache/druid/tests/query/ITUnionQueryTest.java b/integration-tests/src/test/java/org/apache/druid/tests/query/ITUnionQueryTest.java index c720b1fab5b..6ea489b2d54 100644 --- a/integration-tests/src/test/java/org/apache/druid/tests/query/ITUnionQueryTest.java +++ b/integration-tests/src/test/java/org/apache/druid/tests/query/ITUnionQueryTest.java @@ -151,7 +151,7 @@ public class ITUnionQueryTest extends AbstractIndexerTest fullDatasourceName ); - this.queryHelper.testQueriesFromString(queryResponseTemplate, 2); + this.queryHelper.testQueriesFromString(queryResponseTemplate); // wait for the task to complete for (int i = 0; i < numTasks; i++) { @@ -169,7 +169,7 @@ public class ITUnionQueryTest extends AbstractIndexerTest ); } // run queries on historical nodes - this.queryHelper.testQueriesFromString(queryResponseTemplate, 2); + this.queryHelper.testQueriesFromString(queryResponseTemplate); } catch (Throwable e) { diff --git a/integration-tests/src/test/java/org/apache/druid/tests/query/ITWikipediaQueryTest.java b/integration-tests/src/test/java/org/apache/druid/tests/query/ITWikipediaQueryTest.java index a80abbb6b39..ecd8ce3a512 100644 --- a/integration-tests/src/test/java/org/apache/druid/tests/query/ITWikipediaQueryTest.java +++ b/integration-tests/src/test/java/org/apache/druid/tests/query/ITWikipediaQueryTest.java @@ -79,7 +79,7 @@ public class ITWikipediaQueryTest @Test public void testWikipediaQueriesFromFile() throws Exception { - queryHelper.testQueriesFromFile(WIKIPEDIA_QUERIES_RESOURCE, 2); + queryHelper.testQueriesFromFile(WIKIPEDIA_QUERIES_RESOURCE); } @Test