From ee6f21c8897ce09c6cd8d31b1f69ab9748d85b95 Mon Sep 17 00:00:00 2001 From: David Souther Date: Tue, 10 Oct 2023 15:39:33 -0400 Subject: [PATCH 1/5] Rust: Update for SDK HttpConnector changes. --- rust_dev_preview/examples/tls/Cargo.toml | 2 +- rust_dev_preview/examples/tls/src/lib.rs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rust_dev_preview/examples/tls/Cargo.toml b/rust_dev_preview/examples/tls/Cargo.toml index 1600814f87c..0f1f08c39fa 100644 --- a/rust_dev_preview/examples/tls/Cargo.toml +++ b/rust_dev_preview/examples/tls/Cargo.toml @@ -13,7 +13,7 @@ path = "src/lib.rs" [dependencies] aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-smithy-runtime = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-sdk-kms = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", default-features = false } webpki-roots = "0.22.4" tokio = { version = "1.20.1", features = ["full"] } diff --git a/rust_dev_preview/examples/tls/src/lib.rs b/rust_dev_preview/examples/tls/src/lib.rs index 9447cd3e421..47ab6be57c2 100644 --- a/rust_dev_preview/examples/tls/src/lib.rs +++ b/rust_dev_preview/examples/tls/src/lib.rs @@ -15,7 +15,7 @@ This example assumes you have set up environment variables for authentication. */ use aws_sdk_kms::Error; -use aws_smithy_client::hyper_ext; +use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder; use rustls::RootCertStore; // snippet-start:[rust.example_code.tls.ConnectWithTLS13] @@ -49,10 +49,10 @@ pub async fn connect_via_tls_13() -> Result<(), Error> { .enable_http2() .build(); - let shared_conf = aws_config::from_env() - .http_connector(hyper_ext::Adapter::builder().build(rustls_connector)) - .load() - .await; + // See https://github.com/awslabs/smithy-rs/discussions/3022 for the HyperClientBuilder + let http_client = HyperClientBuilder::new().build(rustls_connector); + + let shared_conf = aws_config::from_env().http_client(http_client).load().await; let kms_client = aws_sdk_kms::Client::new(&shared_conf); let response = kms_client.list_keys().send().await?; From 0e3c26f4553469ec4b9c8dd4af4cda8769ad345a Mon Sep 17 00:00:00 2001 From: David Souther Date: Tue, 10 Oct 2023 17:11:07 -0400 Subject: [PATCH 2/5] Fix wasm connector --- rust_dev_preview/webassembly/Cargo.toml | 4 +-- rust_dev_preview/webassembly/src/lib.rs | 46 ++++++++++++++----------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/rust_dev_preview/webassembly/Cargo.toml b/rust_dev_preview/webassembly/Cargo.toml index 823f0744c69..f3661acd212 100644 --- a/rust_dev_preview/webassembly/Cargo.toml +++ b/rust_dev_preview/webassembly/Cargo.toml @@ -13,10 +13,11 @@ crate-type = ["cdylib"] aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", default-features = false } aws-credential-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["hardcoded-credentials"] } aws-sdk-lambda = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", default-features = false } +aws-smithy-async = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", default-features = false } aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["event-stream"] } +aws-smithy-runtime-api = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-smithy-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-async = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } async-trait = "0.1.63" console_error_panic_hook = "0.1.7" http = "0.2.8" @@ -24,7 +25,6 @@ js-sys = "0.3.60" serde = { version = "1.0.152", features = ["derive"] } serde-wasm-bindgen = "0.4.5" tokio = { version = "1.24.2", features = ["macros", "rt"] } -tower = "0.4.13" wasm-bindgen = "0.2.83" wasm-bindgen-futures = "0.4.33" wasm-timer = "0.2.5" diff --git a/rust_dev_preview/webassembly/src/lib.rs b/rust_dev_preview/webassembly/src/lib.rs index b5c96affeb0..b5f22a54100 100644 --- a/rust_dev_preview/webassembly/src/lib.rs +++ b/rust_dev_preview/webassembly/src/lib.rs @@ -10,6 +10,18 @@ use aws_sdk_lambda::primitives::SdkBody; use aws_sdk_lambda::{meta::PKG_VERSION, Client}; use aws_smithy_async::time::TimeSource; use aws_smithy_http::result::ConnectorError; +use aws_smithy_runtime_api::{ + client::{ + http::{ + HttpClient, HttpConnector, HttpConnectorFuture, HttpConnectorSettings, + SharedHttpConnector, + }, + orchestrator::HttpRequest, + runtime_components::RuntimeComponents, + }, + shared::IntoShared, +}; + use serde::Deserialize; use std::time::SystemTime; use wasm_bindgen::{prelude::*, JsCast}; @@ -63,7 +75,7 @@ pub async fn main(region: String, verbose: bool) -> Result { .region(Region::new(region)) .time_source(BrowserNow) .credentials_provider(credentials_provider) - .http_connector(Adapter::new(verbose, access_key == "access_key")) + .http_client(Adapter::new(verbose, access_key == "access_key")) .load() .await; tracing::info!("sdk config: {:#?}", shared_config); @@ -234,24 +246,8 @@ impl Adapter { } } -impl tower::Service> for Adapter { - type Response = http::Response; - - type Error = ConnectorError; - - #[allow(clippy::type_complexity)] - type Future = std::pin::Pin< - Box> + Send + 'static>, - >; - - fn poll_ready( - &mut self, - _cx: &mut std::task::Context<'_>, - ) -> std::task::Poll> { - std::task::Poll::Ready(Ok(())) - } - - fn call(&mut self, req: http::Request) -> Self::Future { +impl HttpConnector for Adapter { + fn call(&self, req: HttpRequest) -> HttpConnectorFuture { let (parts, body) = req.into_parts(); let uri = parts.uri.to_string(); if self.verbose { @@ -277,10 +273,20 @@ impl tower::Service> for Adapter { ); }); - Box::pin(async move { + HttpConnectorFuture::new(async move { let response = rx.await.map_err(|e| ConnectorError::user(Box::new(e)))?; log!("response received"); Ok(response) }) } } + +impl HttpClient for Adapter { + fn http_connector( + &self, + _settings: &HttpConnectorSettings, + _components: &RuntimeComponents, + ) -> SharedHttpConnector { + self.clone().into_shared() + } +} From 9e8a01df2f4ad47b26771d7c7df3fdc3a61b8250 Mon Sep 17 00:00:00 2001 From: David Souther Date: Wed, 11 Oct 2023 17:37:02 -0400 Subject: [PATCH 3/5] Update from TestConnector to StaticReplayClient --- .../photo_asset_management/Cargo.toml | 5 +- .../src/handlers/labels.rs | 3 +- .../photo_asset_management/src/lib.rs | 1 - .../src/test_utils/macros.rs | 103 ------------------ .../src/test_utils/mod.rs | 17 --- .../cross_service/rest_ses/Cargo.toml | 1 + .../cross_service/rest_ses/src/client.rs | 17 ++- rust_dev_preview/examples/dynamodb/Cargo.toml | 23 ++-- .../examples/dynamodb/src/scenario/list.rs | 8 +- rust_dev_preview/examples/s3/Cargo.toml | 1 + .../examples/s3/src/s3-service-lib.rs | 6 +- rust_dev_preview/run_all.sh | 25 +++++ rust_dev_preview/test-utils/Cargo.toml | 5 +- rust_dev_preview/test-utils/src/macros.rs | 6 +- rust_dev_preview/test-utils/src/mod.rs | 4 +- 15 files changed, 60 insertions(+), 165 deletions(-) delete mode 100644 rust_dev_preview/cross_service/photo_asset_management/src/test_utils/macros.rs delete mode 100644 rust_dev_preview/cross_service/photo_asset_management/src/test_utils/mod.rs create mode 100755 rust_dev_preview/run_all.sh diff --git a/rust_dev_preview/cross_service/photo_asset_management/Cargo.toml b/rust_dev_preview/cross_service/photo_asset_management/Cargo.toml index 63b49c2b350..3807e112dd0 100644 --- a/rust_dev_preview/cross_service/photo_asset_management/Cargo.toml +++ b/rust_dev_preview/cross_service/photo_asset_management/Cargo.toml @@ -19,10 +19,8 @@ aws-sdk-dynamodb = { git = "https://github.com/awslabs/aws-sdk-rust", branch = " aws-sdk-rekognition = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-sdk-sns = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ - "test-util", -] } aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-smithy-runtime = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-smithy-types-convert ={ git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["convert-chrono"] } aws_lambda_events = { version = "0.10.0", features = ["s3", "apigw"], default-features = false } bytes = "1.4.0" @@ -35,6 +33,7 @@ lambda_runtime = "0.8.0" miniz_oxide = "0.7.1" pin-project = "1.0.12" pipe = "0.4.0" +sdk-examples-test-utils = { path = "../../test-utils" } serde = { version = "1.0.159", features = ["derive"] } serde_json = "1.0.95" streaming-zip = "0.5.0" diff --git a/rust_dev_preview/cross_service/photo_asset_management/src/handlers/labels.rs b/rust_dev_preview/cross_service/photo_asset_management/src/handlers/labels.rs index f2b137476db..da2fc45fd13 100644 --- a/rust_dev_preview/cross_service/photo_asset_management/src/handlers/labels.rs +++ b/rust_dev_preview/cross_service/photo_asset_management/src/handlers/labels.rs @@ -104,10 +104,9 @@ pub async fn handler( #[cfg(test)] mod test { + use sdk_examples_test_utils::single_shot_client; use serde_json::json; - use crate::single_shot_client; - use super::{get_labels, Labels}; #[tokio::test] diff --git a/rust_dev_preview/cross_service/photo_asset_management/src/lib.rs b/rust_dev_preview/cross_service/photo_asset_management/src/lib.rs index f634c83d9a6..3d0aca88324 100644 --- a/rust_dev_preview/cross_service/photo_asset_management/src/lib.rs +++ b/rust_dev_preview/cross_service/photo_asset_management/src/lib.rs @@ -1,5 +1,4 @@ pub mod chunked_uploader; pub mod common; pub mod handlers; -pub mod test_utils; pub mod uploader; diff --git a/rust_dev_preview/cross_service/photo_asset_management/src/test_utils/macros.rs b/rust_dev_preview/cross_service/photo_asset_management/src/test_utils/macros.rs deleted file mode 100644 index fbf286c6061..00000000000 --- a/rust_dev_preview/cross_service/photo_asset_management/src/test_utils/macros.rs +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0. - */ - -//! Macros and functions that simplify making AWS SDK clients with a mocked request/response pair. - -/// Generate a single http::{Request, Response} pair. The first argument -/// is the expression to use as the value for SdkBody::from. The second -/// argument with the HTTP Status code and the response body. -/// -/// To create a number of events to use for a test client, create a vec![] -/// of many of these test_event pairs. -#[macro_export] -macro_rules! test_event { - ( - $req:expr, - ( - $status:expr, - $res:expr - ) - ) => {{ - ( - http::Request::builder() - .body(aws_smithy_http::body::SdkBody::from($req)) - .unwrap(), - http::Response::builder() - .status($status) - .body(aws_smithy_http::body::SdkBody::from($res)) - .unwrap(), - ) - }}; - ( - $req:expr, - ( - $status:expr, - $headers:expr, - $res:expr - ) - ) => {{ - ( - http::Request::builder() - .body(aws_smithy_http::body::SdkBody::from($req)) - .unwrap(), - { - let mut builder = http::Response::builder().status($status); - for (k, v) in $headers { - builder = builder.header(k, v); - } - builder - .body(aws_smithy_http::body::SdkBody::from($res)) - .unwrap() - }, - ) - }}; -} - -/// Create a hard-coded testing config for an AWS SDK. -#[macro_export] -macro_rules! client_config { - ( - $sdk_crate:ident - ) => { - $sdk_crate::Config::builder() - // TODO: replace after https://github.com/awslabs/smithy-rs/pull/2145 - // .credentials_provider($sdk_crate::config::Credentials::for_test()) - .credentials_provider($sdk_crate::config::Credentials::new( - "ATESTCLIENT", - "atestsecretkey", - Some("atestsessiontoken".to_string()), - None, - "", - )) - .region($sdk_crate::config::Region::new("us-east-1")) - }; -} - -/// Create a single-shot Client for `sdk_crate`. The `req` and `res` will be the -/// body of the request and the response, respectively. The `status` is the HTTP -/// status code for the response. The credentials are hardcoded test values. -#[macro_export] -macro_rules! single_shot_client { - (sdk: $sdk_crate:ident, status: $status:expr, response: $res:expr) => {{ - single_shot_client!($sdk_crate, "", $status, vec![], $res) - }}; - (sdk: $sdk_crate:ident, request: $req:expr, status: $status:expr, response: $res:expr) => {{ - single_shot_client!($sdk_crate, $res, $status, vec![], $res) - }}; - (sdk: $sdk_crate:ident, status: $status:expr, headers: $res_headers:expr, response: $res:expr) => {{ - single_shot_client!($sdk_crate, "", $status, $res_headers, $res) - }}; - // "Private" internal root macro. - ($sdk_crate:ident, $req:expr, $status:expr, $res_headers:expr, $res:expr) => {{ - $sdk_crate::Client::from_conf( - $crate::client_config!($sdk_crate) - .http_connector($crate::test_utils::single_shot( - $req.into(), - ($status.try_into().unwrap(), $res_headers, $res.into()), - )) - .build(), - ) - }}; -} diff --git a/rust_dev_preview/cross_service/photo_asset_management/src/test_utils/mod.rs b/rust_dev_preview/cross_service/photo_asset_management/src/test_utils/mod.rs deleted file mode 100644 index f3780b6d6bd..00000000000 --- a/rust_dev_preview/cross_service/photo_asset_management/src/test_utils/mod.rs +++ /dev/null @@ -1,17 +0,0 @@ -use aws_smithy_http::body::SdkBody; - -use crate::test_event; - -pub mod macros; - -/// Create a single-shot test connection. The arguments are the same as test_event, -/// but the expanded macro creates a TestConnection. The `TestConnection` can be -/// provided directly to a `Client::from_conf_conn`. -pub fn single_shot( - req: SdkBody, - res: (http::StatusCode, Vec<(&str, &str)>, SdkBody), -) -> aws_smithy_client::test_connection::TestConnection { - aws_smithy_client::test_connection::TestConnection::new(vec![ - (test_event!(req, (res.0, res.1, res.2))), - ]) -} diff --git a/rust_dev_preview/cross_service/rest_ses/Cargo.toml b/rust_dev_preview/cross_service/rest_ses/Cargo.toml index 9d6da1fe581..d429638a7cd 100644 --- a/rust_dev_preview/cross_service/rest_ses/Cargo.toml +++ b/rust_dev_preview/cross_service/rest_ses/Cargo.toml @@ -18,6 +18,7 @@ aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" aws-sdk-cloudwatchlogs = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-sdk-rdsdata = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-sdk-ses = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-smithy-runtime = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } chrono = { version = "0.4.22", default-features = false, features = [ "clock", "serde", diff --git a/rust_dev_preview/cross_service/rest_ses/src/client.rs b/rust_dev_preview/cross_service/rest_ses/src/client.rs index 8cf39561312..c9b119f82c7 100644 --- a/rust_dev_preview/cross_service/rest_ses/src/client.rs +++ b/rust_dev_preview/cross_service/rest_ses/src/client.rs @@ -64,23 +64,20 @@ impl RdsClient { #[cfg(test)] mod rds_client_for_test { - use aws_smithy_http::body::SdkBody; + use aws_smithy_runtime::client::http::test_util::ReplayEvent; use secrecy::Secret; use super::RdsClient; impl RdsClient { - pub fn for_test( - pairs: Vec<( - http::request::Request, - http::response::Response, - )>, - ) -> Self { + pub fn for_test(pairs: Vec) -> Self { RdsClient { client: aws_sdk_rdsdata::Client::from_conf( sdk_examples_test_utils::client_config!(aws_sdk_rdsdata) - .http_connector(aws_smithy_client::test_connection::TestConnection::new( - pairs, - )) + .http_client( + aws_smithy_runtime::client::http::test_util::StaticReplayClient::new( + pairs, + ), + ) .build(), ), secret_arn: Secret::from("secret".to_string()), diff --git a/rust_dev_preview/examples/dynamodb/Cargo.toml b/rust_dev_preview/examples/dynamodb/Cargo.toml index 94ce4ec7a45..94085e4ee72 100644 --- a/rust_dev_preview/examples/dynamodb/Cargo.toml +++ b/rust_dev_preview/examples/dynamodb/Cargo.toml @@ -12,30 +12,25 @@ edition = "2021" [dependencies] aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-dynamodb = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ - "client-hyper", - "rustls", - "rt-tokio", -] } -aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ - "rt-tokio", -] } +aws-sdk-dynamodb = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ "client-hyper", "rustls", "rt-tokio", ] } +aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ "rt-tokio", ] } +aws-smithy-runtime = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["test-util"] } aws-smithy-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } axum = "0.5.16" -http = "0.2.5" +clap = { version = "~4.2", features = ["derive"] } futures = "0.3" +http = "0.2.5" log = "0.4.17" rand = "0.8.3" sdk-examples-test-utils = { path = "../../test-utils" } serde = {version = "1.0", features = ["derive"]} -serde_json = "1" serde_dynamo = { version = "4", features = ["aws-sdk-dynamodb+0_22"] } -clap = { version = "~4.2", features = ["derive"] } -tracing = "0.1" +serde_json = "1" thiserror = "1.0" tokio = { version = "1.20.1", features = ["full"] } tokio-stream = "0.1.8" tower-http = { version = "0.3.0", features = ["cors"] } -tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } +tracing = "0.1" +tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } \ No newline at end of file diff --git a/rust_dev_preview/examples/dynamodb/src/scenario/list.rs b/rust_dev_preview/examples/dynamodb/src/scenario/list.rs index 6809d082fee..599f6cb32ce 100644 --- a/rust_dev_preview/examples/dynamodb/src/scenario/list.rs +++ b/rust_dev_preview/examples/dynamodb/src/scenario/list.rs @@ -119,8 +119,8 @@ mod test_list_more_tables { async fn test_list_tables_iterative() { let client = aws_sdk_dynamodb::Client::from_conf( sdk_examples_test_utils::client_config!(aws_sdk_dynamodb) - .http_connector(aws_smithy_client::test_connection::TestConnection::new( - vec![ + .http_client( + aws_smithy_runtime::client::http::test_util::StaticReplayClient::new(vec![ test_event!( "", ( @@ -136,8 +136,8 @@ mod test_list_more_tables { ) ), test_event!("", (200, r#"{"TableNames":["g","h"]}"#)), - ], - )) + ]), + ) .build(), ); diff --git a/rust_dev_preview/examples/s3/Cargo.toml b/rust_dev_preview/examples/s3/Cargo.toml index c15aab14f48..92d8b2ab198 100644 --- a/rust_dev_preview/examples/s3/Cargo.toml +++ b/rust_dev_preview/examples/s3/Cargo.toml @@ -30,6 +30,7 @@ aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "test-util", ] } aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["rt-tokio"] } +aws-smithy-runtime = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-smithy-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } sdk-examples-test-utils = { path = "../../test-utils" } bytes = "1.4.0" diff --git a/rust_dev_preview/examples/s3/src/s3-service-lib.rs b/rust_dev_preview/examples/s3/src/s3-service-lib.rs index d4039118e42..15a73906a99 100644 --- a/rust_dev_preview/examples/s3/src/s3-service-lib.rs +++ b/rust_dev_preview/examples/s3/src/s3-service-lib.rs @@ -163,7 +163,7 @@ pub async fn create_bucket( mod test { use std::env::temp_dir; - use aws_smithy_client::test_connection::TestConnection; + use aws_smithy_runtime::client::http::test_util::StaticReplayClient; use sdk_examples_test_utils::{client_config, single_shot_client, test_event}; use tokio::{fs::File, io::AsyncWriteExt}; use uuid::Uuid; @@ -190,7 +190,7 @@ mod test { async fn test_delete_objects() { let client = aws_sdk_s3::Client::from_conf( client_config!(aws_sdk_s3) - .http_connector(TestConnection::new(vec![ + .http_client(StaticReplayClient::new(vec![ // client.list_objects_v2().bucket(bucket_name) test_event!( r#""#, @@ -241,7 +241,7 @@ mod test { async fn test_delete_objects_failed() { let client = aws_sdk_s3::Client::from_conf( client_config!(aws_sdk_s3) - .http_connector(TestConnection::new(vec![ + .http_client(StaticReplayClient::new(vec![ // client.list_objects_v2().bucket(bucket_name) test_event!( r#""#, diff --git a/rust_dev_preview/run_all.sh b/rust_dev_preview/run_all.sh new file mode 100755 index 00000000000..29be134e609 --- /dev/null +++ b/rust_dev_preview/run_all.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +DIRS=( + cross_service + examples + lambda + webassembly +) + +# Clean Cargo.log +rm rust_dev_preview/**/Cargo.lock + +export RUSTFLAGS="-D warnings" ; +export APP_ENVIRONMENT="test" + +FAIL=() +for f in ${DIRS[@]} ; do + "$HOME/.cargo/bin/cargo" fmt --manifest-path rust_dev_preview/$f/Cargo.toml --all --check || FAIL+=("fmt $f") + "$HOME/.cargo/bin/cargo" clippy --manifest-path rust_dev_preview/$f/Cargo.toml --all || FAIL+=("clippy $f") + "$HOME/.cargo/bin/cargo" test --manifest-path rust_dev_preview/$f/Cargo.toml --all || FAIL+=("clippy $f") +done + +echo $FAIL + +exit "${#FAIL[@]}" diff --git a/rust_dev_preview/test-utils/Cargo.toml b/rust_dev_preview/test-utils/Cargo.toml index 25b0e0ddfe8..815d5cec597 100644 --- a/rust_dev_preview/test-utils/Cargo.toml +++ b/rust_dev_preview/test-utils/Cargo.toml @@ -10,10 +10,9 @@ edition = "2021" [dependencies] aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ - "test-util", -] } +aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ "test-util", ] } aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-smithy-runtime = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["test-util"] } aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next"} http = "0.2" diff --git a/rust_dev_preview/test-utils/src/macros.rs b/rust_dev_preview/test-utils/src/macros.rs index 52f437496e3..e5532383a99 100644 --- a/rust_dev_preview/test-utils/src/macros.rs +++ b/rust_dev_preview/test-utils/src/macros.rs @@ -20,7 +20,7 @@ macro_rules! test_event { $res:expr ) ) => {{ - ( + aws_smithy_runtime::client::http::test_util::ReplayEvent::new( http::Request::builder() .body(aws_smithy_http::body::SdkBody::from($req)) .unwrap(), @@ -38,7 +38,7 @@ macro_rules! test_event { $res:expr ) ) => {{ - ( + aws_smithy_runtime::client::http::test_util::ReplayEvent::new( http::Request::builder() .body(aws_smithy_http::body::SdkBody::from($req)) .unwrap(), @@ -73,7 +73,7 @@ macro_rules! single_shot_client { ($sdk_crate:ident, $req:expr, $status:expr, $res_headers:expr, $res:expr) => {{ $sdk_crate::Client::from_conf( sdk_examples_test_utils::client_config!($sdk_crate) - .http_connector(sdk_examples_test_utils::single_shot( + .http_client(sdk_examples_test_utils::single_shot( $req.into(), ($status.try_into().unwrap(), $res_headers, $res.into()), )) diff --git a/rust_dev_preview/test-utils/src/mod.rs b/rust_dev_preview/test-utils/src/mod.rs index 40a301bdaa2..a8a97c6733e 100644 --- a/rust_dev_preview/test-utils/src/mod.rs +++ b/rust_dev_preview/test-utils/src/mod.rs @@ -8,8 +8,8 @@ pub mod macros; pub fn single_shot( req: SdkBody, res: (http::StatusCode, Vec<(&str, &str)>, SdkBody), -) -> aws_smithy_client::test_connection::TestConnection { - aws_smithy_client::test_connection::TestConnection::new(vec![ +) -> aws_smithy_runtime::client::http::test_util::StaticReplayClient { + aws_smithy_runtime::client::http::test_util::StaticReplayClient::new(vec![ (test_event!(req, (res.0, res.1, res.2))), ]) } From 766395cf2a68d10d96c238af59ac49beba1a5a0f Mon Sep 17 00:00:00 2001 From: David Souther Date: Sat, 14 Oct 2023 10:41:15 -0400 Subject: [PATCH 4/5] Remove deprecated aws-smithy-client --- rust_dev_preview/cross_service/rest_ses/Cargo.toml | 2 +- .../cognitoidentity/src/bin/describe-identity-pool.rs | 4 ++-- .../examples/custom-root-certificates/Cargo.toml | 1 - rust_dev_preview/examples/dynamodb/Cargo.toml | 1 - rust_dev_preview/examples/glue/Cargo.toml | 5 ----- rust_dev_preview/examples/kms/Cargo.toml | 5 ----- rust_dev_preview/examples/s3/Cargo.toml | 3 --- .../examples/s3/src/bin/put-object-progress.rs | 1 - .../examples/sending-presigned-requests/Cargo.toml | 1 + .../examples/sending-presigned-requests/src/main.rs | 2 +- rust_dev_preview/examples/testing/Cargo.toml | 3 --- rust_dev_preview/run_all.sh | 10 +++++----- rust_dev_preview/test-utils/Cargo.toml | 1 - rust_dev_preview/webassembly/Cargo.toml | 1 - 14 files changed, 10 insertions(+), 30 deletions(-) diff --git a/rust_dev_preview/cross_service/rest_ses/Cargo.toml b/rust_dev_preview/cross_service/rest_ses/Cargo.toml index d429638a7cd..d39ae87fd61 100644 --- a/rust_dev_preview/cross_service/rest_ses/Cargo.toml +++ b/rust_dev_preview/cross_service/rest_ses/Cargo.toml @@ -45,7 +45,7 @@ uuid = { version = "1.2.1", features = ["v4", "serde"] } xlsxwriter = "0.6.0" [dev-dependencies] -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["test-util"] } +aws-smithy-runtime = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } fake = { version = "2.5.0", features = ["uuid"] } once_cell = "1.15.0" diff --git a/rust_dev_preview/examples/cognitoidentity/src/bin/describe-identity-pool.rs b/rust_dev_preview/examples/cognitoidentity/src/bin/describe-identity-pool.rs index eee8ddfecf0..1a922599036 100644 --- a/rust_dev_preview/examples/cognitoidentity/src/bin/describe-identity-pool.rs +++ b/rust_dev_preview/examples/cognitoidentity/src/bin/describe-identity-pool.rs @@ -64,13 +64,13 @@ async fn describe_pool(client: &Client, id: &str) -> Result<(), Error> { println!(" value: {}", value); } - let open_id_arns = response.open_id_connect_provider_ar_ns(); + let open_id_arns = response.open_id_connect_provider_arns(); println!(" Open ID provider ARNs:"); for arn in open_id_arns { println!(" {}", arn); } - let saml_arns = response.saml_provider_ar_ns(); + let saml_arns = response.saml_provider_arns(); println!(" SAML provider ARNs:"); for arn in saml_arns { println!(" {}", arn); diff --git a/rust_dev_preview/examples/custom-root-certificates/Cargo.toml b/rust_dev_preview/examples/custom-root-certificates/Cargo.toml index a961c5e711e..a3605ff91e5 100644 --- a/rust_dev_preview/examples/custom-root-certificates/Cargo.toml +++ b/rust_dev_preview/examples/custom-root-certificates/Cargo.toml @@ -8,7 +8,6 @@ description = "An example demonstrating setting a custom root certificate with r [dependencies] aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } # bringing our own HTTPs so no need for the default features aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", default-features = false } tokio = { version = "1.21.2", features = ["full"] } diff --git a/rust_dev_preview/examples/dynamodb/Cargo.toml b/rust_dev_preview/examples/dynamodb/Cargo.toml index 94085e4ee72..eadc56e11a9 100644 --- a/rust_dev_preview/examples/dynamodb/Cargo.toml +++ b/rust_dev_preview/examples/dynamodb/Cargo.toml @@ -14,7 +14,6 @@ edition = "2021" aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-sdk-dynamodb = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ "client-hyper", "rustls", "rt-tokio", ] } aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ "rt-tokio", ] } aws-smithy-runtime = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["test-util"] } aws-smithy-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } diff --git a/rust_dev_preview/examples/glue/Cargo.toml b/rust_dev_preview/examples/glue/Cargo.toml index cc746495b4d..5b6e0daa005 100644 --- a/rust_dev_preview/examples/glue/Cargo.toml +++ b/rust_dev_preview/examples/glue/Cargo.toml @@ -17,11 +17,6 @@ aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" aws-sdk-glue = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ - "client-hyper", - "rustls", - "rt-tokio", -] } aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ "rt-tokio", ] } diff --git a/rust_dev_preview/examples/kms/Cargo.toml b/rust_dev_preview/examples/kms/Cargo.toml index 74717fdc895..4cd0f82d5d3 100644 --- a/rust_dev_preview/examples/kms/Cargo.toml +++ b/rust_dev_preview/examples/kms/Cargo.toml @@ -11,11 +11,6 @@ description = "Example usage of the KMS service" [dependencies] aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-sdk-kms = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ - "client-hyper", - "rustls", - "rt-tokio", -] } tokio = { version = "1.20.1", features = ["full"] } base64 = "0.13.0" clap = { version = "~4.2", features = ["derive"] } diff --git a/rust_dev_preview/examples/s3/Cargo.toml b/rust_dev_preview/examples/s3/Cargo.toml index 92d8b2ab198..36c7fdcb42b 100644 --- a/rust_dev_preview/examples/s3/Cargo.toml +++ b/rust_dev_preview/examples/s3/Cargo.toml @@ -26,9 +26,6 @@ aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" aws-endpoint = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } # snippet-end:[s3.rust.s3-object-lambda-cargo.toml] aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ - "test-util", -] } aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["rt-tokio"] } aws-smithy-runtime = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-smithy-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } diff --git a/rust_dev_preview/examples/s3/src/bin/put-object-progress.rs b/rust_dev_preview/examples/s3/src/bin/put-object-progress.rs index f21feea2a99..cf6fca1ffa1 100644 --- a/rust_dev_preview/examples/s3/src/bin/put-object-progress.rs +++ b/rust_dev_preview/examples/s3/src/bin/put-object-progress.rs @@ -160,7 +160,6 @@ async fn put_object(client: &Client, opts: &Opt) -> Result<(), anyhow::Error> { // ProgressBody wrapped implementation. let customized = request .customize() - .await? .map_request(ProgressBody::::replace); let out = customized.send().await?; diff --git a/rust_dev_preview/examples/sending-presigned-requests/Cargo.toml b/rust_dev_preview/examples/sending-presigned-requests/Cargo.toml index 1f013781a88..7c3718c1621 100644 --- a/rust_dev_preview/examples/sending-presigned-requests/Cargo.toml +++ b/rust_dev_preview/examples/sending-presigned-requests/Cargo.toml @@ -16,3 +16,4 @@ reqwest = "0.11" clap = { version = "~4.2", features = ["derive"] } tokio = { version = "1.20.1", features = ["full"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } +hyper-tls = "0.5.0" diff --git a/rust_dev_preview/examples/sending-presigned-requests/src/main.rs b/rust_dev_preview/examples/sending-presigned-requests/src/main.rs index 1f8cc963c9e..a9453025d79 100644 --- a/rust_dev_preview/examples/sending-presigned-requests/src/main.rs +++ b/rust_dev_preview/examples/sending-presigned-requests/src/main.rs @@ -127,7 +127,7 @@ fn print_as_curl_request(presigned_req: &PresignedRequest, body: Option<&str>) { /// This function demonstrates how you can send a presigned request using [hyper](https://crates.io/crates/hyper) async fn send_presigned_request_with_hyper(req: PresignedRequest, body: hyper::Body) { - let conn = aws_smithy_client::conns::https(); + let conn = hyper_tls::HttpsConnector::new(); let client = hyper::Client::builder().build(conn); let req = req.to_http_request(body).unwrap(); diff --git a/rust_dev_preview/examples/testing/Cargo.toml b/rust_dev_preview/examples/testing/Cargo.toml index 4cc5e3ae78e..59f75ba26f3 100644 --- a/rust_dev_preview/examples/testing/Cargo.toml +++ b/rust_dev_preview/examples/testing/Cargo.toml @@ -13,9 +13,6 @@ async-trait = "0.1.51" # snippet-end:[testing.rust.Cargo.toml] aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ - "test-util", -] } aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-credential-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ diff --git a/rust_dev_preview/run_all.sh b/rust_dev_preview/run_all.sh index 29be134e609..988ef8537f1 100755 --- a/rust_dev_preview/run_all.sh +++ b/rust_dev_preview/run_all.sh @@ -15,11 +15,11 @@ export APP_ENVIRONMENT="test" FAIL=() for f in ${DIRS[@]} ; do - "$HOME/.cargo/bin/cargo" fmt --manifest-path rust_dev_preview/$f/Cargo.toml --all --check || FAIL+=("fmt $f") - "$HOME/.cargo/bin/cargo" clippy --manifest-path rust_dev_preview/$f/Cargo.toml --all || FAIL+=("clippy $f") - "$HOME/.cargo/bin/cargo" test --manifest-path rust_dev_preview/$f/Cargo.toml --all || FAIL+=("clippy $f") + "$HOME/.cargo/bin/cargo" fmt --manifest-path rust_dev_preview/$f/Cargo.toml --all --check || FAIL+=("fmt:$f") + "$HOME/.cargo/bin/cargo" clippy --manifest-path rust_dev_preview/$f/Cargo.toml --all || FAIL+=("clippy:$f") + "$HOME/.cargo/bin/cargo" test --manifest-path rust_dev_preview/$f/Cargo.toml --all || FAIL+=("test:$f") done -echo $FAIL - +echo $FAIL; exit "${#FAIL[@]}" + diff --git a/rust_dev_preview/test-utils/Cargo.toml b/rust_dev_preview/test-utils/Cargo.toml index 815d5cec597..2cc5b68ec19 100644 --- a/rust_dev_preview/test-utils/Cargo.toml +++ b/rust_dev_preview/test-utils/Cargo.toml @@ -10,7 +10,6 @@ edition = "2021" [dependencies] aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ "test-util", ] } aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-smithy-runtime = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["test-util"] } aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next"} diff --git a/rust_dev_preview/webassembly/Cargo.toml b/rust_dev_preview/webassembly/Cargo.toml index f3661acd212..8c92fe5304c 100644 --- a/rust_dev_preview/webassembly/Cargo.toml +++ b/rust_dev_preview/webassembly/Cargo.toml @@ -14,7 +14,6 @@ aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", aws-credential-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["hardcoded-credentials"] } aws-sdk-lambda = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", default-features = false } aws-smithy-async = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", default-features = false } aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["event-stream"] } aws-smithy-runtime-api = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } aws-smithy-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } From 1744cbb504e0197fd4d8ce7b50e936c33dd9c41e Mon Sep 17 00:00:00 2001 From: David Souther Date: Sun, 15 Oct 2023 23:52:36 -0400 Subject: [PATCH 5/5] Final refactor fo run_all.sh --- rust_dev_preview/run_all.sh | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/rust_dev_preview/run_all.sh b/rust_dev_preview/run_all.sh index 988ef8537f1..af2eeb998ff 100755 --- a/rust_dev_preview/run_all.sh +++ b/rust_dev_preview/run_all.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +cd "$(dirname "$0")" + DIRS=( cross_service examples @@ -7,19 +9,27 @@ DIRS=( webassembly ) +ACTIONS=( + "fmt --check" + clippy + test +) + # Clean Cargo.log -rm rust_dev_preview/**/Cargo.lock +rm **/Cargo.lock export RUSTFLAGS="-D warnings" ; export APP_ENVIRONMENT="test" +CARGO="$HOME/.cargo/bin/cargo" + FAIL=() -for f in ${DIRS[@]} ; do - "$HOME/.cargo/bin/cargo" fmt --manifest-path rust_dev_preview/$f/Cargo.toml --all --check || FAIL+=("fmt:$f") - "$HOME/.cargo/bin/cargo" clippy --manifest-path rust_dev_preview/$f/Cargo.toml --all || FAIL+=("clippy:$f") - "$HOME/.cargo/bin/cargo" test --manifest-path rust_dev_preview/$f/Cargo.toml --all || FAIL+=("test:$f") +for f in "${DIRS[@]}" ; do + for a in "${ACTIONS[@]}" ; do + "$CARGO" $a --manifest-path $f/Cargo.toml --all || FAIL+=("${a}:$f") + done done -echo $FAIL; -exit "${#FAIL[@]}" +echo ${FAIL[@]} +exit ${#FAIL[@]}