jiajunwang commented on a change in pull request #1497:
URL: https://github.com/apache/helix/pull/1497#discussion_r513932686



##########
File path: 
helix-core/src/test/java/org/apache/helix/integration/spectator/TestRoutingTableProviderPeriodicRefresh.java
##########
@@ -203,34 +208,32 @@ synchronized int getRefreshCount() {
 
   @Test
   public void testPeriodicRefresh() throws InterruptedException {
-    // Wait so that initial refreshes finish (not triggered by periodic 
refresh timer)
-    Thread.sleep(1000L);
+    // Wait to ensure that the initial refreshes finish (not triggered by 
periodic refresh timer)
+    Thread.sleep(REFRESH_PERIOD_MS * 2);
 
     // Test short refresh
     int prevRefreshCount = _routingTableProvider.getRefreshCount();
-    // Wait for one timer duration
-    Thread.sleep(1000L);
-    // The timer should have gone off, incrementing the refresh count
-    Assert.assertEquals(_routingTableProvider.getRefreshCount(), 
prevRefreshCount + 1);
+    // Wait for more than one timer duration
+    Thread.sleep((long) (REFRESH_PERIOD_MS * 1.5));
+    // The timer should have gone off, incrementing the refresh count by one 
or two depends on the
+    // timing.
+    int newRefreshCount = _routingTableProvider.getRefreshCount();
+    Assert.assertTrue(
+        newRefreshCount == prevRefreshCount + 1 || newRefreshCount == 
prevRefreshCount + 2);

Review comment:
       The java schedule task method that we are using is not accurate anyway. 
Moreover, the main test purpose here is to ensure the refresh happens. If it is 
faster a little bit, I guess we are still good.
   On the other hand, if the refresh does respect the interval, so during 1.5 
seconds, it happens more than 2 times, then the test will still fail.




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

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