abhishekagarwal87 commented on code in PR #15726:
URL: https://github.com/apache/druid/pull/15726#discussion_r1512785886


##########
server/src/test/java/org/apache/druid/discovery/BaseNodeRoleWatcherTest.java:
##########
@@ -116,6 +117,70 @@ public void testGeneralUseSimulation()
     assertListener(listener3, true, nodesAdded, nodesRemoved);
   }
 
+  @Test(timeout = 60_000L)
+  public void testRegisterListenerBeforeTimeout() throws InterruptedException
+  {
+    BaseNodeRoleWatcher nodeRoleWatcher = new BaseNodeRoleWatcher(exec, 
NodeRole.BROKER, 3);
+
+    TestListener listener1 = new TestListener();
+    nodeRoleWatcher.registerListener(listener1);
+
+    DiscoveryDruidNode broker1 = buildDiscoveryDruidNode(NodeRole.BROKER, 
"broker1");
+    DiscoveryDruidNode broker2 = buildDiscoveryDruidNode(NodeRole.BROKER, 
"broker2");
+    DiscoveryDruidNode broker3 = buildDiscoveryDruidNode(NodeRole.BROKER, 
"broker3");
+
+    DiscoveryDruidNode notBroker = new DiscoveryDruidNode(
+        new DruidNode("s3", "h3", false, 8080, null, true, false),
+        NodeRole.COORDINATOR,
+        ImmutableMap.of()
+    );
+
+    nodeRoleWatcher.childAdded(broker1);
+    nodeRoleWatcher.childAdded(notBroker);
+    nodeRoleWatcher.childAdded(broker3);
+    nodeRoleWatcher.childRemoved(broker2);
+
+    assertListener(listener1, false, Collections.emptyList(), 
Collections.emptyList());
+
+    Thread.sleep(3100);

Review Comment:
   then it needs to be reaped at test class level rather than after every 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: commits-unsubscr...@druid.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to