Skip to content

Commit d36c110

Browse files
authored
Merge pull request #4476 from aws/dongie/revert-s3-integ
Revert "Fix flaky pauseAndResume_ObjectNotChanged_shouldResumeDownloa…
2 parents 7054a9c + 5fd37b6 commit d36c110

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

services-custom/s3-transfer-manager/src/it/java/software/amazon/awssdk/transfer/s3/S3TransferManagerDownloadPauseResumeIntegrationTest.java

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.nio.file.Path;
2828
import java.time.Duration;
2929
import java.util.Optional;
30-
import java.util.concurrent.atomic.AtomicLong;
3130
import org.apache.commons.lang3.RandomStringUtils;
3231
import org.apache.logging.log4j.Level;
3332
import org.assertj.core.api.Assertions;
@@ -152,11 +151,8 @@ void pauseAndResume_ObjectNotChanged_shouldResumeDownload(S3TransferManager tm)
152151
assertEqualsBySdkFields(resumableFileDownload.downloadFileRequest(), request);
153152
assertThat(testDownloadListener.getObjectResponse).isNotNull();
154153

155-
// wait to give CRT client time to write last bytes to file if any
156-
long actualInProgressFileSize = waitUntilFileSizeStable(path);
157-
158154
// Skip the test if everything has been downloaded.
159-
Assumptions.assumeTrue(actualInProgressFileSize < sourceFile.length());
155+
Assumptions.assumeTrue(resumableFileDownload.bytesTransferred() < sourceFile.length());
160156

161157
assertThat(resumableFileDownload.s3ObjectLastModified()).hasValue(testDownloadListener.getObjectResponse.lastModified());
162158
// Request may not be cancelled right away when pause is invoked, so there may be more bytes written to the file
@@ -166,7 +162,7 @@ void pauseAndResume_ObjectNotChanged_shouldResumeDownload(S3TransferManager tm)
166162
assertThat(download.completionFuture()).isCancelled();
167163

168164
log.debug(() -> "Resuming download ");
169-
verifyFileDownload(path, resumableFileDownload, OBJ_SIZE - actualInProgressFileSize, tm);
165+
verifyFileDownload(path, resumableFileDownload, OBJ_SIZE - bytesTransferred, tm);
170166
}
171167

172168
private void assertEqualsBySdkFields(DownloadFileRequest actual, DownloadFileRequest expected) {
@@ -256,25 +252,6 @@ private static void waitUntilFirstByteBufferDelivered(FileDownload download) {
256252
waiter.run(() -> download.progress().snapshot());
257253
}
258254

259-
/**
260-
* CRT File downloads can continue to flush bytes to the file after pause. Wait until the file size is stable.
261-
*
262-
* @param file
263-
* @return the final file size
264-
*/
265-
private static long waitUntilFileSizeStable(Path file) {
266-
final AtomicLong fileSize = new AtomicLong(0L);
267-
Waiter<Path> waiter = Waiter.builder(Path.class)
268-
.addAcceptor(WaiterAcceptor.successOnResponseAcceptor(p -> file.toFile().length() == fileSize.getAndSet(file.toFile().length())))
269-
.addAcceptor(WaiterAcceptor.retryOnResponseAcceptor(r -> true))
270-
.overrideConfiguration(o -> o.waitTimeout(Duration.ofMinutes(1))
271-
.maxAttempts(Integer.MAX_VALUE)
272-
.backoffStrategy(FixedDelayBackoffStrategy.create(Duration.ofMillis(500))))
273-
.build();
274-
waiter.run(() -> file);
275-
return file.toFile().length();
276-
}
277-
278255
private static final class TestDownloadListener implements TransferListener {
279256
private int transferInitiatedCount = 0;
280257
private GetObjectResponse getObjectResponse;

0 commit comments

Comments
 (0)