sreejasahithi commented on code in PR #10120:
URL: https://github.com/apache/ozone/pull/10120#discussion_r3145231604
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java:
##########
@@ -1731,45 +1731,36 @@ private void checkInvalidPath(Path path) {
@Test
void testRenameFile() throws Exception {
final String dir = "/dir" + RandomUtils.secure().randomInt(0, 1000);
- Path dirPath = new Path(getBucketPath() + dir);
- Path file1Source = new Path(getBucketPath() + dir
- + "/file1_Copy");
- Path file1Destin = new Path(getBucketPath() + dir + "/file1");
+ Path dirPath = pathUnderFsRoot(dir);
try {
- getFs().mkdirs(dirPath);
-
- ContractTestUtils.touch(getFs(), file1Source);
- assertTrue(getFs().rename(file1Source, file1Destin), "Renamed failed");
- assertTrue(getFs().exists(file1Destin), "Renamed failed: /dir/file1");
- FileStatus[] fStatus = getFs().listStatus(dirPath);
- assertEquals(1, fStatus.length, "Renamed failed");
+ renameFile(dir);
} finally {
// clean up
fs.delete(dirPath, true);
}
}
-
+ @Override
+ void verifyRenameFile(Path workDir, Path expectedDest) throws IOException {
+ FileStatus[] fStatus = getFs().listStatus(workDir);
+ assertEquals(1, fStatus.length, "Renamed failed");
+ }
/**
* Rename file to an existed directory.
*/
@Test
void testRenameFileToDir() throws Exception {
final String dir = "/dir" + RandomUtils.secure().randomInt(0, 1000);
- Path dirPath = new Path(getBucketPath() + dir);
- getFs().mkdirs(dirPath);
-
- Path file1Destin = new Path(getBucketPath() + dir + "/file1");
- ContractTestUtils.touch(getFs(), file1Destin);
- Path abcRootPath = new Path(getBucketPath() + "/a/b/c");
- getFs().mkdirs(abcRootPath);
- assertTrue(getFs().rename(file1Destin, abcRootPath), "Renamed failed");
- assertTrue(getFs().exists(new Path(
- abcRootPath, "file1")), "Renamed filed: /a/b/c/file1");
+ renameFileToDir(dir);
getFs().delete(getBucketPath(), true);
}
+ @Override
+ Path pathUnderFsRoot(String p) {
+ return new Path(getBucketPath() + p);
+ }
+
Review Comment:
Nit: parameter name does not convey any meaning , could you please change
this to adescriptive name like relativePath.
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTest.java:
##########
@@ -1136,16 +1115,12 @@ public void testRenameFile() throws Exception {
@Test
public void testRenameFileToDir() throws Exception {
final String root = "/root";
- Path rootPath = new Path(fs.getUri().toString() + root);
- fs.mkdirs(rootPath);
+ renameFileToDir(root);
+ }
- Path file1Destin = new Path(fs.getUri().toString() + root + "/file1");
- ContractTestUtils.touch(fs, file1Destin);
- Path abcRootPath = new Path(fs.getUri().toString() + "/a/b/c");
- fs.mkdirs(abcRootPath);
- assertTrue(fs.rename(file1Destin, abcRootPath), "Renamed failed");
- assertTrue(fs.exists(new Path(abcRootPath,
- "file1")), "Renamed filed: /a/b/c/file1");
+ @Override
+ protected Path pathUnderFsRoot(String p) {
+ return new Path(getFs().getUri().toString() + p);
Review Comment:
same here
--
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]