You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "raju-balpande (via GitHub)" <gi...@apache.org> on 2024/02/01 06:04:07 UTC
[PR] HDDS-10165. Replace GenericTestUtils temp dirs with `@TempDir` in ozone unit tests [ozone]
raju-balpande opened a new pull request, #6142:
URL: https://github.com/apache/ozone/pull/6142
## What changes were proposed in this pull request?
Replace usage of GenericTestUtils test/temp dir methods with @TempDir in hadoop-ozone except in integration tests.
(see parent task [HDDS-9103](https://issues.apache.org/jira/browse/HDDS-9103) for details)
## 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-10165. Replace GenericTestUtils temp dirs with `@TempDir` in ozone unit tests [ozone]
Posted by "raju-balpande (via GitHub)" <gi...@apache.org>.
raju-balpande commented on code in PR #6142:
URL: https://github.com/apache/ozone/pull/6142#discussion_r1474371289
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHttpServer.java:
##########
@@ -64,16 +64,14 @@ public static Collection<Object[]> policy() {
}
@BeforeAll public static void setUp() throws Exception {
- File base = new File(BASEDIR);
Review Comment:
Done. thanks.
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/security/TestOzoneTokenIdentifier.java:
##########
@@ -282,9 +248,9 @@ public void testSymmetricTokenPerfHelper(String hmacAlgorithm, int keyLen) {
* Test serialization/deserialization of OzoneTokenIdentifier.
*/
@Test
- public void testReadWriteInProtobuf() throws IOException {
+ public void testReadWriteInProtobuf(@TempDir Path baseDir) throws IOException {
OzoneTokenIdentifier id = getIdentifierInst();
- File idFile = new File(BASEDIR + "/tokenFile");
+ File idFile = baseDir.resolve("/tokenFile").toFile();
Review Comment:
Done. thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-10165. Replace GenericTestUtils temp dirs with `@TempDir` in ozone unit tests [ozone]
Posted by "raju-balpande (via GitHub)" <gi...@apache.org>.
raju-balpande commented on code in PR #6142:
URL: https://github.com/apache/ozone/pull/6142#discussion_r1474370753
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestKeyManagerUnit.java:
##########
@@ -105,7 +104,6 @@ public class TestKeyManagerUnit {
private KeyManagerImpl keyManager;
private Instant startDate;
- private File testDir;
Review Comment:
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-10165. Replace GenericTestUtils temp dirs with `@TempDir` in ozone unit tests [ozone]
Posted by "raju-balpande (via GitHub)" <gi...@apache.org>.
raju-balpande commented on code in PR #6142:
URL: https://github.com/apache/ozone/pull/6142#discussion_r1474372114
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshotManager.java:
##########
@@ -95,9 +95,9 @@ public class TestOmSnapshotManager {
private File f1File;
@BeforeEach
- public void init() throws Exception {
+ public void init(@TempDir Path pathTestDir) throws Exception {
OzoneConfiguration configuration = new OzoneConfiguration();
- testDir = GenericTestUtils.getRandomizedTestDir();
+ testDir = pathTestDir.toFile();
Review Comment:
Done. thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-10165. Replace GenericTestUtils temp dirs with `@TempDir` in ozone unit tests [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on PR #6142:
URL: https://github.com/apache/ozone/pull/6142#issuecomment-1921273397
```
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshotManager.java
210: 'testDir' hides a field.
361: 'testDir' hides a field.
452: 'testDir' hides a field.
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/security/acl/TestVolumeOwner.java
39: Unused import - org.apache.hadoop.security.authentication.client.AuthenticationException.
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/security/acl/TestParentAcl.java
46: Unused import - org.apache.hadoop.security.authentication.client.AuthenticationException.
```
https://github.com/raju-balpande/apache_ozone/actions/runs/7741058283/job/21107319150
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-10165. Replace GenericTestUtils temp dirs with `@TempDir` in ozone unit tests [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #6142:
URL: https://github.com/apache/ozone/pull/6142#discussion_r1473997193
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHttpServer.java:
##########
@@ -64,16 +64,14 @@ public static Collection<Object[]> policy() {
}
@BeforeAll public static void setUp() throws Exception {
- File base = new File(BASEDIR);
Review Comment:
Here we can minimize change by adding `@TempDir File base` as parameter, instead of adding a member variable.
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshotManager.java:
##########
@@ -95,9 +95,9 @@ public class TestOmSnapshotManager {
private File f1File;
@BeforeEach
- public void init() throws Exception {
+ public void init(@TempDir Path pathTestDir) throws Exception {
OzoneConfiguration configuration = new OzoneConfiguration();
- testDir = GenericTestUtils.getRandomizedTestDir();
+ testDir = pathTestDir.toFile();
Review Comment:
`testDir` can be annotated directly, then we don't need the parameter and the assignment.
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestKeyManagerUnit.java:
##########
@@ -105,7 +104,6 @@ public class TestKeyManagerUnit {
private KeyManagerImpl keyManager;
private Instant startDate;
- private File testDir;
Review Comment:
We can keep and annotate it, instead of adding parameter.
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/security/TestOzoneTokenIdentifier.java:
##########
@@ -282,9 +248,9 @@ public void testSymmetricTokenPerfHelper(String hmacAlgorithm, int keyLen) {
* Test serialization/deserialization of OzoneTokenIdentifier.
*/
@Test
- public void testReadWriteInProtobuf() throws IOException {
+ public void testReadWriteInProtobuf(@TempDir Path baseDir) throws IOException {
OzoneTokenIdentifier id = getIdentifierInst();
- File idFile = new File(BASEDIR + "/tokenFile");
+ File idFile = baseDir.resolve("/tokenFile").toFile();
Review Comment:
I think test failure is caused by `/tokenFile` being resolved as absolute path, not a child of `baseDir`.
```suggestion
File idFile = baseDir.resolve("tokenFile").toFile();
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-10165. Replace GenericTestUtils temp dirs with `@TempDir` in ozone unit tests [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai merged PR #6142:
URL: https://github.com/apache/ozone/pull/6142
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-10165. Replace GenericTestUtils temp dirs with `@TempDir` in ozone unit tests [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on PR #6142:
URL: https://github.com/apache/ozone/pull/6142#issuecomment-1920722058
Thanks @raju-balpande for working on this.
There are some conflicts, please merge from `master`.
Also, one unit test failure looks related:
```
Error: Tests run: 6, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.059 s <<< FAILURE! - in org.apache.hadoop.ozone.security.TestOzoneTokenIdentifier
Error: org.apache.hadoop.ozone.security.TestOzoneTokenIdentifier.testReadWriteInProtobuf(Path) Time elapsed: 0.064 s <<< ERROR!
java.io.FileNotFoundException: /tokenFile (Permission denied)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:162)
at org.apache.hadoop.ozone.security.TestOzoneTokenIdentifier.testReadWriteInProtobuf(TestOzoneTokenIdentifier.java:255)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-10165. Replace GenericTestUtils temp dirs with `@TempDir` in ozone unit tests [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on PR #6142:
URL: https://github.com/apache/ozone/pull/6142#issuecomment-1921853657
Thanks @raju-balpande for the patch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org