-
Notifications
You must be signed in to change notification settings - Fork 195
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
2 changed files
with
60 additions
and
1 deletion.
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
59 changes: 59 additions & 0 deletions
59
aws/sdk/integration-tests/dynamodb/tests/test-error-classification.rs
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,59 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
use std::time::Duration; | ||
|
||
use aws_credential_types::Credentials; | ||
use aws_sdk_dynamodb::types::AttributeValue; | ||
use aws_sdk_dynamodb::Client; | ||
use aws_smithy_async::rt::sleep::{SharedAsyncSleep, TokioSleep}; | ||
use aws_smithy_runtime::client::http::test_util::wire::{ReplayedEvent, WireMockServer}; | ||
use aws_smithy_runtime::match_events; | ||
use aws_smithy_types::retry::RetryConfig; | ||
use aws_smithy_types::timeout::TimeoutConfig; | ||
use aws_types::region::Region; | ||
use bytes::Bytes; | ||
|
||
const DYNAMO_THROTTLING_RESPONSE: &str = r#"{"__type":"com.amazonaws.dynamodb.v20120810#ThrottlingException", | ||
"message":"enhance your calm"}"#; | ||
|
||
const DYNAMODB_DB_SUCCESS_RESPONSE: &str = r#"{"Count":0,"Items":[],"ScannedCount":2}"#; | ||
|
||
#[tokio::test] | ||
async fn test_disable_reconnect_on_503() { | ||
let mock = WireMockServer::start(vec![ | ||
ReplayedEvent::HttpResponse { | ||
status: 429, | ||
body: Bytes::from_static(DYNAMO_THROTTLING_RESPONSE.as_bytes()), | ||
}, | ||
ReplayedEvent::Timeout, | ||
ReplayedEvent::with_body(DYNAMODB_DB_SUCCESS_RESPONSE), | ||
]) | ||
.await; | ||
|
||
let config = aws_sdk_dynamodb::Config::builder() | ||
.region(Region::from_static("us-east-2")) | ||
.credentials_provider(Credentials::for_tests()) | ||
.sleep_impl(SharedAsyncSleep::new(TokioSleep::new())) | ||
.endpoint_url(mock.endpoint_url()) | ||
.http_client(mock.http_client()) | ||
.timeout_config( | ||
TimeoutConfig::builder() | ||
.operation_attempt_timeout(Duration::from_millis(100)) | ||
.build(), | ||
) | ||
.retry_config( | ||
RetryConfig::standard(), //.with_reconnect_mode(ReconnectMode::ReuseAllConnections), | ||
) | ||
.build(); | ||
let client = Client::from_conf(config); | ||
let item = client | ||
.get_item() | ||
.key("foo", AttributeValue::Bool(true)) | ||
.send() | ||
.await | ||
.expect("should succeed"); | ||
match_events!(ev!(dns), ev!(connect), ev!(http(500)), ev!(http(200)))(&mock.events()); | ||
} |