[hotfix]Harden TextInputFormatTest to avoid failure by uncleaned files#8304
[hotfix]Harden TextInputFormatTest to avoid failure by uncleaned files#8304zentol merged 2 commits intoapache:masterfrom
Conversation
|
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community Review Progress
Please see the Pull Request Review Guide for a full explanation of the review process. DetailsThe Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commandsThe @flinkbot bot supports the following commands:
|
|
And I see there are quite a lot other tests rely on |
zentol
left a comment
There was a problem hiding this comment.
the cleanup isn't really the problem; you cannot ensure 100% that files are deleted. The real issue here is testNestedFileRead using constant paths.
| private final String tempDirName = "tempDir"; | ||
|
|
||
| @Before | ||
| public void setUp() throws IOException { |
There was a problem hiding this comment.
use a TemporaryFolder instead
There was a problem hiding this comment.
Seems better, I will change it then. But a little question, why my approach can not ensure the file cleaned (I check and clean the related file before execute and after test method), Thanks.
There was a problem hiding this comment.
if the JVM crashes before the delete calls are executed the files will remain.
|
I update the PR, please take a look when you are free, thanks @zentol |
What is the purpose of the change
When I run test locally, it happened to failed and with the uncleaned temp file leaving in the tmp dir. So the test case can not pass ever until i delete the correspond files.
It use
deleteOnExitto clean up the temp file created by test case, But the method may not work when JVM crash or killed. I think it may make the test case fragile.Brief change log
Add the @before and @after prepare / cleanup method