Skip to content

Commit 83c606f

Browse files
authored
switch integration tests to new test-utils (#3898)
## Motivation and Context Follow up PR to #3888 ## Description * Update `aws/sdk/integration-tests` to use the `test-util` feature(s) directly from `aws-smithy-http-client` rather than `aws-smithy-runtime` * ~Refactor `aws-smithy-http` to use `http-1.x~ * Fixed an erroneous error message from `imds` credentials provider in passing while tracking down a test failure * Fixed a few tests that were not immune to environment variables (e.g. on dev desktop `AWS_EC2_METADATA_ENABLED=false` is set by default and was causing some test failures) I started pulling at some threads and found them to be quite load bearing (e.g. `inlineable/serialization_settings.rs`) and would require updating all of codegen to use `http-1.x`. ~This PR is a bit of a half step with some stop gaps put into place (e.g. the new `compat` feature of `aws-smithy-http` or inlining a function) to prevent the need to update everything in a single PR. Future PR's will continue where I left off here. ~ One lesson I learned the hard way was that our integration test `Cargo.toml` have to reflect codegen. I had updated them to all use `http = "1"` and got it all working only to realize codegen generates `http = "0.2.9"` and `http-1x = { package = "http", version = "1"}` and thus the integration tests have to look the same as that. ### Future * ~Continue to refactor `aws-smithy-http` to upgrade to `http-body-1.x`. ~ * Refactor codegen to update to `http-1.x` UPDATE: I reverted the update to http 1.x for `aws-smithy-http`. This needs to be done and planned with the server and I don't want it to unnecessarily block hyper 1. We will pursue the remaining hyper 1 changes and then make a decision on internal use of http and http-body pre 1.x usage. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
1 parent 633f715 commit 83c606f

File tree

104 files changed

+757
-930
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+757
-930
lines changed

aws/rust-runtime/Cargo.lock

Lines changed: 16 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aws/rust-runtime/aws-config/Cargo.lock

Lines changed: 14 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aws/rust-runtime/aws-config/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "aws-config"
3-
version = "1.5.10"
3+
version = "1.6.0"
44
authors = [
55
"AWS Rust SDK Team <[email protected]>",
66
"Russell Cohen <[email protected]>",
@@ -35,7 +35,7 @@ aws-smithy-runtime-api = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-runtim
3535
aws-smithy-types = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-types" }
3636
aws-types = { path = "../../sdk/build/aws-sdk/sdk/aws-types" }
3737
bytes = "1.1.0"
38-
http = "0.2.4"
38+
http = "1"
3939
time = { version = "0.3.4", features = ["parsing"] }
4040
tokio = { version = "1.13.1", features = ["sync"] }
4141
tracing = { version = "0.1" }
@@ -55,6 +55,7 @@ aws-sdk-ssooidc = { path = "../../sdk/build/aws-sdk/sdk/ssooidc", default-featur
5555

5656
[dev-dependencies]
5757
aws-smithy-runtime = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-runtime", features = ["client", "connector-hyper-0-14-x", "test-util"] }
58+
aws-smithy-http-client = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-http-client", features = ["test-util"] }
5859
aws-smithy-runtime-api = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-runtime-api", features = ["test-util"] }
5960
futures-util = { version = "0.3.29", default-features = false }
6061
tracing-test = "0.2.4"

aws/rust-runtime/aws-config/src/default_provider/credentials.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@ mod test {
352352
use crate::provider_config::ProviderConfig;
353353
use aws_credential_types::provider::error::CredentialsError;
354354
use aws_smithy_async::rt::sleep::TokioSleep;
355+
use aws_smithy_http_client::test_util::NeverTcpConnector;
355356
use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder;
356-
use aws_smithy_runtime::client::http::test_util::NeverTcpConnector;
357357

358358
tokio::time::pause();
359359
let conf = ProviderConfig::no_configuration()

aws/rust-runtime/aws-config/src/ecs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
use crate::http_credential_provider::HttpCredentialProvider;
5959
use crate::provider_config::ProviderConfig;
6060
use aws_credential_types::provider::{self, error::CredentialsError, future, ProvideCredentials};
61-
use aws_smithy_runtime::client::endpoint::apply_endpoint;
61+
use aws_smithy_http::endpoint::apply_endpoint;
6262
use aws_smithy_runtime_api::client::dns::{ResolveDns, ResolveDnsError, SharedDnsResolver};
6363
use aws_smithy_runtime_api::client::http::HttpConnectorSettings;
6464
use aws_smithy_runtime_api::shared::IntoShared;
@@ -498,7 +498,7 @@ mod test {
498498
use aws_credential_types::Credentials;
499499
use aws_smithy_async::future::never::Never;
500500
use aws_smithy_async::rt::sleep::TokioSleep;
501-
use aws_smithy_runtime::client::http::test_util::{ReplayEvent, StaticReplayClient};
501+
use aws_smithy_http_client::test_util::{ReplayEvent, StaticReplayClient};
502502
use aws_smithy_runtime_api::client::dns::DnsFuture;
503503
use aws_smithy_runtime_api::client::http::HttpClient;
504504
use aws_smithy_runtime_api::shared::IntoShared;

aws/rust-runtime/aws-config/src/http_credential_provider.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl ClassifyRetry for HttpCredentialRetryClassifier {
220220
mod test {
221221
use super::*;
222222
use aws_credential_types::provider::error::CredentialsError;
223-
use aws_smithy_runtime::client::http::test_util::{ReplayEvent, StaticReplayClient};
223+
use aws_smithy_http_client::test_util::{ReplayEvent, StaticReplayClient};
224224
use aws_smithy_types::body::SdkBody;
225225
use http::{Request, Response, Uri};
226226
use std::time::SystemTime;

aws/rust-runtime/aws-config/src/imds/client.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,9 +582,7 @@ pub(crate) mod test {
582582
use crate::provider_config::ProviderConfig;
583583
use aws_smithy_async::rt::sleep::TokioSleep;
584584
use aws_smithy_async::test_util::{instant_time_and_sleep, InstantSleep};
585-
use aws_smithy_runtime::client::http::test_util::{
586-
capture_request, ReplayEvent, StaticReplayClient,
587-
};
585+
use aws_smithy_http_client::test_util::{capture_request, ReplayEvent, StaticReplayClient};
588586
use aws_smithy_runtime::test_util::capture_test_logs::capture_test_logs;
589587
use aws_smithy_runtime_api::client::interceptors::context::{
590588
Input, InterceptorContext, Output,

aws/rust-runtime/aws-config/src/imds/credentials.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,12 @@ impl ImdsCredentialsProvider {
208208

209209
async fn retrieve_credentials(&self) -> provider::Result {
210210
if self.imds_disabled() {
211-
tracing::debug!(
212-
"IMDS disabled because AWS_EC2_METADATA_DISABLED env var was set to `true`"
211+
let err = format!(
212+
"IMDS disabled by {} env var set to `true`",
213+
super::env::EC2_METADATA_DISABLED
213214
);
214-
return Err(CredentialsError::not_loaded(
215-
"IMDS disabled by AWS_ECS_METADATA_DISABLED env var",
216-
));
215+
tracing::debug!(err);
216+
return Err(CredentialsError::not_loaded(err));
217217
}
218218
tracing::debug!("loading credentials from IMDS");
219219
let profile: Cow<'_, str> = match &self.profile {
@@ -289,7 +289,7 @@ mod test {
289289
use crate::provider_config::ProviderConfig;
290290
use aws_credential_types::provider::ProvideCredentials;
291291
use aws_smithy_async::test_util::instant_time_and_sleep;
292-
use aws_smithy_runtime::client::http::test_util::{ReplayEvent, StaticReplayClient};
292+
use aws_smithy_http_client::test_util::{ReplayEvent, StaticReplayClient};
293293
use aws_smithy_types::body::SdkBody;
294294
use std::time::{Duration, UNIX_EPOCH};
295295
use tracing_test::traced_test;
@@ -322,6 +322,7 @@ mod test {
322322
]);
323323
let client = ImdsCredentialsProvider::builder()
324324
.imds_client(make_imds_client(&http_client))
325+
.configure(&ProviderConfig::no_configuration())
325326
.build();
326327
let creds1 = client.provide_credentials().await.expect("valid creds");
327328
let creds2 = client.provide_credentials().await.expect("valid creds");
@@ -468,6 +469,7 @@ mod test {
468469
let expected = aws_credential_types::Credentials::for_tests();
469470
let provider = ImdsCredentialsProvider::builder()
470471
.imds_client(client)
472+
.configure(&ProviderConfig::no_configuration())
471473
// seed fallback credentials for testing
472474
.last_retrieved_credentials(expected.clone())
473475
.build();
@@ -515,6 +517,7 @@ mod test {
515517
]);
516518
let provider = ImdsCredentialsProvider::builder()
517519
.imds_client(make_imds_client(&http_client))
520+
.configure(&ProviderConfig::no_configuration())
518521
.build();
519522
let creds1 = provider.provide_credentials().await.expect("valid creds");
520523
assert_eq!(creds1.access_key_id(), "ASIARTEST");

aws/rust-runtime/aws-config/src/imds/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ mod test {
120120
use crate::imds::region::ImdsRegionProvider;
121121
use crate::provider_config::ProviderConfig;
122122
use aws_smithy_async::rt::sleep::TokioSleep;
123-
use aws_smithy_runtime::client::http::test_util::{ReplayEvent, StaticReplayClient};
123+
use aws_smithy_http_client::test_util::{ReplayEvent, StaticReplayClient};
124124
use aws_smithy_types::body::SdkBody;
125125
use aws_types::region::Region;
126126
use tracing_test::traced_test;

aws/rust-runtime/aws-config/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ mod loader {
943943
use crate::{defaults, ConfigLoader};
944944
use aws_credential_types::provider::ProvideCredentials;
945945
use aws_smithy_async::rt::sleep::TokioSleep;
946-
use aws_smithy_runtime::client::http::test_util::{infallible_client_fn, NeverClient};
946+
use aws_smithy_http_client::test_util::{infallible_client_fn, NeverClient};
947947
use aws_smithy_runtime::test_util::capture_test_logs::capture_test_logs;
948948
use aws_types::app_name::AppName;
949949
use aws_types::origin::Origin;

aws/rust-runtime/aws-config/src/sso/token.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,9 @@ mod tests {
406406
use aws_smithy_async::rt::sleep::TokioSleep;
407407
use aws_smithy_async::test_util::instant_time_and_sleep;
408408
use aws_smithy_async::time::{StaticTimeSource, TimeSource};
409-
use aws_smithy_runtime::test_util::capture_test_logs::capture_test_logs;
409+
use aws_smithy_http_client::test_util::{capture_request, ReplayEvent, StaticReplayClient};
410410
use aws_smithy_runtime::{
411-
assert_str_contains,
412-
client::http::test_util::{capture_request, ReplayEvent, StaticReplayClient},
411+
assert_str_contains, test_util::capture_test_logs::capture_test_logs,
413412
};
414413
use aws_smithy_runtime_api::client::http::HttpClient;
415414
use aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder;

aws/rust-runtime/aws-config/src/sts/assume_role.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,7 @@ mod test {
335335
use aws_smithy_async::rt::sleep::{SharedAsyncSleep, TokioSleep};
336336
use aws_smithy_async::test_util::instant_time_and_sleep;
337337
use aws_smithy_async::time::StaticTimeSource;
338-
use aws_smithy_runtime::client::http::test_util::{
339-
capture_request, ReplayEvent, StaticReplayClient,
340-
};
338+
use aws_smithy_http_client::test_util::{capture_request, ReplayEvent, StaticReplayClient};
341339
use aws_smithy_runtime::test_util::capture_test_logs::capture_test_logs;
342340
use aws_smithy_runtime_api::client::behavior_version::BehaviorVersion;
343341
use aws_smithy_types::body::SdkBody;

0 commit comments

Comments
 (0)