From ba8f81b8415dc6dba258542fad1cc58ee6ce0b4d Mon Sep 17 00:00:00 2001 From: Ceki Gulcu Date: Fri, 4 Aug 2023 19:35:45 +0200 Subject: [PATCH] fix TimeBasedRollingWithConfigFileTest.timeAndSize Signed-off-by: Ceki Gulcu --- .../src/test/input/joran/rolling/timeAndSize.xml | 2 +- .../rolling/TimeBasedRollingWithConfigFileTest.java | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/logback-classic/src/test/input/joran/rolling/timeAndSize.xml b/logback-classic/src/test/input/joran/rolling/timeAndSize.xml index 2b71ae4857..f84b99e5fa 100644 --- a/logback-classic/src/test/input/joran/rolling/timeAndSize.xml +++ b/logback-classic/src/test/input/joran/rolling/timeAndSize.xml @@ -8,7 +8,7 @@ ${randomOutputDir}${testId}-%d{yyyy-MM-dd_HH_mm_ss}.%i - 25 + ${sizeThreshold} diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/rolling/TimeBasedRollingWithConfigFileTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/rolling/TimeBasedRollingWithConfigFileTest.java index 7ee4bf83d7..58fd8b8865 100755 --- a/logback-classic/src/test/java/ch/qos/logback/classic/rolling/TimeBasedRollingWithConfigFileTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/rolling/TimeBasedRollingWithConfigFileTest.java @@ -117,6 +117,7 @@ public void timeAndSize() throws Exception { int approxWritesPerPeriod = 64; sizeThreshold = prefix.length() * approxWritesPerPeriod; loggerContext.putProperty("sizeThreshold", "" + sizeThreshold); + System.out.println("timeAndSize.sizeThreshold="+sizeThreshold); loadConfig(ClassicTestConstants.JORAN_INPUT_PREFIX + "rolling/" + testId + ".xml"); StatusPrinter.print(loggerContext); @@ -135,7 +136,8 @@ public void timeAndSize() throws Exception { TimeBasedFileNamingAndTriggeringPolicy tbnatp = tprp.getTimeBasedFileNamingAndTriggeringPolicy(); int timeIncrement = 1000 / approxWritesPerPeriod; - int runLength = approxWritesPerPeriod * 3; + int targetPeriodCount = 3; + int runLength = approxWritesPerPeriod * targetPeriodCount; for (int i = 0; i < runLength; i++) { String msg = prefix + i; logger.debug(msg); @@ -149,7 +151,7 @@ public void timeAndSize() throws Exception { // for various reasons, it is extremely difficult to have the files // match exactly the expected archive files. Thus, we aim for // an approximate match - assertTrue(eCount >= 4 && eCount > expectedFilenameList.size() / 2, + assertTrue(eCount >= targetPeriodCount || eCount >= expectedFilenameList.size() / 2, "existenceCount=" + eCount + ", expectedFilenameList.size=" + expectedFilenameList.size()); } @@ -218,10 +220,10 @@ void addExpectedFileNamedIfItsTime(String testId, String msg, boolean gzExtensio void addExpectedFileName(String testId, Date date, int fileIndexCounter, boolean gzExtension) { String fn = randomOutputDir + testId + "-" + SDF.format(date) + "." + fileIndexCounter; - System.out.println("Adding " + fn); if (gzExtension) { fn += ".gz"; } + System.out.println("Adding " + fn); expectedFilenameList.add(fn); }