Skip to content

Commit

Permalink
add unit test for S3PinotFS move operation (apache#13608)
Browse files Browse the repository at this point in the history
  • Loading branch information
sullis authored and rajagopr committed Jul 17, 2024
1 parent 7bb192f commit 394492f
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,37 @@ public void testMkdir()
Assert.assertTrue(headObjectResponse.sdkHttpResponse().isSuccessful());
}

@Test
public void testMoveFile()
throws Exception {

String fileName = "file-to-move";
int fileSize = 5000;

File file = new File(TEMP_FILE, fileName);

try {
createDummyFile(file, fileSize);
URI sourceUri = URI.create(String.format(FILE_FORMAT, SCHEME, BUCKET, fileName));

_s3PinotFS.copyFromLocalFile(file, sourceUri);

URI targetUri = URI.create(String.format(FILE_FORMAT, SCHEME, BUCKET, "move-target"));

boolean moveResult = _s3PinotFS.move(sourceUri, targetUri, false);
Assert.assertTrue(moveResult);

Assert.assertFalse(_s3PinotFS.exists(sourceUri));
Assert.assertTrue(_s3PinotFS.exists(targetUri));

HeadObjectResponse headObjectResponse =
_s3Client.headObject(S3TestUtils.getHeadObjectRequest(BUCKET, "move-target"));
Assert.assertEquals(headObjectResponse.contentLength(), fileSize);
} finally {
FileUtils.deleteQuietly(file);
}
}

private static void createDummyFile(File file, int size)
throws IOException {
FileUtils.deleteQuietly(file);
Expand Down

0 comments on commit 394492f

Please sign in to comment.