You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by ka...@apache.org on 2025/05/16 04:44:45 UTC
(druid) branch master updated: fix flaky unit test (#18004)
This is an automated email from the ASF dual-hosted git repository.
karan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new c7bca7848d4 fix flaky unit test (#18004)
c7bca7848d4 is described below
commit c7bca7848d4f64c0d32db5598cedeb643b9e9ab2
Author: Cece Mei <yi...@gmail.com>
AuthorDate: Thu May 15 21:44:38 2025 -0700
fix flaky unit test (#18004)
* fix flaky unit test
* add comment
---
.../indexing/overlord/SingleTaskBackgroundRunnerTest.java | 7 +++++++
.../scheduledbatch/ScheduledBatchStatusTrackerTest.java | 14 +++++++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/SingleTaskBackgroundRunnerTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/SingleTaskBackgroundRunnerTest.java
index 1b24f3b84c5..8e59460f93c 100644
--- a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/SingleTaskBackgroundRunnerTest.java
+++ b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/SingleTaskBackgroundRunnerTest.java
@@ -325,6 +325,13 @@ public class SingleTaskBackgroundRunnerTest
0,
null
)
+ {
+ @Override
+ public boolean waitForCleanupToFinish()
+ {
+ return true;
+ }
+ }
);
Assert.assertTrue(runLatch.await(1, TimeUnit.SECONDS));
diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/scheduledbatch/ScheduledBatchStatusTrackerTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/scheduledbatch/ScheduledBatchStatusTrackerTest.java
index 422c3fb234a..506d734c63e 100644
--- a/indexing-service/src/test/java/org/apache/druid/indexing/scheduledbatch/ScheduledBatchStatusTrackerTest.java
+++ b/indexing-service/src/test/java/org/apache/druid/indexing/scheduledbatch/ScheduledBatchStatusTrackerTest.java
@@ -23,10 +23,13 @@ import com.google.common.collect.ImmutableList;
import org.apache.druid.indexer.TaskState;
import org.apache.druid.indexer.TaskStatus;
import org.apache.druid.query.http.SqlTaskStatus;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import java.util.Comparator;
import java.util.List;
+import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -204,7 +207,16 @@ public class ScheduledBatchStatusTrackerTest
final BatchSupervisorTaskReport report1 = statusTracker.getSupervisorTaskReport(SUPERVISOR_ID_1);
assertNotNull(report1);
- verifyTaskStatus(report1.getRecentTasks(), ImmutableList.of(TaskStatus.success(TASK_ID_1), TaskStatus.failure(TASK_ID_2, "Task failed")));
+ // supervisor1 got task1 and task2 at the same time, the order should not matter, hence sort the tasks to make sure the result matches.
+ List<TaskStatus> sortedActualStatues = report1.getRecentTasks()
+ .stream()
+ .map(BatchSupervisorTaskStatus::getTaskStatus)
+ .sorted(Comparator.comparing(TaskStatus::getId))
+ .collect(Collectors.toList());
+ Assert.assertEquals(
+ sortedActualStatues,
+ ImmutableList.of(TaskStatus.success(TASK_ID_1), TaskStatus.failure(TASK_ID_2, "Task failed"))
+ );
// Verify that tasks were correctly tracked for supervisor 2
final BatchSupervisorTaskReport report2 = statusTracker.getSupervisorTaskReport(SUPERVISOR_ID_2);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org