Skip to content

Commit 5dfd7f4

Browse files
committed
add integration test for cross-region-access-enabled
1 parent ef5af04 commit 5dfd7f4

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

aws/src/integration/java/org/apache/iceberg/aws/s3/TestS3FileIOIntegration.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,29 @@ public void testNewInputStreamWithAccessPoint() throws Exception {
182182
validateRead(s3FileIO);
183183
}
184184

185+
@Test
186+
public void testCrossRegionAccessEnabled() throws Exception {
187+
clientFactory.initialize(
188+
ImmutableMap.of(S3FileIOProperties.CROSS_REGION_ACCESS_ENABLED, "true"));
189+
S3Client s3Client = clientFactory.s3();
190+
String crossBucketObjectKey = String.format("%s/%s", prefix, UUID.randomUUID());
191+
String crossBucketObjectUri =
192+
String.format("s3://%s/%s", crossRegionBucketName, crossBucketObjectKey);
193+
try {
194+
s3Client.putObject(
195+
PutObjectRequest.builder()
196+
.bucket(crossRegionBucketName)
197+
.key(crossBucketObjectKey)
198+
.build(),
199+
RequestBody.fromBytes(contentBytes));
200+
// make a copy in cross-region bucket
201+
S3FileIO s3FileIO = new S3FileIO(clientFactory::s3);
202+
validateRead(s3FileIO, crossBucketObjectUri);
203+
} finally {
204+
AwsIntegTestUtil.cleanS3Bucket(s3Client, crossRegionBucketName, crossBucketObjectKey);
205+
}
206+
}
207+
185208
@Test
186209
public void testNewInputStreamWithCrossRegionAccessPoint() throws Exception {
187210
clientFactory.initialize(ImmutableMap.of(S3FileIOProperties.USE_ARN_REGION_ENABLED, "true"));
@@ -550,7 +573,11 @@ private void write(S3FileIO s3FileIO, String uri) throws Exception {
550573
}
551574

552575
private void validateRead(S3FileIO s3FileIO) throws Exception {
553-
InputFile file = s3FileIO.newInputFile(objectUri);
576+
validateRead(s3FileIO, objectUri);
577+
}
578+
579+
private void validateRead(S3FileIO s3FileIO, String s3Uri) throws Exception {
580+
InputFile file = s3FileIO.newInputFile(s3Uri);
554581
assertThat(file.getLength()).isEqualTo(contentBytes.length);
555582
try (InputStream stream = file.newStream()) {
556583
String result = IoUtils.toUtf8String(stream);

0 commit comments

Comments
 (0)