-
Notifications
You must be signed in to change notification settings - Fork 196
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
Add connection poisoning to aws-smithy-client #2445
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b4674e0
Add Connection Poisoning to aws-smithy-client
rcoh c67f649
Fix doc links
rcoh b306277
Remove required tokio dependency from aws-smithy-client
rcoh 3edbc5e
Remove external type exposed
rcoh 688e0dd
Rename, re-add tokio dependency
rcoh fe7398e
Change IP to 127.0.0.1 to attempt to fix windows
rcoh 24418cd
Add dns::Name to external types
rcoh 63f9f2e
Remove non_exhaustive not needed
rcoh 610e4f5
Add client target to changelog
rcoh 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
use aws_credential_types::provider::SharedCredentialsProvider; | ||
use aws_credential_types::Credentials; | ||
use aws_smithy_async::rt::sleep::TokioSleep; | ||
use aws_smithy_client::test_connection::wire_mock::{ | ||
check_matches, ReplayedEvent, WireLevelTestConnection, | ||
}; | ||
use aws_smithy_client::{ev, match_events}; | ||
use aws_smithy_types::retry::{ReconnectMode, RetryConfig}; | ||
use aws_types::region::Region; | ||
use aws_types::SdkConfig; | ||
use std::sync::Arc; | ||
|
||
#[tokio::test] | ||
/// test that disabling reconnects on retry config disables them for the client | ||
async fn disable_reconnects() { | ||
let mock = WireLevelTestConnection::spinup(vec![ | ||
ReplayedEvent::status(503), | ||
ReplayedEvent::status(503), | ||
ReplayedEvent::with_body("here-is-your-object"), | ||
]) | ||
.await; | ||
|
||
let sdk_config = SdkConfig::builder() | ||
.region(Region::from_static("us-east-2")) | ||
.credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) | ||
.sleep_impl(Arc::new(TokioSleep::new())) | ||
.endpoint_url(mock.endpoint_url()) | ||
.http_connector(mock.http_connector()) | ||
.retry_config( | ||
RetryConfig::standard().with_reconnect_mode(ReconnectMode::ReuseAllConnections), | ||
) | ||
.build(); | ||
let client = aws_sdk_s3::Client::new(&sdk_config); | ||
let resp = client | ||
.get_object() | ||
.bucket("bucket") | ||
.key("key") | ||
.send() | ||
.await | ||
.expect("succeeds after retries"); | ||
assert_eq!( | ||
resp.body.collect().await.unwrap().to_vec(), | ||
b"here-is-your-object" | ||
); | ||
match_events!( | ||
ev!(dns), | ||
ev!(connect), | ||
ev!(http(503)), | ||
ev!(http(503)), | ||
ev!(http(200)) | ||
)(&mock.events()); | ||
} | ||
|
||
#[tokio::test] | ||
async fn reconnect_on_503() { | ||
let mock = WireLevelTestConnection::spinup(vec![ | ||
ReplayedEvent::status(503), | ||
ReplayedEvent::status(503), | ||
ReplayedEvent::with_body("here-is-your-object"), | ||
]) | ||
.await; | ||
|
||
let sdk_config = SdkConfig::builder() | ||
.region(Region::from_static("us-east-2")) | ||
.credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) | ||
.sleep_impl(Arc::new(TokioSleep::new())) | ||
.endpoint_url(mock.endpoint_url()) | ||
.http_connector(mock.http_connector()) | ||
.retry_config(RetryConfig::standard()) | ||
.build(); | ||
let client = aws_sdk_s3::Client::new(&sdk_config); | ||
let resp = client | ||
.get_object() | ||
.bucket("bucket") | ||
.key("key") | ||
.send() | ||
.await | ||
.expect("succeeds after retries"); | ||
assert_eq!( | ||
resp.body.collect().await.unwrap().to_vec(), | ||
b"here-is-your-object" | ||
); | ||
match_events!( | ||
ev!(dns), | ||
ev!(connect), | ||
ev!(http(503)), | ||
ev!(dns), | ||
ev!(connect), | ||
ev!(http(503)), | ||
ev!(dns), | ||
ev!(connect), | ||
ev!(http(200)) | ||
)(&mock.events()); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
[workspace] | ||
|
||
|
||
members = [ | ||
"inlineable", | ||
"aws-smithy-async", | ||
|
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
Oops, something went wrong.
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.
Missing target
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.
ah—we changed the default to
all
at some point which is why this isn't an error