promote aws-smithy-mocks out of experimental (#4098)
Motivation and Context
- https://github.com/smithy-lang/smithy-rs/issues/4074
- https://github.com/smithy-lang/smithy-rs/issues/3926
Description
- Rename
aws-smithy-mocks-experimental
toaws-smithy-mocks
and reset version to0.1.0
- Fix #3926 by having
mock_client!
macro always set an HTTP client. By default it returns a dummy I’m a teapot response to aid in debugging and be easy to tell where that response is coming from. Also when a rule sets an HTTP response it is not set as an extension in the request and returned by the HTTP client. This allows for more thorough and accurate integration testing as the client/runtime will see the response coming from the HTTP client instead of being ignored and then replaced as it was before- Added a new sequence builder API for allowing a rule to generate more than one response. This allows for testing retries for example.
- Also deleted a hyper 1.x test that is no longer needed and was ignored anyway
Questions
- In this PR I’ve simply renamed/moved
aws-smithy-mocks-experimental
toaws-smithy-mocks
. Do we want or need to publish one last version ofaws-smithy-mocks-experimental
with a deprecated API that instructs users it has moved? Alternatively we could publish an informational advisory notice about the rename. We don’t currently promote the crate anywhere and the dev guide will get updated so I’m on the fence for what we want to do.Testing
- Added new unit tests to exercise the API without needing an SDK client by leveraging the manual
Operation
APIs.- Added new integration tests for S3 to cover the macros and test the library e2e.
Checklist
- For changes to the smithy-rs codegen or runtime crates, I have created a changelog entry Markdown file in the
.changelog
directory, specifying “client,” “server,” or both in theapplies_to
key.- For changes to the AWS SDK, generated SDK code, or SDK runtime crates, I have created a changelog entry Markdown file in the
.changelog
directory, specifying “aws-sdk-rust” in theapplies_to
key.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Smithy Rust
Smithy code generators for Rust that generate clients, servers, and the entire AWS SDK. The latest unreleased SDK build can be found in aws-sdk-rust/next.
Design documentation
All internal and external interfaces are considered unstable and subject to change without notice.
Setup
./gradlew
will setup gradle for you. JDK 17 is required.stable-2
, i.e. the currentstable
Rust version and the prior two versions. Older versions may work.Development
For development, pre-commit hooks make it easier to pass automated linting when opening a pull request. Setup:
Project Layout
aws
: AWS specific codegen & Rust code (signing, endpoints, customizations, etc.) Common commands:./gradlew :aws:sdk:assemble
: Generate (but do not test / compile etc.) a fresh SDK intosdk/build/aws-sdk
./gradlew :aws:sdk:sdkTest
: Generate & run all tests for a fresh SDK. (Note that these tests require Go to be installed for FIP support to compile properly)./gradlew :aws:sdk:{cargoCheck, cargoTest, cargoDocs, cargoClippy}
: Generate & run specified cargo command.codegen-core
: Common code generation logic useful for clients and serverscodegen-client
: Whitelabel Smithy client code generationcodegen-client-test
: Smithy protocol test generation & integration tests for Smithy client whitelabel codedesign
: Design documentation. See the design/README.md for details about building / viewing.codegen-server
: Whitelabel Smithy server code generationcodegen-server-test
: Smithy protocol test generation & integration tests for Smithy server whitelabel codeexamples
: A collection of server implementation examplesTesting
Running all of smithy-rs’s tests can take a very long time, so it’s better to know which parts to test based on the changes being made, and allow continuous integration to find other issues when posting a pull request.
In general, the components of smithy-rs affect each other in the following order (with earlier affecting later):
rust-runtime
codegen
andcodegen-server
aws/rust-runtime
aws/sdk-codegen
Some components, such as
codegen-client-test
andcodegen-server-test
, are purely for testing other components.Testing
rust-runtime
andaws/rust-runtime
To test the
rust-runtime
crates:To test the
aws/rust-runtime
crates:Some runtime crates have a
additional-ci
script that can also be run. These scripts often requirecargo-hack
andcargo-udeps
to be installed.Testing Client/Server Codegen
To test the code generation, the following can be used:
Several Kotlin unit tests generate Rust projects and compile them. When these fail, they typically output links to the location of the generated code so that it can be inspected.
To look at generated code when the codegen tests fail, check these paths depending on the test suite that’s failing:
codegen-client-test/build/smithyprojections/codegen-client-test
codegen-server-test/build/smithyprojections/codegen-server-test
Testing SDK Codegen
See the readme in
aws/sdk/
for more information about these targets as they can be configured to generate more or less AWS service clients.The generated SDK will be placed in
aws/sdk/build/aws-sdk
.