ivakegg commented on a change in pull request #368: ACCUMULO-4777: fix log 
messages
URL: https://github.com/apache/accumulo/pull/368#discussion_r164924273
 
 

 ##########
 File path: fate/src/test/java/org/apache/accumulo/fate/zookeeper/RetryTest.java
 ##########
 @@ -147,4 +154,344 @@ public void testUnlimitedRetry() {
       unlimitedRetry2.useRetry();
     }
   }
+
+  @Test
+  public void testLogging() {
+    TestLogger testLogger = new TestLogger();
+    Retry.setLogger(testLogger);
+    try {
+
+      // we want to do this for 5 second and observe the log messages
+      long start = System.currentTimeMillis();
+      long end = System.currentTimeMillis();
+      int i = 0;
+      for (; (end - start < 5000l) && (i < Integer.MAX_VALUE); i++) {
+        unlimitedRetry1.logRetry("failure message");
+        unlimitedRetry1.useRetry();
+        end = System.currentTimeMillis();
+      }
+
+      // now observe what log messages we got which should be around 5 +- 1
+      Assert.assertTrue(i > 10);
+      Assert.assertTrue(testLogger.getMessages().size() >= 4 && 
testLogger.getMessages().size() <= 6);
+    } finally {
+      Retry.setLogger(LoggerFactory.getLogger(Retry.class));
+    }
+
+  }
+
+  private static class TestLogger implements Logger {
 
 Review comment:
   true....I was initially thinking about actually examining the contents of 
the message which is why I went this route....I can rework it however

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to