Skip to content

Commit 259c434

Browse files
authored
Fix flaky pause and resume tests (#6406)
1 parent 5011e5c commit 259c434

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.apache.logging.log4j.Level;
3232
import org.assertj.core.api.Assertions;
3333
import org.junit.jupiter.api.AfterAll;
34+
import org.junit.jupiter.api.Assumptions;
3435
import org.junit.jupiter.api.BeforeAll;
3536
import org.junit.jupiter.params.ParameterizedTest;
3637
import org.junit.jupiter.params.provider.MethodSource;
@@ -149,8 +150,13 @@ void pauseAndResume_ObjectNotChanged_shouldResumeDownload(S3TransferManager tm)
149150
log.debug(() -> "Paused: " + resumableFileDownload);
150151
assertEqualsBySdkFields(resumableFileDownload.downloadFileRequest(), request);
151152
assertThat(testDownloadListener.getObjectResponse).isNotNull();
153+
154+
// Skip the test if everything has been downloaded.
155+
Assumptions.assumeTrue(resumableFileDownload.bytesTransferred() < sourceFile.length());
156+
152157
assertThat(resumableFileDownload.s3ObjectLastModified()).hasValue(testDownloadListener.getObjectResponse.lastModified());
153-
assertThat(bytesTransferred).isEqualTo(path.toFile().length());
158+
// Request may not be cancelled right away when pause is invoked, so there may be more bytes written to the file
159+
assertThat(bytesTransferred).isLessThanOrEqualTo(path.toFile().length());
154160
assertThat(resumableFileDownload.totalSizeInBytes()).hasValue(sourceFile.length());
155161
assertThat(bytesTransferred).isLessThanOrEqualTo(sourceFile.length());
156162
assertThat(download.completionFuture()).isCancelled();

0 commit comments

Comments
 (0)