FrankChen021 commented on code in PR #20479:
URL: https://github.com/apache/druid/pull/20479#discussion_r4190864633


##########
extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/simulate/EmbeddedKafkaSupervisorTest.java:
##########
@@ -87,6 +90,24 @@ public EmbeddedDruidCluster createCluster()
     return cluster;
   }
 
+  @AfterEach
+  public void stopSupervisor()
+  {
+    if (supervisorSpec != null) {
+      try {
+        cluster.callApi().postSupervisor(supervisorSpec.createSuspendedSpec());
+        // Suspension stops new tasks, but existing tasks may still be 
publishing.
+        for (final TaskStatusPlus task : getActiveTasks()) {
+          cluster.callApi().onLeaderOverlord(o -> o.cancelTask(task.getId()));
+        }
+        cluster.callApi().waitForResult(this::getActiveTasks, 
List::isEmpty).go();
+      }
+      finally {
+        supervisorSpec = null;

Review Comment:
   [P2] Teardown loses the cleanup handle after a failure
   
   **Finding:** If suspending the supervisor, cancelling a task, or the default 
10-second drain wait throws, this finally block still clears the only tracked 
supervisor spec. Because the test class shares one cluster across methods, any 
task left running after that failure can continue into the next test and this 
teardown cannot retry the suspension or cancellation, causing cross-test 
interference.
   
   **Suggestion:** Only clear the tracked spec after cleanup succeeds, and 
preserve or retry it when cancellation or draining fails so a later cleanup can 
still isolate the following test.



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