-
Notifications
You must be signed in to change notification settings - Fork 916
Update tm builder log messages #3822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,5 +25,6 @@ | |
@SdkInternalApi | ||
public enum S3ClientType { | ||
CRT_BASED, | ||
JAVA_BASED | ||
JAVA_BASED, | ||
OTHER | ||
} |
60 changes: 60 additions & 0 deletions
60
...src/test/java/software/amazon/awssdk/transfer/s3/internal/TransferManagerLoggingTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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 software.amazon.awssdk.transfer.s3.internal; | ||
|
||
import nl.altindag.log.LogCaptor; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import software.amazon.awssdk.services.s3.S3AsyncClient; | ||
import software.amazon.awssdk.transfer.s3.S3TransferManager; | ||
|
||
public class TransferManagerLoggingTest { | ||
|
||
LogCaptor logCaptor; | ||
|
||
@BeforeEach | ||
void initLogCaptor() { | ||
logCaptor = LogCaptor.forClass(S3TransferManager.class); | ||
} | ||
|
||
@Test | ||
public void transferManager_withCrtClient_shouldNotLogMessages(){ | ||
|
||
S3AsyncClient s3Crt = S3AsyncClient.crtCreate(); | ||
S3TransferManager tm = S3TransferManager.builder().s3Client(s3Crt).build(); | ||
|
||
assertThat(logCaptor.getDebugLogs()).isEmpty(); | ||
assertThat(logCaptor.getWarnLogs()).isEmpty(); | ||
} | ||
|
||
@Test | ||
public void transferManager_withJavaClient_shouldLogWarnMessage(){ | ||
|
||
S3AsyncClient s3Java = S3AsyncClient.create(); | ||
S3TransferManager tm = S3TransferManager.builder().s3Client(s3Java).build(); | ||
|
||
assertThat(logCaptor.getDebugLogs()).isEmpty(); | ||
assertThat(logCaptor.getWarnLogs()).containsExactly("The provided DefaultS3AsyncClient is not an instance of " | ||
+ "S3CrtAsyncClient, and thus multipart upload/download feature is " | ||
+ "not enabled and resumable file upload is not supported. To benefit" | ||
+ " from maximum throughput, consider using " | ||
+ "S3AsyncClient.crtBuilder().build() instead."); | ||
|
||
|
||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,11 +19,11 @@ | |
import static org.mockito.Mockito.mock; | ||
|
||
import java.util.List; | ||
import org.apache.logging.log4j.Level; | ||
import nl.altindag.log.LogCaptor; | ||
import org.apache.logging.log4j.core.LogEvent; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import software.amazon.awssdk.testutils.LogCaptor; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, I didn't know we have LogCaptor, can we use it instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep, using LogCaptor from testutils instead |
||
|
||
import software.amazon.awssdk.transfer.s3.model.CompletedObjectTransfer; | ||
import software.amazon.awssdk.transfer.s3.model.TransferObjectRequest; | ||
import software.amazon.awssdk.transfer.s3.internal.progress.DefaultTransferProgress; | ||
|
@@ -54,52 +54,48 @@ public void setUp() throws Exception { | |
|
||
@Test | ||
public void test_defaultListener_successfulTransfer() { | ||
try (LogCaptor logCaptor = LogCaptor.create()) { | ||
invokeSuccessfulLifecycle(); | ||
List<LogEvent> events = logCaptor.loggedEvents(); | ||
assertLogged(events, Level.INFO, "Transfer initiated..."); | ||
assertLogged(events, Level.INFO, "| | 0.0%"); | ||
assertLogged(events, Level.INFO, "|= | 5.0%"); | ||
assertLogged(events, Level.INFO, "|== | 10.0%"); | ||
assertLogged(events, Level.INFO, "|=== | 15.0%"); | ||
assertLogged(events, Level.INFO, "|==== | 20.0%"); | ||
assertLogged(events, Level.INFO, "|===== | 25.0%"); | ||
assertLogged(events, Level.INFO, "|====== | 30.0%"); | ||
assertLogged(events, Level.INFO, "|======= | 35.0%"); | ||
assertLogged(events, Level.INFO, "|======== | 40.0%"); | ||
assertLogged(events, Level.INFO, "|========= | 45.0%"); | ||
assertLogged(events, Level.INFO, "|========== | 50.0%"); | ||
assertLogged(events, Level.INFO, "|=========== | 55.0%"); | ||
assertLogged(events, Level.INFO, "|============ | 60.0%"); | ||
assertLogged(events, Level.INFO, "|============= | 65.0%"); | ||
assertLogged(events, Level.INFO, "|============== | 70.0%"); | ||
assertLogged(events, Level.INFO, "|=============== | 75.0%"); | ||
assertLogged(events, Level.INFO, "|================ | 80.0%"); | ||
assertLogged(events, Level.INFO, "|================= | 85.0%"); | ||
assertLogged(events, Level.INFO, "|================== | 90.0%"); | ||
assertLogged(events, Level.INFO, "|=================== | 95.0%"); | ||
assertLogged(events, Level.INFO, "|====================| 100.0%"); | ||
assertLogged(events, Level.INFO, "Transfer complete!"); | ||
assertThat(events).isEmpty(); | ||
} | ||
LogCaptor logCaptor = LogCaptor.forClass(LoggingTransferListener.class); | ||
invokeSuccessfulLifecycle(); | ||
List<String> infoLogs = logCaptor.getInfoLogs(); | ||
assertThat(infoLogs).contains("Transfer initiated..."); | ||
assertThat(infoLogs).contains("| | 0.0%"); | ||
assertThat(infoLogs).contains("|= | 5.0%"); | ||
assertThat(infoLogs).contains("|== | 10.0%"); | ||
assertThat(infoLogs).contains("|=== | 15.0%"); | ||
assertThat(infoLogs).contains("|==== | 20.0%"); | ||
assertThat(infoLogs).contains("|===== | 25.0%"); | ||
assertThat(infoLogs).contains("|====== | 30.0%"); | ||
assertThat(infoLogs).contains("|======= | 35.0%"); | ||
assertThat(infoLogs).contains("|======== | 40.0%"); | ||
assertThat(infoLogs).contains("|========= | 45.0%"); | ||
assertThat(infoLogs).contains("|========== | 50.0%"); | ||
assertThat(infoLogs).contains("|=========== | 55.0%"); | ||
assertThat(infoLogs).contains("|============ | 60.0%"); | ||
assertThat(infoLogs).contains("|============= | 65.0%"); | ||
assertThat(infoLogs).contains("|============== | 70.0%"); | ||
assertThat(infoLogs).contains("|=============== | 75.0%"); | ||
assertThat(infoLogs).contains("|================ | 80.0%"); | ||
assertThat(infoLogs).contains("|================= | 85.0%"); | ||
assertThat(infoLogs).contains("|================== | 90.0%"); | ||
assertThat(infoLogs).contains("|=================== | 95.0%"); | ||
assertThat(infoLogs).contains("|====================| 100.0%"); | ||
assertThat(infoLogs).contains("Transfer complete!"); | ||
} | ||
|
||
@Test | ||
public void test_customTicksListener_successfulTransfer() { | ||
try (LogCaptor logCaptor = LogCaptor.create()) { | ||
listener = LoggingTransferListener.create(5); | ||
invokeSuccessfulLifecycle(); | ||
List<LogEvent> events = logCaptor.loggedEvents(); | ||
assertLogged(events, Level.INFO, "Transfer initiated..."); | ||
assertLogged(events, Level.INFO, "| | 0.0%"); | ||
assertLogged(events, Level.INFO, "|= | 20.0%"); | ||
assertLogged(events, Level.INFO, "|== | 40.0%"); | ||
assertLogged(events, Level.INFO, "|=== | 60.0%"); | ||
assertLogged(events, Level.INFO, "|==== | 80.0%"); | ||
assertLogged(events, Level.INFO, "|=====| 100.0%"); | ||
assertLogged(events, Level.INFO, "Transfer complete!"); | ||
assertThat(events).isEmpty(); | ||
} | ||
LogCaptor logCaptor = LogCaptor.forClass(LoggingTransferListener.class); | ||
listener = LoggingTransferListener.create(5); | ||
invokeSuccessfulLifecycle(); | ||
List<String> infoLogs = logCaptor.getInfoLogs(); | ||
assertThat(infoLogs).contains("Transfer initiated..."); | ||
assertThat(infoLogs).contains("| | 0.0%"); | ||
assertThat(infoLogs).contains("|= | 20.0%"); | ||
assertThat(infoLogs).contains("|== | 40.0%"); | ||
assertThat(infoLogs).contains("|=== | 60.0%"); | ||
assertThat(infoLogs).contains("|==== | 80.0%"); | ||
assertThat(infoLogs).contains("|=====| 100.0%"); | ||
assertThat(infoLogs).contains("Transfer complete!"); | ||
} | ||
|
||
private void invokeSuccessfulLifecycle() { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is version needed? Can't it inherit from parent pom?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logcaptor plugin needs 2.x.x version, while parent uses 1.7.30. Upgrading to 2.x.x causes breaking changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I see, then we can't use it unfortunately, because it will break customers. We could potentially making it a test dependency, but this could be error-prone since we could get confused and just remove the test scope in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, removed plugin and dependencies