From a88fff1afddc7dfa2a6fc0408489e55def4be0d2 Mon Sep 17 00:00:00 2001 From: Russell Cohen Date: Tue, 27 Jul 2021 10:15:46 -0400 Subject: [PATCH] breaking: Remove make test-util and optional feature (#608) * breaking: Remove make test-util and optional feature for historical reasons, `test-util` was enabled by default in aws-hyper. This change: * removes the pub use for test util in aws-hyper * updates usages to use it in smithy-client * updates the crate dependencies to correctly pull in the new feature but only for development NOTE: please wait for a full cargoTest all crates prior to merging this change. * Update CHANGELOG.md * fix non-optional smithy client dependencies * Update CHANGELOG.md Co-authored-by: John DiSanti Co-authored-by: John DiSanti --- CHANGELOG.md | 6 ++++++ aws/rust-runtime/aws-hyper/Cargo.toml | 7 ++----- aws/rust-runtime/aws-hyper/src/lib.rs | 3 --- aws/rust-runtime/aws-hyper/tests/e2e_test.rs | 2 +- aws/rust-runtime/aws-types/Cargo.toml | 2 +- .../amazon/smithy/rustsdk/FluentClientGenerator.kt | 5 ++--- .../amazon/smithy/rustsdk/IntegrationTestDependencies.kt | 6 +++--- aws/sdk/integration-tests/dynamodb/tests/movies.rs | 2 +- aws/sdk/integration-tests/kms/tests/integration.rs | 2 +- aws/sdk/integration-tests/qldbsession/tests/integration.rs | 2 +- aws/sdk/integration-tests/s3/tests/signing-it.rs | 2 +- .../amazon/smithy/rust/codegen/rustlang/CargoDependency.kt | 2 +- .../codegen/smithy/generators/FluentClientDecorator.kt | 4 ++-- rust-runtime/smithy-client/Cargo.toml | 2 +- rust-runtime/smithy-client/src/test_connection.rs | 2 +- 15 files changed, 24 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8b73b217..d0b707172 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## vNext (Month Day Year) +**Breaking changes** +* `test-util` has been made an optional dependency and has moved from + aws-hyper to smithy-http. If you were relying on `aws_hyper::TestConnection`, add `smithy-client` as a dependency + and enable the optional `test-util` feature. This prunes some unnecessary dependencies on `roxmltree` and `serde_json` + for most users. (#608) + **New This Week** - :bug: Bugfix: Fix parsing bug where whitespace was stripped when parsing XML (#590) - Establish common abstraction for environment variables (#594) diff --git a/aws/rust-runtime/aws-hyper/Cargo.toml b/aws/rust-runtime/aws-hyper/Cargo.toml index 395bc2229..d40ed47e9 100644 --- a/aws/rust-runtime/aws-hyper/Cargo.toml +++ b/aws/rust-runtime/aws-hyper/Cargo.toml @@ -8,8 +8,7 @@ license = "Apache-2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] -test-util = ["protocol-test-helpers"] -default = ["test-util"] +default = [] native-tls = ["hyper-tls", "smithy-client/native-tls"] rustls = ["hyper-rustls", "smithy-client/rustls"] @@ -35,13 +34,11 @@ tokio = { version = "1", features = ["time"] } pin-project = "1" tracing = "0.1" -protocol-test-helpers = { path = "../../../rust-runtime/protocol-test-helpers", optional = true } - [dev-dependencies] tokio = { version = "1", features = ["full", "test-util"] } tower-test = "0.4.0" aws-types = { path = "../aws-types" } +smithy-client = { path = "../../../rust-runtime/smithy-client", features = ["test-util"] } [[test]] name = "e2e_test" -required-features = ["test-util"] diff --git a/aws/rust-runtime/aws-hyper/src/lib.rs b/aws/rust-runtime/aws-hyper/src/lib.rs index 7e121d16d..4248c384a 100644 --- a/aws/rust-runtime/aws-hyper/src/lib.rs +++ b/aws/rust-runtime/aws-hyper/src/lib.rs @@ -3,9 +3,6 @@ * SPDX-License-Identifier: Apache-2.0. */ -#[doc(inline)] -pub use smithy_client::test_connection; - pub use smithy_client::retry::Config as RetryConfig; use aws_auth::middleware::CredentialsStage; diff --git a/aws/rust-runtime/aws-hyper/tests/e2e_test.rs b/aws/rust-runtime/aws-hyper/tests/e2e_test.rs index e8a196f43..039adc245 100644 --- a/aws/rust-runtime/aws-hyper/tests/e2e_test.rs +++ b/aws/rust-runtime/aws-hyper/tests/e2e_test.rs @@ -8,7 +8,6 @@ use aws_endpoint::partition::endpoint::{Protocol, SignatureVersion}; use aws_endpoint::set_endpoint_resolver; use aws_http::user_agent::AwsUserAgent; use aws_http::AwsErrorRetryPolicy; -use aws_hyper::test_connection::TestConnection; use aws_hyper::{Client, RetryConfig}; use aws_sig_auth::signer::OperationSigningConfig; use aws_types::region::Region; @@ -16,6 +15,7 @@ use aws_types::SigningService; use bytes::Bytes; use http::header::{AUTHORIZATION, HOST, USER_AGENT}; use http::{Response, Uri}; +use smithy_client::test_connection::TestConnection; use smithy_http::body::SdkBody; use smithy_http::operation; use smithy_http::operation::Operation; diff --git a/aws/rust-runtime/aws-types/Cargo.toml b/aws/rust-runtime/aws-types/Cargo.toml index 0b3cda3ff..bd41fb50e 100644 --- a/aws/rust-runtime/aws-types/Cargo.toml +++ b/aws/rust-runtime/aws-types/Cargo.toml @@ -18,4 +18,4 @@ serde_json = "1" arbitrary = "1" [build-dependencies] -rustc_version = "0.3.3" +rustc_version = "0.4.0" diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/FluentClientGenerator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/FluentClientGenerator.kt index 236cccedc..d4544c501 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/FluentClientGenerator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/FluentClientGenerator.kt @@ -17,7 +17,6 @@ import software.amazon.smithy.rust.codegen.rustlang.RustType import software.amazon.smithy.rust.codegen.rustlang.RustWriter import software.amazon.smithy.rust.codegen.rustlang.asOptional import software.amazon.smithy.rust.codegen.rustlang.asType -import software.amazon.smithy.rust.codegen.rustlang.contains import software.amazon.smithy.rust.codegen.rustlang.documentShape import software.amazon.smithy.rust.codegen.rustlang.render import software.amazon.smithy.rust.codegen.rustlang.rust @@ -48,7 +47,7 @@ class FluentClientDecorator : RustCodegenDecorator { rustCrate.withModule(RustModule("client", module)) { writer -> FluentClientGenerator(protocolConfig).render(writer) } - val awsHyper = protocolConfig.runtimeConfig.awsHyper().name + val awsHyper = "aws-hyper" rustCrate.addFeature(Feature("client", true, listOf(awsHyper))) rustCrate.addFeature(Feature("rustls", default = true, listOf("$awsHyper/rustls"))) rustCrate.addFeature(Feature("native-tls", default = false, listOf("$awsHyper/native-tls"))) @@ -76,8 +75,8 @@ class FluentClientGenerator(protocolConfig: ProtocolConfig) { TopDownIndex.of(protocolConfig.model).getContainedOperations(serviceShape).sortedBy { it.id } private val symbolProvider = protocolConfig.symbolProvider private val model = protocolConfig.model - private val hyperDep = protocolConfig.runtimeConfig.awsHyper().copy(optional = true) private val runtimeConfig = protocolConfig.runtimeConfig + private val hyperDep = runtimeConfig.awsRuntimeDependency("aws-hyper").copy(optional = true) fun render(writer: RustWriter) { writer.rustTemplate( diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt index 83694a60e..cb03b3078 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt @@ -49,7 +49,8 @@ class IntegrationTestDependencies( override fun section(section: LibRsSection) = when (section) { LibRsSection.Body -> writable { if (hasTests) { - addDependency(runtimeConfig.awsHyper().copy(scope = DependencyScope.Dev)) + val smithyClient = CargoDependency.SmithyClient(runtimeConfig).copy(features = listOf("test-util"), scope = DependencyScope.Dev) + addDependency(smithyClient) addDependency(SerdeJson) addDependency(Tokio) } @@ -62,6 +63,5 @@ class IntegrationTestDependencies( } val Criterion = CargoDependency("criterion", CratesIo("0.3"), scope = DependencyScope.Dev) -val SerdeJson = CargoDependency("serde_json", CratesIo("1"), features = emptyList()) +val SerdeJson = CargoDependency("serde_json", CratesIo("1"), features = emptyList(), scope = DependencyScope.Dev) val Tokio = CargoDependency("tokio", CratesIo("1"), features = listOf("macros", "test-util"), scope = DependencyScope.Dev) -fun RuntimeConfig.awsHyper() = awsRuntimeDependency("aws-hyper", features = listOf("test-util")) diff --git a/aws/sdk/integration-tests/dynamodb/tests/movies.rs b/aws/sdk/integration-tests/dynamodb/tests/movies.rs index d4f8a00bd..83a30aca3 100644 --- a/aws/sdk/integration-tests/dynamodb/tests/movies.rs +++ b/aws/sdk/integration-tests/dynamodb/tests/movies.rs @@ -6,7 +6,6 @@ use aws_sdk_dynamodb as dynamodb; use aws_http::AwsErrorRetryPolicy; -use aws_hyper::test_connection::TestConnection; use aws_hyper::{SdkError, SdkSuccess}; use aws_sdk_dynamodb::input::CreateTableInput; use dynamodb::error::DescribeTableError; @@ -21,6 +20,7 @@ use dynamodb::{Config, Credentials, Region}; use http::header::{HeaderName, AUTHORIZATION}; use http::Uri; use serde_json::Value; +use smithy_client::test_connection::TestConnection; use smithy_http::body::SdkBody; use smithy_http::operation::Operation; use smithy_http::retry::ClassifyResponse; diff --git a/aws/sdk/integration-tests/kms/tests/integration.rs b/aws/sdk/integration-tests/kms/tests/integration.rs index cb9a4cf2a..d0472c6ed 100644 --- a/aws/sdk/integration-tests/kms/tests/integration.rs +++ b/aws/sdk/integration-tests/kms/tests/integration.rs @@ -5,13 +5,13 @@ use aws_auth::Credentials; use aws_http::user_agent::AwsUserAgent; -use aws_hyper::test_connection::TestConnection; use aws_hyper::{Client, SdkError}; use aws_sdk_kms as kms; use http::header::AUTHORIZATION; use http::Uri; use kms::operation::GenerateRandom; use kms::{Config, Region}; +use smithy_client::test_connection::TestConnection; use smithy_http::body::SdkBody; use std::time::{Duration, UNIX_EPOCH}; diff --git a/aws/sdk/integration-tests/qldbsession/tests/integration.rs b/aws/sdk/integration-tests/qldbsession/tests/integration.rs index bb5a68753..fa1ffc7f4 100644 --- a/aws/sdk/integration-tests/qldbsession/tests/integration.rs +++ b/aws/sdk/integration-tests/qldbsession/tests/integration.rs @@ -5,13 +5,13 @@ use aws_auth::Credentials; use aws_http::user_agent::AwsUserAgent; -use aws_hyper::test_connection::TestConnection; use aws_hyper::Client; use aws_sdk_qldbsession as qldbsession; use http::Uri; use qldbsession::model::StartSessionRequest; use qldbsession::operation::SendCommand; use qldbsession::{Config, Region}; +use smithy_client::test_connection::TestConnection; use smithy_http::body::SdkBody; use std::time::{Duration, UNIX_EPOCH}; diff --git a/aws/sdk/integration-tests/s3/tests/signing-it.rs b/aws/sdk/integration-tests/s3/tests/signing-it.rs index 756e8b493..fc6090bbd 100644 --- a/aws/sdk/integration-tests/s3/tests/signing-it.rs +++ b/aws/sdk/integration-tests/s3/tests/signing-it.rs @@ -4,9 +4,9 @@ */ use aws_http::user_agent::AwsUserAgent; -use aws_hyper::test_connection::TestConnection; use aws_sdk_s3::operation::ListObjectsV2; use aws_sdk_s3::{Credentials, Region}; +use smithy_client::test_connection::TestConnection; use smithy_http::body::SdkBody; use std::time::{Duration, UNIX_EPOCH}; diff --git a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/rustlang/CargoDependency.kt b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/rustlang/CargoDependency.kt index 7bf28d430..81972bb8d 100644 --- a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/rustlang/CargoDependency.kt +++ b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/rustlang/CargoDependency.kt @@ -178,7 +178,7 @@ data class CargoDependency( fun SmithyHttp(runtimeConfig: RuntimeConfig) = runtimeConfig.runtimeCrate("http") fun SmithyHttpTower(runtimeConfig: RuntimeConfig) = runtimeConfig.runtimeCrate("http-tower") - fun SmithyClient(runtimeConfig: RuntimeConfig) = runtimeConfig.runtimeCrate("client", true) + fun SmithyClient(runtimeConfig: RuntimeConfig) = runtimeConfig.runtimeCrate("client") fun ProtocolTestHelpers(runtimeConfig: RuntimeConfig) = CargoDependency( "protocol-test-helpers", runtimeConfig.runtimeCrateLocation.crateLocation(), scope = DependencyScope.Dev diff --git a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/FluentClientDecorator.kt b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/FluentClientDecorator.kt index 6b0331903..56fbff23f 100644 --- a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/FluentClientDecorator.kt +++ b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/FluentClientDecorator.kt @@ -280,7 +280,7 @@ class FluentClientGenerator(protocolConfig: ProtocolConfig) { M: #{client}::bounds::SmithyMiddleware, R: #{client}::retry::NewRequestPolicy, """, - "client" to CargoDependency.SmithyClient(runtimeConfig).asType(), + "client" to clientDep.asType(), ) { rustTemplate( """ @@ -301,7 +301,7 @@ class FluentClientGenerator(protocolConfig: ProtocolConfig) { "ok" to symbolProvider.toSymbol(operation.outputShape(model)), "operation_err" to operation.errorSymbol(symbolProvider), "sdk_err" to CargoDependency.SmithyHttp(runtimeConfig).asType().copy(name = "result::SdkError"), - "client" to CargoDependency.SmithyClient(runtimeConfig).asType(), + "client" to clientDep.asType(), ) members.forEach { member -> val memberName = symbolProvider.toMemberName(member) diff --git a/rust-runtime/smithy-client/Cargo.toml b/rust-runtime/smithy-client/Cargo.toml index c37f59290..669364c4c 100644 --- a/rust-runtime/smithy-client/Cargo.toml +++ b/rust-runtime/smithy-client/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0" [features] test-util = ["protocol-test-helpers"] -default = ["test-util", "hyper", "rustls"] +default = ["hyper", "rustls"] native-tls = ["hyper", "hyper-tls"] rustls = ["hyper", "hyper-rustls"] diff --git a/rust-runtime/smithy-client/src/test_connection.rs b/rust-runtime/smithy-client/src/test_connection.rs index 40693f611..29de07f91 100644 --- a/rust-runtime/smithy-client/src/test_connection.rs +++ b/rust-runtime/smithy-client/src/test_connection.rs @@ -2,7 +2,7 @@ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -//! Module with client connectors usefule for testing. +//! Module with client connectors useful for testing. // TODO #![allow(missing_docs)] -- GitLab