Skip to content

Commit 936494f

Browse files
committed
removing logging assertions for netty based transfer managers
1 parent b64302f commit 936494f

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

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

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@
2626
import java.nio.file.Files;
2727
import java.nio.file.Path;
2828
import java.time.Duration;
29-
import java.util.List;
3029
import java.util.Optional;
3130
import org.apache.commons.lang3.RandomStringUtils;
3231
import org.apache.logging.log4j.Level;
33-
import org.apache.logging.log4j.core.LogEvent;
32+
import org.assertj.core.api.Assertions;
3433
import org.junit.jupiter.api.AfterAll;
3534
import org.junit.jupiter.api.BeforeAll;
3635
import org.junit.jupiter.params.ParameterizedTest;
@@ -104,26 +103,31 @@ void pauseAndResume_ObjectEtagChange_shouldRestartDownload(S3TransferManager tm)
104103

105104
String newEtag = putResponse.eTag();
106105
assertThat(newEtag).isNotEqualTo(originalEtag);
107-
try (LogCaptor logCaptor = LogCaptor.create(Level.DEBUG)) {
108106

107+
boolean isCrtClient = tm.getClass().getName().contains("Crt");
108+
if (isCrtClient) {
109+
try (LogCaptor logCaptor = LogCaptor.create(Level.DEBUG)) {
110+
FileDownload resumedFileDownload = tm.resumeDownloadFile(resumableFileDownload);
111+
CompletedFileDownload completedDownload = resumedFileDownload.completionFuture().join();
112+
113+
assertThat(completedDownload.response().eTag()).isEqualTo(newEtag);
114+
assertThat(testDownloadListener.transferInitiatedCount == 2).isTrue();
115+
116+
Assertions.assertThat(logCaptor.loggedEvents())
117+
.anySatisfy(logEvent -> Assertions.assertThat(logEvent.getMessage().getFormattedMessage())
118+
.contains(String.format("The ETag of the requested object in bucket (%s) with key (%s) "
119+
+ "has changed since the last "
120+
+ "pause. The SDK will download the S3 object from "
121+
+ "the beginning",
122+
BUCKET, KEY)));
123+
}
124+
} else {
125+
// skip the log assertion for Netty because DEBUG level will log the entire byte stream and crash codebuild
109126
FileDownload resumedFileDownload = tm.resumeDownloadFile(resumableFileDownload);
110127
CompletedFileDownload completedDownload = resumedFileDownload.completionFuture().join();
111128

112129
assertThat(completedDownload.response().eTag()).isEqualTo(newEtag);
113130
assertThat(testDownloadListener.transferInitiatedCount == 2).isTrue();
114-
115-
List<LogEvent> logEvents = logCaptor.loggedEvents();
116-
StringBuilder sb = new StringBuilder();
117-
logEvents.forEach(logEvent -> {
118-
sb.append(logEvent.getMessage().getFormattedMessage());
119-
});
120-
121-
assertThat(sb)
122-
.contains(String.format("The ETag of the requested object in bucket (%s) with key (%s) "
123-
+ "has changed since the last "
124-
+ "pause. The SDK will download the S3 object from "
125-
+ "the beginning",
126-
BUCKET, KEY));
127131
}
128132
}
129133

0 commit comments

Comments
 (0)