|
24 | 24 | import java.util.HashMap;
|
25 | 25 | import java.util.Map;
|
26 | 26 | import java.util.concurrent.CancellationException;
|
| 27 | +import java.util.concurrent.TimeUnit; |
27 | 28 | import org.apache.commons.lang3.RandomStringUtils;
|
28 | 29 | import org.junit.jupiter.api.AfterAll;
|
29 | 30 | import org.junit.jupiter.api.BeforeAll;
|
| 31 | +import org.junit.jupiter.api.Test; |
| 32 | +import org.junit.jupiter.api.Timeout; |
30 | 33 | import org.junit.jupiter.params.ParameterizedTest;
|
31 | 34 | import org.junit.jupiter.params.provider.MethodSource;
|
32 | 35 | import software.amazon.awssdk.core.ResponseInputStream;
|
33 | 36 | import software.amazon.awssdk.core.async.AsyncRequestBody;
|
34 | 37 | import software.amazon.awssdk.core.internal.async.FileAsyncRequestBody;
|
35 | 38 | import software.amazon.awssdk.core.sync.ResponseTransformer;
|
| 39 | +import software.amazon.awssdk.services.s3.S3AsyncClient; |
36 | 40 | import software.amazon.awssdk.services.s3.model.ChecksumAlgorithm;
|
37 | 41 | import software.amazon.awssdk.services.s3.model.GetObjectResponse;
|
38 | 42 | import software.amazon.awssdk.testutils.RandomTempFile;
|
@@ -93,6 +97,34 @@ void upload_file_SentCorrectly(S3TransferManager tm) throws IOException {
|
93 | 97 | assertListenerForSuccessfulTransferComplete(transferListener);
|
94 | 98 | }
|
95 | 99 |
|
| 100 | + // This is a test for an issue where the file upload hangs (no chunk |
| 101 | + // uploads are initiated) if apiCallBufferSizeInBytes is less than the |
| 102 | + // publisher chunk size. |
| 103 | + // Note: Only applicable to the Java based TM because file uploads are |
| 104 | + // done completely by CRT for the CRT based transfer manager, and does |
| 105 | + // not hit the same code path. |
| 106 | + @Test |
| 107 | + @Timeout(value = 10, unit = TimeUnit.MINUTES) |
| 108 | + public void uploadFile_apiBufferSizeLessThanFileAsyncPublisherChunkSize_sentCorrectly() { |
| 109 | + try ( |
| 110 | + S3AsyncClient s3Async = s3AsyncClientBuilder() |
| 111 | + .multipartConfiguration(c -> c.apiCallBufferSizeInBytes(SizeConstant.KB)) |
| 112 | + .build(); |
| 113 | + |
| 114 | + S3TransferManager tm = S3TransferManager.builder() |
| 115 | + .s3Client(s3Async) |
| 116 | + .build(); |
| 117 | + ) { |
| 118 | + FileUpload fileUpload = |
| 119 | + tm.uploadFile(u -> u.putObjectRequest(p -> p.bucket(TEST_BUCKET) |
| 120 | + .key(TEST_KEY)) |
| 121 | + .source(testFile.toPath()) |
| 122 | + .build()); |
| 123 | + |
| 124 | + fileUpload.completionFuture().join(); |
| 125 | + } |
| 126 | + } |
| 127 | + |
96 | 128 | private static void assertListenerForSuccessfulTransferComplete(CaptureTransferListener transferListener) {
|
97 | 129 | assertThat(transferListener.isTransferInitiated()).isTrue();
|
98 | 130 | assertThat(transferListener.isTransferComplete()).isTrue();
|
|
0 commit comments