Skip to content
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

Update PagedDoraWorkerTest.java #18050

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@
import alluxio.grpc.CreateDirectoryPOptions;
import alluxio.grpc.CreateFilePOptions;
import alluxio.grpc.DeletePOptions;
import alluxio.grpc.ExistsPOptions;
import alluxio.grpc.FileInfo;
import alluxio.grpc.FileSystemMasterCommonPOptions;
import alluxio.grpc.GetStatusPOptions;
import alluxio.grpc.ListStatusPOptions;
import alluxio.grpc.LoadFileFailure;
import alluxio.grpc.RenamePOptions;
import alluxio.grpc.Route;
import alluxio.grpc.RouteFailure;
import alluxio.grpc.SetAttributePOptions;
Expand Down Expand Up @@ -752,4 +754,35 @@ private void createDummyFile(File testFile, int length) throws Exception {
mWorker.completeFile(testFile.getPath(), CompleteFilePOptions.getDefaultInstance(),
handle.getUUID().toString());
}

@Test
public void testExists() throws Exception {
File rootFolder = mTestFolder.newFolder("root");
String rootPath = rootFolder.getAbsolutePath();
assertTrue(mWorker.exists(rootPath, ExistsPOptions.getDefaultInstance()));
String fileContent = "foobar";
File f = mTestFolder.newFile("root/f");
Files.write(f.toPath(), fileContent.getBytes());
assertTrue(mWorker.exists(f.getAbsolutePath(), ExistsPOptions.getDefaultInstance()));
mWorker.delete(f.getAbsolutePath(), DeletePOptions.getDefaultInstance());
assertFalse(mWorker.exists(f.getAbsolutePath(), ExistsPOptions.getDefaultInstance()));
mWorker.delete(rootPath, DeletePOptions.getDefaultInstance());
assertFalse(mWorker.exists(rootPath, ExistsPOptions.getDefaultInstance()));
}

@Test
public void testRename() throws IOException, AccessControlException {
File srcFolder = mTestFolder.newFolder("root");
String rootPath = srcFolder.getAbsolutePath();
mWorker.rename(rootPath, rootPath + "2", RenamePOptions.getDefaultInstance());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use PathUtils.concatPath() instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok,I wil

assertFalse(mWorker.exists(rootPath, ExistsPOptions.getDefaultInstance()));
assertTrue(mWorker.exists(rootPath + "2", ExistsPOptions.getDefaultInstance()));
String fileContent = "foobar";
File f = mTestFolder.newFile("root2/f");
Files.write(f.toPath(), fileContent.getBytes());
mWorker.rename(f.getAbsolutePath(), f.getAbsolutePath() + "2",
RenamePOptions.getDefaultInstance());
assertFalse(mWorker.exists(f.getAbsolutePath(), ExistsPOptions.getDefaultInstance()));
assertTrue(mWorker.exists(f.getAbsolutePath() + "2", ExistsPOptions.getDefaultInstance()));
}
}
Loading