danielcweeks commented on a change in pull request #1900: URL: https://github.com/apache/iceberg/pull/1900#discussion_r540588604
########## File path: aws/src/integration/java/org/apache/iceberg/aws/s3/S3MultipartUploadTest.java ########## @@ -0,0 +1,192 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iceberg.aws.s3; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Random; +import java.util.UUID; +import java.util.stream.IntStream; +import org.apache.iceberg.aws.AwsClientUtil; +import org.apache.iceberg.aws.AwsIntegTestUtil; +import org.apache.iceberg.aws.AwsProperties; +import org.apache.iceberg.io.InputFile; +import org.apache.iceberg.io.PositionOutputStream; +import org.apache.iceberg.io.SeekableInputStream; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import software.amazon.awssdk.services.s3.S3Client; + +/** + * Long-running tests to ensure multipart upload logic is resilient + */ +public class S3MultipartUploadTest { + + private final Random random = new Random(1); + private static S3Client s3; + private static String bucketName; + private static String prefix; + private String objectUri; + + @BeforeClass + public static void beforeClass() { + s3 = AwsClientUtil.defaultS3Client(); + bucketName = AwsIntegTestUtil.testBucketName(); + prefix = UUID.randomUUID().toString(); + } + + @AfterClass + public static void afterClass() { + AwsIntegTestUtil.cleanS3Bucket(s3, bucketName, prefix); + } + + @Before + public void before() { + String objectKey = String.format("%s/%s", prefix, UUID.randomUUID().toString()); + objectUri = String.format("s3://%s/%s", bucketName, objectKey); + } + + @Test + public void testManyParts_writeWithInt() throws IOException { + AwsProperties properties = new AwsProperties(); + properties.setS3FileIoMultiPartSize(AwsProperties.S3FILEIO_MULTIPART_SIZE_MIN); + S3FileIO io = new S3FileIO(() -> s3, properties); + PositionOutputStream outputStream = io.newOutputFile(objectUri).create(); + for (int i = 0; i < 100; i++) { Review comment: No, I just mixed up this test and the next one and missed the inner loop here. However, you might be able to combine some of the upload and content validation into a single test, but it looks like you already have some thoughts on it, so I'll wait. I guess there's two minor questions I have: 1) Is it reasonable to be creating large files in S3 as part of the integration test (I'm not clear on if we run these as part of our actual build or it's left up to users to run in their own accounts). 2) Are there cases where we think the s3mock wouldn't catch something that these tests would? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
