-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Verify log file rotation for periods longer than day #1946
Verify log file rotation for periods longer than day #1946
Conversation
@gtroitsk It's look good to me! Just would be better also checking if the file is created with that suffix? |
Let's go further, let's check content as it adds better coverage while this is very much like unit test. IMHO we don't want to test isolated bugs if we can have something similar to what users do. And if they enable logging to file, they are likely to desire there is a content. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to my previous comment, also please rebase on current main to fix CI.
e98b116
to
ac1ea5f
Compare
logging/jboss/src/test/java/io/quarkus/ts/logging/jboss/DefaultMinLogLevelIT.java
Outdated
Show resolved
Hide resolved
logging/jboss/src/test/java/io/quarkus/ts/logging/jboss/DefaultMinLogLevelIT.java
Show resolved
Hide resolved
Following jobs contain at least one flaky test: 'PR - Linux - JVM build - Latest Version' |
ac1ea5f
to
e08ae96
Compare
throw new UncheckedIOException(e); | ||
} | ||
}) | ||
.anyMatch(line -> line.contains(EXPECTED_LOG_MESSAGE)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this succeeds if at least one of the files has expected line, I don't know how many files you expect. We have io.quarkus.test.utils.FileUtils
, have you considered using them to cut the verbosity (try catches etc.)? I'd expect using io.quarkus.test.utils.FileUtils#findTargetFile(java.nio.file.Path, java.lang.String)
and io.quarkus.test.utils.FileUtils#loadFile(java.lang.String)
would cut your code to three lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect 3 files according to configuration. Check if each of rotated files contain the log message now use FileUtils.loadFile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, 3? in that case previous check was incorrect because you didn't check that each file contains that line. You did test that any did. I'll comment elsewhere on this expectation.
@gtroitsk it looks good, I still think you could refactor it bit, but please consider it rather unimportant. |
e1262c6
to
ce56d26
Compare
|
||
Awaitility.await().atMost(10, TimeUnit.SECONDS).until(() -> { | ||
File[] rotatedFiles = logDir.toFile().listFiles((dir, name) -> name.startsWith(LOG_FILE_NAME)); | ||
return rotatedFiles != null && rotatedFiles.length > 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, so, you expect 3 files but are content with finding one? I understood your comment that you want to find this line in 3 files, so I expect you need 3 files. Won't the test be flaky if you wait just for one and hope others are stored in the meanwhile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tbh I don't think it was wrong as with backup logs you can't know how many will be there. Someone can update quarkus.log.file.rotation.max-file-size
and this test can have only one backup log.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, that is not acceptable; someone cannot just update max-file-size
because this is part of the test; if he updates it, the test must fail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jedla97 configuration properties are either required for test in their current value to test a feature, or we should drop them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I played with it before review and the test failed. But there can be value where the test will pass. Anyway the test is updated to check for maximum number of files so it should be fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I have no idea whether this test is stable. I commented on changing property for no reason. by looking at this test I think it is weird I don't understand why it is separated to 3 files and max-file-size refers to memory size, not lines. I somehow expected @gtroitsk have it worked out :-)
List<Path> rotatedFiles = Files.list(logDir) | ||
.filter(path -> path.getFileName().toString().matches(LOG_FILE_NAME + expectedSuffix)).toList(); | ||
|
||
assertFalse(rotatedFiles.isEmpty(), "Rotated log file with expected suffix not found."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like you are looking for single file...
Following jobs contain at least one flaky test: 'PR - Linux - JVM build - Latest Version' |
ce56d26
to
1b79f2e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just have two minor comments in this last update.
logging/jboss/src/test/java/io/quarkus/ts/logging/jboss/DefaultMinLogLevelIT.java
Outdated
Show resolved
Hide resolved
Following jobs contain at least one flaky test: 'PR - Linux - JVM build - Latest Version' |
1b79f2e
to
f1c9939
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for changes
Following jobs contain at least one flaky test: 'PR - Linux - JVM build - Latest Version' |
The flaky test is related to Kafka. |
List<Path> rotatedFiles = Files.list(logDir) | ||
.filter(path -> path.getFileName().toString().matches(LOG_FILE_NAME + expectedSuffix)).toList(); | ||
|
||
assertFalse(rotatedFiles.isEmpty(), "Rotated log files with expected suffix were not found."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For record @jedla97 , I still think this condition doesn't make sense. First there is waiting for max-backup-index
+ 1=3 and now it's satisfied with 1
Summary
Verifies issue quarkusio/quarkus#40016
Please select the relevant options.
run tests
phrase in comment)Checklist: