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


##########
indexing-service/src/test/java/org/apache/druid/indexing/overlord/TaskQueueConcurrencyTest.java:
##########
@@ -309,6 +309,97 @@ public void test_add_blocks_shutdown_forSameTaskId()
     );
   }
 
+  @Test
+  public void test_add_doesNotBlock_add_forDifferentTaskId()
+  {
+    taskQueue.setActive(true);
+
+    final Task task1 = createTask("t1");
+    final Task task2 = createTask("t2");
+
+    ActionVerifier.verifyThat(
+        update(
+            () -> taskQueue.add(task1)
+        ).withEndState(
+            () -> Assert.assertEquals(
+                Optional.of(task1),
+                taskQueue.getActiveTask(task1.getId())
+            )
+        )
+    ).doesNotBlock(
+        update(
+            () -> taskQueue.add(task2)
+        ).withEndState(
+            () -> Assert.assertEquals(
+                Optional.of(task2),
+                taskQueue.getActiveTask(task2.getId())
+            )
+        )
+    );
+  }
+
+  @Test
+  public void test_add_doesNotBlock_shutdown_forDifferentTaskId()
+  {
+    taskQueue.setActive(true);
+
+    final Task task1 = createTask("t1");
+    taskQueue.add(task1);
+
+    final Task task2 = createTask("t2");
+
+    ActionVerifier.verifyThat(
+        update(
+            () -> taskQueue.add(task2)
+        ).withEndState(
+            () -> Assert.assertEquals(
+                Optional.of(task2),
+                taskQueue.getActiveTask(task2.getId())
+            )
+        )
+    ).doesNotBlock(
+        update(
+            () -> taskQueue.shutdown(task1.getId(), "killed")
+        ).withEndState(
+            () -> Assert.assertEquals(
+                Optional.of(TaskStatus.failure(task1.getId(), "killed")),
+                taskQueue.getTaskStatus(task1.getId())
+            )
+        )
+    );
+  }
+
+  @Test
+  public void test_shutdown_doesNotBlock_add_forDifferentTaskId()
+  {
+    taskQueue.setActive(true);
+
+    final Task task1 = createTask("t1");
+    taskQueue.add(task1);
+
+    final Task task2 = createTask("t2");
+
+    ActionVerifier.verifyThat(
+        update(
+            () -> taskQueue.shutdown(task1.getId(), "killed")
+        ).withEndState(
+            () -> Assert.assertEquals(
+                Optional.of(TaskStatus.failure(task1.getId(), "killed")),
+                taskQueue.getTaskStatus(task1.getId())
+            )
+        )
+    ).doesNotBlock(
+        update(
+            () -> taskQueue.add(task2)
+        ).withEndState(
+            () -> Assert.assertEquals(
+                Optional.of(task2),
+                taskQueue.getActiveTask(task2.getId())
+            )
+        )
+    );
+  }
+

Review Comment:
   Yeah, we will need separate tests for those race conditions. These are just 
the cases I had missed in the original PR.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to