Skip to content
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

add: tests to ensure all interceptors are run if an error occurs in one #2664

Merged
merged 16 commits into from
May 8, 2023

Conversation

Velfi
Copy link
Contributor

@Velfi Velfi commented May 2, 2023

Motivation and Context

#2662

Description

This PR adds tests for all interceptor hooks to ensure the correct error handling behavior and defines a set of stub components for orchestrator testing.

Testing

This PR includes tests.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

add: stub components for orchestrator testing
@Velfi Velfi requested a review from a team as a code owner May 2, 2023 17:51
@github-actions
Copy link

github-actions bot commented May 2, 2023

A new generated diff is ready to view.

  • AWS SDK (ignoring whitespace)
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@Velfi Velfi requested a review from a team as a code owner May 3, 2023 14:45
@jjant
Copy link
Contributor

jjant commented May 3, 2023

You can write Closes #2662 in the PR description so that merging this PR will automatically close the issue, see: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue.

@Velfi
Copy link
Contributor Author

Velfi commented May 3, 2023

You can write Closes #2662 in the PR description so that merging this PR will automatically close the issue, see: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue.

I actually don't want to close that issue since I still have more work to do. This PR adds tests that check error handling flow for individual hooks. I'm going to create another PR that tests the behavior across multiple hooks, since most (IIRC) times we're still supposed to run the modify_before_completion hook before we exit invoke.

This PR was already getting a bit long and that's why I'm splitting the work up. I also wanted to make sure that I'm in-sync with John and the work he's doing.

@github-actions
Copy link

github-actions bot commented May 3, 2023

A new generated diff is ready to view.

  • AWS SDK (ignoring whitespace)
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@Velfi
Copy link
Contributor Author

Velfi commented May 3, 2023

I'm waiting on the changes introduced by #2670

Once those make it to main, I'll update this PR

@github-actions
Copy link

github-actions bot commented May 4, 2023

A new generated diff is ready to view.

  • AWS SDK (ignoring whitespace)
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

jdisanti
jdisanti previously approved these changes May 4, 2023
Copy link
Collaborator

@jdisanti jdisanti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

rust-runtime/aws-smithy-runtime/src/client/orchestrator.rs Outdated Show resolved Hide resolved
}

#[derive(Debug, Default)]
pub struct AnonymousAuthScheme {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a bunch of anonymous auth scheme stuff in crate::client::identity already. I think it belongs outside of test utils since it is a legitimate use case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a runtime plugin for anonymous auth that uses the pre-existing stuff. Let me know what you think.

ysaito1001
ysaito1001 previously approved these changes May 5, 2023
Copy link
Contributor

@ysaito1001 ysaito1001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the use of the interceptor_error_handling_test macro to simplify each test call site!

…eptor test

add: runtime plugin for anonymous auth
fix: clippy lints for explicit lifetimes
remove: test-utils endpoints and auth modules
Comment on lines -51 to -61
fn resolve_auth_options<'a>(
&'a self,
fn resolve_auth_options(
&self,
params: &AuthOptionResolverParams,
) -> Result<Cow<'a, [AuthSchemeId]>, BoxError>;
) -> Result<Cow<'_, [AuthSchemeId]>, BoxError>;
}

impl AuthOptionResolver for Box<dyn AuthOptionResolver> {
fn resolve_auth_options<'a>(
&'a self,
fn resolve_auth_options(
&self,
params: &AuthOptionResolverParams,
) -> Result<Cow<'a, [AuthSchemeId]>, BoxError> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linter was complaining about an unnecessary explicit lifetime here and in the auth option resolver so I switched it to an anonymous lifetime.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I take it to mean that the compiler deterministically derives the anomalous lifeitme in this case from the first &.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's what happens AFAICT

@@ -12,6 +12,7 @@ repository = "https://github.com/awslabs/smithy-rs"
[features]
default = []
http-auth = ["dep:zeroize"]
anonymous-auth = []
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, the anonymous auth stuff was always available. I added some more stuff related to anonymous auth and feature-gated it since we were already doing so for http-auth.

@@ -65,30 +68,6 @@ impl Identity {
}
}

#[derive(Debug)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to aws_smithy_runtime_api::client::identity::anonymous

@github-actions
Copy link

github-actions bot commented May 8, 2023

A new generated diff is ready to view.

  • AWS SDK (ignoring whitespace)
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

Comment on lines -51 to -61
fn resolve_auth_options<'a>(
&'a self,
fn resolve_auth_options(
&self,
params: &AuthOptionResolverParams,
) -> Result<Cow<'a, [AuthSchemeId]>, BoxError>;
) -> Result<Cow<'_, [AuthSchemeId]>, BoxError>;
}

impl AuthOptionResolver for Box<dyn AuthOptionResolver> {
fn resolve_auth_options<'a>(
&'a self,
fn resolve_auth_options(
&self,
params: &AuthOptionResolverParams,
) -> Result<Cow<'a, [AuthSchemeId]>, BoxError> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I take it to mean that the compiler deterministically derives the anomalous lifeitme in this case from the first &.

@github-actions
Copy link

github-actions bot commented May 8, 2023

A new generated diff is ready to view.

  • AWS SDK (ignoring whitespace)
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@Velfi Velfi added this pull request to the merge queue May 8, 2023
Merged via the queue into main with commit 97c70c4 May 8, 2023
@Velfi Velfi deleted the add/interceptor-error-handling-tests branch May 8, 2023 21:55
david-perez pushed a commit that referenced this pull request May 18, 2023
…ne (#2664)

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->
#2662

## Description
<!--- Describe your changes in detail -->
This PR adds tests for all interceptor hooks to ensure the correct error
handling behavior and defines a set of stub components for orchestrator
testing.

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
This PR includes tests.
----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
david-perez pushed a commit that referenced this pull request May 22, 2023
…ne (#2664)

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->
#2662

## Description
<!--- Describe your changes in detail -->
This PR adds tests for all interceptor hooks to ensure the correct error
handling behavior and defines a set of stub components for orchestrator
testing.

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
This PR includes tests.
----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
david-perez pushed a commit that referenced this pull request May 22, 2023
…ne (#2664)

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->
#2662

## Description
<!--- Describe your changes in detail -->
This PR adds tests for all interceptor hooks to ensure the correct error
handling behavior and defines a set of stub components for orchestrator
testing.

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
This PR includes tests.
----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants