jtuglu-netflix commented on code in PR #18022:
URL: https://github.com/apache/druid/pull/18022#discussion_r2098697669


##########
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:
   The issue from yesterday doesn't really fit into this happens-before testing 
(at least not with an in-memory metadata store) since the writes are pretty 
much immediately visible to the read in `syncFromStorage`. i.e I'll need to 
mock the DB read in `syncFromStorage` to exclude the task ID to allow for 
testing the clock comparison logic.



-- 
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