Interesting, I've spent some time in the internals of the rolling appender but I didn't know that it only rolled over every 16 log events. I'll see if I can find that in the code. (Strange that the tests worked on my machine, oh well...)
Thanks for helping to fix the test. On Sun, May 18, 2014 at 3:14 PM, Ralph Goers <[email protected]>wrote: > Never mind. The way you modified the test it wasn’t forcing a rollover. A > check for rollover is only performed once per every 16 log events. In > addition, since the compression happens on a separate thread some time > needs to be allowed to have that complete. I’ve fixed these problems so > hopefully I won’t see failures any more. > > Ralph > > On May 17, 2014, at 11:01 PM, Ralph Goers <[email protected]> > wrote: > > Here is how it fails. > > Running > org.apache.logging.log4j.core.appender.rolling.RollingAppenderTimeTest > Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.523 sec > <<< FAILURE! - in > org.apache.logging.log4j.core.appender.rolling.RollingAppenderTimeTest > testAppender(org.apache.logging.log4j.core.appender.rolling.RollingAppenderTimeTest) > Time elapsed: 1.508 sec <<< FAILURE! > java.lang.AssertionError: No compressed files found > at org.junit.Assert.fail(Assert.java:88) > at org.junit.Assert.assertTrue(Assert.java:41) > at > org.apache.logging.log4j.core.appender.rolling.RollingAppenderTimeTest.testAppender(RollingAppenderTimeTest.java:76) > > On May 17, 2014, at 10:47 PM, Ralph Goers <[email protected]> > wrote: > > Please revert this change. It now occasionally fails on my machine. The > reason for the loop is to avoid those failures. > > Ralph > > On May 17, 2014, at 9:00 AM, [email protected] wrote: > > Author: rpopma > Date: Sat May 17 16:00:06 2014 > New Revision: 1595502 > > URL: http://svn.apache.org/r1595502 > Log: > performance improvement: reduce to a single sleep() long enough to trigger > a rollover (speedup from 11 to 2.3 seconds) > > Modified: > > > logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java > > Modified: > logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java > URL: > http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java?rev=1595502&r1=1595501&r2=1595502&view=diff > > ============================================================================== > --- > logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java > (original) > +++ > logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java > Sat May 17 16:00:06 2014 > @@ -58,12 +58,10 @@ public class RollingAppenderTimeTest { > > @Test > public void testAppender() throws Exception { > - for (int i=0; i < 100; ++i) { > - if (i % 11 == 0) { > - Thread.sleep(1000); > - } > - logger.debug("This is test message number " + i); > - } > + logger.debug("This is test message number 1"); > + Thread.sleep(1500); > + logger.debug("This is test message number 2"); > + > final File dir = new File(DIR); > assertTrue("Directory not created", dir.exists() && > dir.listFiles().length > 0); > final File[] files = dir.listFiles(); > > > > > >
