stefan-egli commented on a change in pull request #4:
URL: 
https://github.com/apache/sling-org-apache-sling-discovery-oak/pull/4#discussion_r708339633



##########
File path: 
src/test/java/org/apache/sling/discovery/oak/OakDiscoveryServiceTest.java
##########
@@ -414,4 +428,352 @@ public void testPropertyProviderRegistrations() throws 
Exception{
         discoveryService.unbindPropertyProvider(p, m);
         discoveryService.updatedPropertyProvider(p, m);
     }
-}
+
+    @Test
+    public void simpleNewJoinerTest() throws Exception {
+        doSimpleNewJoinerTest(0);
+    }
+
+    @Test
+    public void simpleNewJoinerTestWithDelay() throws Exception {
+        doSimpleNewJoinerTest(2);
+    }
+
+    private void doSimpleNewJoinerTest(int joinerDelaySeconds) throws 
Exception {
+        OakVirtualInstanceBuilder builder1 =
+                (OakVirtualInstanceBuilder) new OakVirtualInstanceBuilder()
+                .setDebugName("instance1")
+                .newRepository("/foo/barrio/foo/", true)
+                .setConnectorPingInterval(999)
+                .setConnectorPingTimeout(999);
+        builder1.getConfig().setSyncTokenEnabled(true);
+        builder1.getConfig().setJoinerDelaySeconds(joinerDelaySeconds);
+        VirtualInstance instance1 = builder1.build();
+        DummyListener listener1 = new DummyListener();
+        OakDiscoveryService discoveryService1 = (OakDiscoveryService) 
instance1.getDiscoveryService();
+        discoveryService1.bindTopologyEventListener(listener1);
+
+        instance1.heartbeatsAndCheckView();
+        instance1.heartbeatsAndCheckView();
+
+        assertEquals(0, 
discoveryService1.getViewStateManager().waitForAsyncEvents(2000));
+        Thread.sleep(1000);

Review comment:
       `waitForAsyncEvents` could in theory have waited for an aysnc event in 
the queue to be picked up (by `AsyncEventSender.run()`), so 
`getInFlightEventCnt()` returns 0 - while that async event is still being 
executed via 
[asyncEvent.trigger()](https://github.com/apache/sling-org-apache-sling-discovery-commons/blob/8ecba4a098ae32e28022166a0e4095494efe10f1/src/main/java/org/apache/sling/discovery/commons/providers/base/AsyncEventSender.java#L118)
   
   I think there's room for improvement here to avoid waiting - by more precise 
wait logic in the AsyncEventSender. Relying on sleeping is indeed not ideal.




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


Reply via email to