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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to