-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,191 additions
and
98 deletions.
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,62 @@ | ||
/* | ||
* 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::RetryConfig; | ||
use aws_types::region::Region; | ||
use aws_types::SdkConfig; | ||
use std::sync::Arc; | ||
use tracing_subscriber::EnvFilter; | ||
|
||
#[tokio::test] | ||
async fn reconnect_on_503() { | ||
tracing_subscriber::fmt() | ||
.with_env_filter(EnvFilter::new("trace")) | ||
.init(); | ||
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
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.