-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
NIFI-13996 Improved removal of tmp file creation during build #9551
Conversation
…nit 5 Tempdir to allow for working on Windows.
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 working on improving the test behavior @dan-s1.
The failures on Windows indicate a process still using some files. This points to resources not closed, which appears to be a latent issue in some tests.
I plan to take a closer look soon, but Derby is particularly susceptible to this issue, so I recommend reviewing the behavior of other tests that use Derby.
@AfterAll | ||
public static void cleanUpAfterAll() { |
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.
It seems like this could be better as an AfterEach
method. Ideally, the Handler class would have the temporary directory as a parameter, but given the usage of createTempDirectory(), this style of expecting the system temporary seems reasonable.
… files in Junit 5 Tempdir in order to avoid a java.nio.file.DirectoryNotEmptyException.
@exceptionfactory Looking closer at the logs closer I noticed the following I then looked at the suppressed exception which was Some Google searching revealed
I therefore added code to manually delete the directories created under the Junit 5 tempdir. |
@exceptionfactory It seems that did not work as there is still that exception and the one you mentioned I understand now that is the main issue which is preventing the deletion which then prevents removing any top level directory. I am not sure why this would make a difference but I see many of the database test classes placing the Derby database under target (in the Maven build). |
Yes, this is where working with the lifecycle of the Derby database is essential to make things work as expected, versus just attempting to delete the directory contents. |
What are the Unix based operating systems doing different than Windows for this as they do not seem to exhibit the same issues? |
This reflects OS differences in file locking. |
…TestUpdateDatabaseTable does it.
… temp dir with the attempt to delete files after all tests completed.
@exceptionfactory Instead of Using JUnit @ TempDir, I ended up just writing to the system temp dir and then using Junit 5 @ AfterAll to delete the created directory. That seemed to be ok even on Windows. At you earliest convenience can you please review this PR again? Thanks! |
- Streamlined directory resolution for Excel tests
Thanks for the updates @dan-s1. Reviewing the changes locally, everything looked good except for the I also noticed the |
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.
All builds completed on the latest commit. Thanks again for this improvement @dan-s1, it is very helpful to avoid leaving temporary files around after a build. +1 merging
Summary
NIFI-13996
This PR aims to ensure the build does not leave around artifacts in a systems tmp directory. Two strategies were employed.
TempDir
annotation to allow Junit to handle the creation and deletion of temporary files .AfterAll
annotation to allow for globbing files using file patterns withjava.nio.file.Files.newDirectoryStream
and then deleting them.The one directory I could not delete was the
poifiles
directory created by all the Excel unit tests found in thenifi-poi-bundle
. When trying to delete that directory after each of those unit tests, it seemed to clobber thepoifiles
directory for each of the subsequent tests causing the unit tests to fail due to files not existing which thereby failed the build.Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000
NIFI-00000
Pull Request Formatting
main
branchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
mvn clean install -P contrib-check
Licensing
LICENSE
andNOTICE
filesDocumentation