AmatyaAvadhanula commented on code in PR #15726: URL: https://github.com/apache/druid/pull/15726#discussion_r1512827260
########## server/src/test/java/org/apache/druid/discovery/BaseNodeRoleWatcherTest.java: ########## @@ -190,41 +196,39 @@ private DiscoveryDruidNode buildDiscoveryDruidNode(NodeRole role, String host) ); } - private void assertListenerTimedOut(TestListener listener) - { - try { - exec.submit(() -> { - Assert.assertTrue(listener.timedOut.get()); - }).get(); - } - catch (Exception e) { - Assert.fail(); - } - } - private void assertListener( TestListener listener, boolean nodeViewInitialized, List<DiscoveryDruidNode> nodesAdded, List<DiscoveryDruidNode> nodesRemoved ) { - try { - exec.submit(() -> { - Assert.assertEquals(nodeViewInitialized, listener.nodeViewInitialized.get()); - Assert.assertEquals(nodesAdded, listener.nodesAddedList); - Assert.assertEquals(nodesRemoved, listener.nodesRemovedList); - }).get(); - } - catch (Exception e) { - Assert.fail(); - } + Assert.assertEquals(nodeViewInitialized, listener.nodeViewInitialized.get()); + Assert.assertEquals(nodesAdded, listener.nodesAddedList); + Assert.assertEquals(nodesRemoved, listener.nodesRemovedList); + } + + private ScheduledExecutorService createScheduledSingleThreadedExecutor() + { + return new ScheduledThreadPoolExecutor( + 1, + Execs.makeThreadFactory("BaseNodeRoleWatcher") + ) + { + @Override + public Future<?> submit(Runnable task) + { + task.run(); + return Futures.immediateFuture(null); + } + }; } public static class TestListener implements DruidNodeDiscovery.Listener { - private final AtomicBoolean timedOut = new AtomicBoolean(false); + private final CountDownLatch ready = new CountDownLatch(1); private final AtomicBoolean nodeViewInitialized = new AtomicBoolean(false); + private final AtomicBoolean nodeViewInitializationTimedOut = new AtomicBoolean(false); Review Comment: Thanks, I've reused the latch for the checks. -- 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