-
Notifications
You must be signed in to change notification settings - Fork 590
HDDS-10165. Replace GenericTestUtils temp dirs with @TempDir in ozone unit tests
#6142
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
Conversation
|
Thanks @raju-balpande for working on this. There are some conflicts, please merge from Also, one unit test failure looks related: (Please use code formatting (enclose in `) for |
| public void init(@TempDir Path pathTestDir) throws Exception { | ||
| OzoneConfiguration configuration = new OzoneConfiguration(); | ||
| testDir = GenericTestUtils.getRandomizedTestDir(); | ||
| testDir = pathTestDir.toFile(); |
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.
testDir can be annotated directly, then we don't need the parameter and the assignment.
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.
Done. thanks.
| private KeyManagerImpl keyManager; | ||
|
|
||
| private Instant startDate; | ||
| private File testDir; |
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.
We can keep and annotate it, instead of adding parameter.
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 is not used anywhere else hence added as a parameter instead of keeping as instance variable. It is also removed from the method cleanup.
| @BeforeAll public static void setUp() throws Exception { | ||
| File base = new File(BASEDIR); |
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.
Here we can minimize change by adding @TempDir File base as parameter, instead of adding a member variable.
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.
Done. thanks.
| public void testReadWriteInProtobuf(@TempDir Path baseDir) throws IOException { | ||
| OzoneTokenIdentifier id = getIdentifierInst(); | ||
| File idFile = new File(BASEDIR + "/tokenFile"); | ||
| File idFile = baseDir.resolve("/tokenFile").toFile(); |
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 think test failure is caused by /tokenFile being resolved as absolute path, not a child of baseDir.
| File idFile = baseDir.resolve("/tokenFile").toFile(); | |
| File idFile = baseDir.resolve("tokenFile").toFile(); |
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.
Done. thanks.
|
|
Thanks @raju-balpande for the patch. |
What changes were proposed in this pull request?
Replace usage of GenericTestUtils test/temp dir methods with
@TempDirin hadoop-ozone except in integration tests.(see parent task HDDS-9103 for details)
@TempDirvariable in some cases.@TempDirat one location because the directory was shared among directories.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-10165
How was this patch tested?
Tested in CI-CI pipeline and a few manually.