kfaraz commented on code in PR #18207:
URL: https://github.com/apache/druid/pull/18207#discussion_r2238865318


##########
embedded-tests/src/test/java/org/apache/druid/testing/embedded/compact/AutoCompactionTest.java:
##########
@@ -1742,84 +1639,85 @@ public void 
testAutoCompactionDutyWithOverlappingInterval() throws Exception
       );
       // Compact the MONTH segment
       forceTriggerAutoCompaction(2);
-      verifyQuery(INDEX_ROLLUP_QUERIES_RESOURCE, queryAndResultFields);
+      verifyScanResult("added", "57.0||459.0");
+      verifyScanResult("COUNT(*)", "2");
 
       // Compact the WEEK segment
       forceTriggerAutoCompaction(2);
-      verifyQuery(INDEX_ROLLUP_QUERIES_RESOURCE, queryAndResultFields);
+      verifyScanResult("added", "57.0||459.0");
+      verifyScanResult("COUNT(*)", "2");
 
       // Verify all task succeed
-      List<TaskResponseObject> compactTasksBefore = 
indexer.getCompleteTasksForDataSource(fullDatasourceName);
-      for (TaskResponseObject taskResponseObject : compactTasksBefore) {
-        Assert.assertEquals(TaskState.SUCCESS, taskResponseObject.getStatus());
+      List<TaskStatusPlus> compactTasksBefore = 
getCompleteTasksForDataSource(fullDatasourceName);
+      for (TaskStatusPlus taskResponseObject : compactTasksBefore) {
+        Assertions.assertEquals(TaskState.SUCCESS, 
taskResponseObject.getStatusCode());
       }
 
       // Verify compacted segments does not get compacted again
       forceTriggerAutoCompaction(2);
-      List<TaskResponseObject> compactTasksAfter = 
indexer.getCompleteTasksForDataSource(fullDatasourceName);
-      Assert.assertEquals(compactTasksAfter.size(), compactTasksBefore.size());
+      List<TaskStatusPlus> compactTasksAfter = 
getCompleteTasksForDataSource(fullDatasourceName);
+      Assertions.assertEquals(compactTasksAfter.size(), 
compactTasksBefore.size());
     }
   }
 
-  private void loadData(String indexTask) throws Exception
+  private <T extends TaskBuilder.IndexCommon<?, ?, ?>> void 
loadData(Supplier<T> updatePayload)
   {
-    loadData(indexTask, ImmutableMap.of());
+    loadData(updatePayload, null);
   }
 
-  private void loadData(String indexTask, Map<String, Object> specs) throws 
Exception
+  private <T extends TaskBuilder.IndexCommon<?, ?, ?>> void loadData(
+      Supplier<T> taskPayloadSupplier,
+      GranularitySpec granularitySpec
+  )
   {
-    String taskSpec = getResourceAsString(indexTask);
-    taskSpec = StringUtils.replace(taskSpec, "%%DATASOURCE%%", 
fullDatasourceName);
-    taskSpec = StringUtils.replace(
-        taskSpec,
-        "%%SEGMENT_AVAIL_TIMEOUT_MILLIS%%",
-        jsonMapper.writeValueAsString("0")
-    );
-    for (Map.Entry<String, Object> entry : specs.entrySet()) {
-      taskSpec = StringUtils.replace(
-          taskSpec,
-          entry.getKey(),
-          jsonMapper.writeValueAsString(entry.getValue())
-      );
+    final TaskBuilder.IndexCommon<?, ?, ?> taskBuilder = 
taskPayloadSupplier.get();
+    taskBuilder.dataSource(fullDatasourceName);
+    if (granularitySpec != null) {
+      taskBuilder.granularitySpec(granularitySpec);
     }
-    final String taskId = indexer.submitTask(taskSpec);
-    LOG.info("Submitted task[%s] to load data", taskId);
-    indexer.waitUntilTaskCompletes(taskId);
 
-    ITRetryUtil.retryUntilTrue(
-        () -> coordinator.areSegmentsLoaded(fullDatasourceName),
-        "Segments are loaded"
+    runTask(taskBuilder, fullDatasourceName);
+  }
+
+  private void verifyQuery(List<Pair<String, String>> queries)
+  {
+    queries.forEach(
+        query -> verifyQuery(query.lhs, query.rhs)
     );
   }
 
-  private void verifyQuery(String queryResource) throws Exception
+  private void verifyQuery(String query, String result)
   {
-    verifyQuery(queryResource, ImmutableMap.of());
+    Assertions.assertEquals(
+        result,
+        cluster.runSql(query, dataSource),
+        StringUtils.format("Query[%s] failed", query)
+    );
   }
 
-  private void verifyQuery(String queryResource, Map<String, Object> 
keyValueToReplace) throws Exception
+  /**
+   * Verifies the result of a SELECT query
+   *
+   * @param field  Field to select
+   * @param result CSV result with special strings {@code ||} to represent

Review Comment:
   I tried a bunch of different symbols, but nothing really conveyed a 
"newline" well-enough, not even `↵` or `⏎`.
   The empty strings are probably the worse of the two though.
   Using ellipsis for now, but keeping newline `\n` as is.
   
   So, we would have something like this:
   
   ```java
   verifyScanResult("added", "...\n31\n...\n62");
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to