Skip to content
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

Merged
merged 1 commit into from
Aug 28, 2024

Conversation

gtroitsk
Copy link
Member

@gtroitsk gtroitsk commented Aug 25, 2024

Summary

Verifies issue quarkusio/quarkus#40016

Please select the relevant options.

  • Bug fix (non-breaking change which fixes an issue)
  • Dependency update
  • Refactoring
  • Backport
  • New scenario (non-breaking change which adds functionality)
  • This change requires a documentation update
  • This change requires execution against OCP (use run tests phrase in comment)

Checklist:

  • Methods and classes used in PR scenarios are meaningful
  • Commits are well encapsulated and follow the best practices

@gtroitsk gtroitsk requested a review from jedla97 August 25, 2024 22:04
@jedla97
Copy link
Member

jedla97 commented Aug 26, 2024

@gtroitsk It's look good to me! Just would be better also checking if the file is created with that suffix?

@michalvavrik
Copy link
Member

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

Copy link
Member

@michalvavrik michalvavrik left a 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.

@gtroitsk gtroitsk marked this pull request as draft August 26, 2024 16:28
@gtroitsk gtroitsk force-pushed the verify-log-file-rotation branch 3 times, most recently from e98b116 to ac1ea5f Compare August 27, 2024 19:32
@gtroitsk gtroitsk marked this pull request as ready for review August 27, 2024 19:33
@gtroitsk gtroitsk requested a review from michalvavrik August 27, 2024 19:36
@github-actions github-actions bot added the triage/flaky-test Signal that flaky tests were detected during CI run label Aug 27, 2024
Copy link

Following jobs contain at least one flaky test: 'PR - Linux - JVM build - Latest Version'

throw new UncheckedIOException(e);
}
})
.anyMatch(line -> line.contains(EXPECTED_LOG_MESSAGE));
Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member

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.

@michalvavrik
Copy link
Member

michalvavrik commented Aug 28, 2024

@gtroitsk it looks good, I still think you could refactor it bit, but please consider it rather unimportant.

@gtroitsk gtroitsk force-pushed the verify-log-file-rotation branch 2 times, most recently from e1262c6 to ce56d26 Compare August 28, 2024 08:50

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;
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

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

Copy link
Member

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

Copy link
Member

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

Copy link
Member

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.");
Copy link
Member

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

Copy link

Following jobs contain at least one flaky test: 'PR - Linux - JVM build - Latest Version'

@gtroitsk gtroitsk force-pushed the verify-log-file-rotation branch from ce56d26 to 1b79f2e Compare August 28, 2024 12:11
Copy link
Member

@jedla97 jedla97 left a 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.

Copy link

Following jobs contain at least one flaky test: 'PR - Linux - JVM build - Latest Version'

@gtroitsk gtroitsk force-pushed the verify-log-file-rotation branch from 1b79f2e to f1c9939 Compare August 28, 2024 13:03
Copy link
Member

@jedla97 jedla97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for changes

Copy link

Following jobs contain at least one flaky test: 'PR - Linux - JVM build - Latest Version'

@michalvavrik
Copy link
Member

The flaky test is related to Kafka.

@michalvavrik michalvavrik merged commit 538724d into quarkus-qe:main Aug 28, 2024
14 checks passed
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.");
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants