-
Notifications
You must be signed in to change notification settings - Fork 853
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump CRT version and ensure crt resources are closed (#4782)
- Loading branch information
Showing
8 changed files
with
149 additions
and
13 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
.changes/next-release/bugfix-AWSCRTbasedS3Client-d7f038c.json
This file contains 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,6 @@ | ||
{ | ||
"type": "bugfix", | ||
"category": "AWS CRT-based S3 Client", | ||
"contributor": "", | ||
"description": "Make sure all CRT resources are closed when the AWS CRT-based S3 client is closed." | ||
} |
This file contains 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,6 @@ | ||
{ | ||
"type": "feature", | ||
"category": "AWS SDK for Java v2", | ||
"contributor": "", | ||
"description": "Bump `aws-crt` version to `0.29.1`." | ||
} |
This file contains 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 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 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 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
94 changes: 94 additions & 0 deletions
94
...rc/test/java/software/amazon/awssdk/services/s3/internal/crt/S3CrtClientWiremockTest.java
This file contains 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,94 @@ | ||
/* | ||
* 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.services.s3.internal.crt; | ||
|
||
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.any; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.anyUrl; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; | ||
import com.github.tomakehurst.wiremock.junit5.WireMockTest; | ||
import java.net.URI; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; | ||
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; | ||
import software.amazon.awssdk.crt.CrtResource; | ||
import software.amazon.awssdk.crt.Log; | ||
import software.amazon.awssdk.regions.Region; | ||
import software.amazon.awssdk.services.s3.S3AsyncClient; | ||
import software.amazon.awssdk.services.s3.model.CompleteMultipartUploadResponse; | ||
|
||
/** | ||
* Tests to make sure all CRT resources are cleaned up | ||
*/ | ||
@WireMockTest | ||
public class S3CrtClientWiremockTest { | ||
|
||
private S3AsyncClient s3AsyncClient; | ||
|
||
@BeforeAll | ||
public static void setUpBeforeAll() { | ||
System.setProperty("aws.crt.debugnative", "true"); | ||
Log.initLoggingToStdout(Log.LogLevel.Warn); | ||
} | ||
|
||
@BeforeEach | ||
public void setup(WireMockRuntimeInfo wiremock) { | ||
s3AsyncClient = S3AsyncClient.crtBuilder() | ||
.region(Region.US_EAST_1) | ||
.endpointOverride(URI.create("http://localhost:" + wiremock.getHttpPort())) | ||
.credentialsProvider( | ||
StaticCredentialsProvider.create(AwsBasicCredentials.create("key", "secret"))) | ||
.build(); | ||
} | ||
|
||
@AfterEach | ||
public void tearDown() { | ||
s3AsyncClient.close(); | ||
CrtResource.waitForNoResources(); | ||
} | ||
|
||
@Test | ||
public void completeMultipartUpload_completeResponse() { | ||
String location = "http://Example-Bucket.s3.amazonaws.com/Example-Object"; | ||
String bucket = "Example-Bucket"; | ||
String key = "Example-Object"; | ||
String eTag = "\"3858f62230ac3c915f300c664312c11f-9\""; | ||
String xmlResponseBody = String.format( | ||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" | ||
+ "<CompleteMultipartUploadResult xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">\n" | ||
+ "<Location>%s</Location>\n" | ||
+ "<Bucket>%s</Bucket>\n" | ||
+ "<Key>%s</Key>\n" | ||
+ "<ETag>%s</ETag>\n" | ||
+ "</CompleteMultipartUploadResult>", location, bucket, key, eTag); | ||
|
||
stubFor(any(anyUrl()).willReturn(aResponse().withStatus(200).withBody(xmlResponseBody))); | ||
|
||
CompleteMultipartUploadResponse response = s3AsyncClient.completeMultipartUpload( | ||
r -> r.bucket(bucket).key(key).uploadId("upload-id")).join(); | ||
|
||
assertThat(response.location()).isEqualTo(location); | ||
assertThat(response.bucket()).isEqualTo(bucket); | ||
assertThat(response.key()).isEqualTo(key); | ||
assertThat(response.eTag()).isEqualTo(eTag); | ||
} | ||
} |
This file contains 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,18 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
# Set up logging implementation | ||
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog | ||
org.eclipse.jetty.LEVEL=OFF |