Russole commented on code in PR #10120:
URL: https://github.com/apache/ozone/pull/10120#discussion_r3143888041


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/OzoneFileSystemTestBase.java:
##########
@@ -473,6 +480,112 @@ void 
nonExplicitlyCreatedPathExistsAfterItsLeafsWereRemoved(Path root)
     fs.delete(source, true);
   }
 
+  void renameFile(String workDirFromFsRoot) throws Exception {
+    FileSystem fs = getFs();
+    Path workDir = pathUnderFsRoot(workDirFromFsRoot);
+    fs.mkdirs(workDir);
+
+    Path file1Source = pathUnderFsRoot(workDirFromFsRoot + "/file1_Copy");
+    Path file1Destin = pathUnderFsRoot(workDirFromFsRoot + "/file1");
+    ContractTestUtils.touch(fs, file1Source);
+    assertTrue(fs.rename(file1Source, file1Destin), "Renamed failed");
+    assertTrue(fs.exists(file1Destin), "Renamed failed");
+
+    verifyRenameFile(workDir, file1Destin);
+  }
+
+  void renameFileToDir(String workDirFromFsRoot) throws Exception {
+    FileSystem fs = getFs();
+    Path workDir = pathUnderFsRoot(workDirFromFsRoot);
+    fs.mkdirs(workDir);
+
+    Path file = pathUnderFsRoot(workDirFromFsRoot + "/file1");
+    ContractTestUtils.touch(fs, file);
+    Path targetDirTree = pathUnderFsRoot("/a/b/c");
+    fs.mkdirs(targetDirTree);
+    assertTrue(fs.rename(file, targetDirTree), "Renamed failed");
+    assertTrue(fs.exists(new Path(targetDirTree, "file1")), "Renamed failed: 
.../a/b/c/file1");
+  }
+
+  void renameToParentDir() throws Exception {
+    FileSystem fs = getFs();
+    final String root = "/root_dir";
+    final String dir1 = root + "/dir1";
+    final String dir2 = dir1 + "/dir2";
+    final Path dir2SourcePath = pathUnderFsRoot(dir2);
+    fs.mkdirs(dir2SourcePath);
+    final Path destRootPath = pathUnderFsRoot(root);
+
+    Path file1Source = pathUnderFsRoot(dir1 + "/file2");
+    ContractTestUtils.touch(fs, file1Source);
+
+    // rename source directory to its parent directory(destination).
+    assertTrue(fs.rename(dir2SourcePath, destRootPath), "Rename failed");
+    final Path expectedPathAfterRename =
+        pathUnderFsRoot(root + "/dir2");
+    assertTrue(fs.exists(expectedPathAfterRename), "Rename failed");
+
+    // rename source file to its parent directory(destination).
+    assertTrue(fs.rename(file1Source, destRootPath), "Rename failed");
+    final Path expectedFilePathAfterRename =
+        pathUnderFsRoot(root + "/file2");
+    assertTrue(fs.exists(expectedFilePathAfterRename), "Rename failed");
+  }
+
+  public void renameDirToItsOwnSubDir() throws Exception {

Review Comment:
   Nit: would it be better to keep this helper package-private, similar to the 
other rename helpers?
   ```suggestion
   void renameDirToItsOwnSubDir() throws Exception {
   ```



-- 
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