Skip to content

Commit

Permalink
add integration test for cross-region-access-enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
munendrasn committed Oct 5, 2024
1 parent ef5af04 commit 1072af2
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,29 @@ public void testNewInputStreamWithAccessPoint() throws Exception {
validateRead(s3FileIO);
}

@Test
public void testCrossRegionAccessEnabled() throws Exception {
clientFactory.initialize(
ImmutableMap.of(S3FileIOProperties.CROSS_REGION_ACCESS_ENABLED, "true"));
S3Client s3Client = clientFactory.s3();
String crossBucketObjectKey = String.format("%s/%s", prefix, UUID.randomUUID());
String crossBucketObjectUri =
String.format("s3://%s/%s", crossRegionBucketName, crossBucketObjectKey);
try {
s3Client.putObject(
PutObjectRequest.builder()
.bucket(crossRegionBucketName)
.key(crossBucketObjectKey)
.build(),
RequestBody.fromBytes(contentBytes));
// make a copy in cross-region bucket
S3FileIO s3FileIO = new S3FileIO(clientFactory::s3);
validateRead(s3FileIO, crossBucketObjectUri);
} finally {
AwsIntegTestUtil.cleanS3Bucket(s3Client, crossRegionBucketName, crossBucketObjectKey);
}
}

@Test
public void testNewInputStreamWithCrossRegionAccessPoint() throws Exception {
clientFactory.initialize(ImmutableMap.of(S3FileIOProperties.USE_ARN_REGION_ENABLED, "true"));
Expand Down Expand Up @@ -550,6 +573,10 @@ private void write(S3FileIO s3FileIO, String uri) throws Exception {
}

private void validateRead(S3FileIO s3FileIO) throws Exception {
validateRead(s3FileIO, objectUri);
}

private void validateRead(S3FileIO s3FileIO, String objectUri) throws Exception {
InputFile file = s3FileIO.newInputFile(objectUri);
assertThat(file.getLength()).isEqualTo(contentBytes.length);
try (InputStream stream = file.newStream()) {
Expand Down

0 comments on commit 1072af2

Please sign in to comment.