clintropolis commented on code in PR #13499:
URL: https://github.com/apache/druid/pull/13499#discussion_r1040082862


##########
server/src/test/java/org/apache/druid/server/coordination/ChangeRequestHistoryTest.java:
##########
@@ -171,4 +172,48 @@ public void testNonImmediateFuture() throws Exception
     Assert.assertEquals(1, snapshot.getCounter().getCounter());
     Assert.assertEquals(1, snapshot.getRequests().size());
   }
+
+  @Test
+  public void testStop() throws ExecutionException, InterruptedException
+  {
+    final ChangeRequestHistory<DataSegmentChangeRequest> history = new 
ChangeRequestHistory();
+
+    ListenableFuture<ChangeRequestsSnapshot<DataSegmentChangeRequest>> future 
= history.getRequestsSince(
+        ChangeRequestHistory.Counter.ZERO
+    );
+    Assert.assertEquals(1, history.waitingFutures.size());
+
+    final AtomicBoolean callbackExcecuted = new AtomicBoolean(false);
+    Futures.addCallback(
+        future,
+        new FutureCallback<ChangeRequestsSnapshot<DataSegmentChangeRequest>>()
+        {
+          @Override
+          public void onSuccess(ChangeRequestsSnapshot result)
+          {
+            callbackExcecuted.set(true);
+          }
+
+          @Override
+          public void onFailure(Throwable t)
+          {
+            callbackExcecuted.set(true);
+          }
+        }
+    );
+
+    history.stop();
+    // any new change requests should be ignored, there should be no waiting 
futures, and open futures should be resolved
+    history.addChangeRequest(new SegmentChangeRequestNoop());
+    Assert.assertEquals(0, history.waitingFutures.size());
+    Assert.assertTrue(callbackExcecuted.get());
+    Assert.assertTrue(future.isDone());
+    try {

Review Comment:
   heh, I wasn't sure how to test the exception message, but I see now that 
`assertThrows` actually returns the thrown exception, will adjust, thanks :+1:



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