-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Endpoint operation input tests #2204
Conversation
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/EndpointBuiltInsDecorator.kt
Show resolved
Hide resolved
aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkConfigDecorator.kt
Show resolved
Hide resolved
if (name.startsWith("S3")) { | ||
return null | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kinds of things does this skip? From my naïve point of view, it looks like we're filtering out stuff related to S3 in an S3 decorator, which I find strange.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was a double bug 🤕 good catch. It doesn't filter out anything because the builtIns start with AWS::S3
.
...sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/AwsEndpointDecorator.kt
Show resolved
Hide resolved
...egen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/OperationInputTestGenerator.kt
Outdated
Show resolved
Hide resolved
...egen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/OperationInputTestGenerator.kt
Outdated
Show resolved
Hide resolved
...egen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/OperationInputTestGenerator.kt
Outdated
Show resolved
Hide resolved
...egen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/OperationInputTestGenerator.kt
Outdated
Show resolved
Hide resolved
...egen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/OperationInputTestGenerator.kt
Show resolved
Hide resolved
...egen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/OperationInputTestGenerator.kt
Outdated
Show resolved
Hide resolved
...egen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/OperationInputTestGenerator.kt
Outdated
Show resolved
Hide resolved
aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/StripEndpointTrait.kt
Show resolved
Hide resolved
...kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RequiredCustomizations.kt
Show resolved
Hide resolved
...main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/EndpointsDecorator.kt
Outdated
Show resolved
Hide resolved
.../kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/EndpointTypesGenerator.kt
Show resolved
Hide resolved
...oftware/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt
Outdated
Show resolved
Hide resolved
...oftware/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt
Outdated
Show resolved
Hide resolved
...oftware/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt
Show resolved
Hide resolved
codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustType.kt
Outdated
Show resolved
Hide resolved
...e/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/Instantiator.kt
Show resolved
Hide resolved
codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/util/LetIf.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only had doc and naming-related comments. Good work on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for all the excellent comments!
rust("self") | ||
} | ||
|
||
// Attribute.CfgTest.render(this) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete
...sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/AwsEndpointDecorator.kt
Show resolved
Hide resolved
...kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RequiredCustomizations.kt
Show resolved
Hide resolved
aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/EndpointBuiltInsDecorator.kt
Show resolved
Hide resolved
if (name.startsWith("S3")) { | ||
return null | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was a double bug 🤕 good catch. It doesn't filter out anything because the builtIns start with AWS::S3
.
aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/StripEndpointTrait.kt
Show resolved
Hide resolved
.../kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/EndpointTypesGenerator.kt
Show resolved
Hide resolved
...oftware/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt
Outdated
Show resolved
Hide resolved
...oftware/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt
Show resolved
Hide resolved
...e/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/Instantiator.kt
Show resolved
Hide resolved
…mithy-rs into endpoint-operation-input-tests
7bb3ea7
to
9e17129
Compare
aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt
Outdated
Show resolved
Hide resolved
aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/EndpointBuiltInsDecorator.kt
Show resolved
Hide resolved
aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/EndpointBuiltInsDecorator.kt
Show resolved
Hide resolved
aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/EndpointBuiltInsDecorator.kt
Show resolved
Hide resolved
aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/EndpointBuiltInsDecorator.kt
Show resolved
Hide resolved
aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/EndpointBuiltInsDecorator.kt
Show resolved
Hide resolved
if (parameter.type == ParameterType.STRING) { | ||
rust(".clone()") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be better represented by implementing an is_not_copy
method on parameter
. However, since I don't see us adding a profusion of parameter types any time soon, you can probably just ignore this.
else -> null | ||
} | ||
|
||
override fun setBuiltInOnServiceConfig(name: String, value: Node, configBuilderRef: String): Writable? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should consider thinking of a word that means "this function constructs and returns a writable" and using it to name things like this. My reasoning is that this looks like something that sets a field in Kotlin when it actually creates rust code that sets something in Rust. I don't think we have too much of a problem with keeping Kotlin vs. Rust stuff straight in codegen, but I think it's worth considering and defining a boundary.
* | ||
* Doing this in AWS codegen allows us to actually integration test generated clients. | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | ||
* Generate `operationInputTests` for EP2 tests. | ||
* | ||
* These are `tests/` style integration tests that run as a public SDK user against a complete client. `capture_request` | ||
* is used to retrieve the URL. | ||
* | ||
* Example generated test: | ||
* ```rust | ||
* #[tokio::test] | ||
* async fn operation_input_test_get_object_119() { | ||
* /* builtIns: { | ||
* "AWS::Region": "us-west-2", | ||
* "AWS::S3::UseArnRegion": false | ||
* } */ | ||
* /* clientParams: {} */ | ||
* let (conn, rcvr) = aws_smithy_client::test_connection::capture_request(None); | ||
* let conf = { | ||
* #[allow(unused_mut)] | ||
* let mut builder = aws_sdk_s3::Config::builder() | ||
* .with_test_defaults() | ||
* .http_connector(conn); | ||
* let builder = builder.region(aws_types::region::Region::new("us-west-2")); | ||
* let builder = builder.use_arn_region(false); | ||
* builder.build() | ||
* }; | ||
* let client = aws_sdk_s3::Client::from_conf(conf); | ||
* let _result = dbg!(client.get_object() | ||
* .set_bucket(Some( | ||
* "arn:aws:s3-outposts:us-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint".to_owned() | ||
* )) | ||
* .set_key(Some( | ||
* "key".to_owned() | ||
* )) | ||
* .send().await); | ||
* rcvr.expect_no_request(); | ||
* let error = _result.expect_err("expected error: Invalid configuration: region from ARN `us-east-1` does not match client region `us-west-2` and UseArnRegion is `false` [outposts arn with region mismatch and UseArnRegion=false]"); | ||
* assert!(format!("{:?}", error).contains("Invalid configuration: region from ARN `us-east-1` does not match client region `us-west-2` and UseArnRegion is `false`"), "expected error to contain `Invalid configuration: region from ARN `us-east-1` does not match client region `us-west-2` and UseArnRegion is `false`` but it was {}", format!("{:?}", error)); | ||
* } | ||
* ``` | ||
* | ||
* Eventually, we need to pull this test into generic smithy. However, this relies on generic smithy clients | ||
* supporting middleware and being instantiable from config (https://github.com/awslabs/smithy-rs/issues/2194) | ||
* | ||
* Doing this in AWS codegen allows us to actually integration test generated clients. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
Motivation and Context
Endpoints 2.0 exposes integration-style tests–we need to use those (and this found a bug!)
Description
with_test_defaults()
which we can start using after this PRTesting
Checklist
CHANGELOG.next.toml
if I made changes to the smithy-rs codegen or runtime cratesCHANGELOG.next.toml
if I made changes to the AWS SDK, generated SDK code, or SDK runtime cratesBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.