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

Run server httpRequestTests and httpMalformedRequestTests against actual Services #1212

Closed
david-perez opened this issue Feb 21, 2022 · 2 comments
Assignees
Labels
good first issue Good for newcomers server Rust server SDK

Comments

@david-perez
Copy link
Contributor

Currently, we're deserializing requests manually in server httpRequestTest protocol tests. That is, we build the HTTP request and then call from_request() on the operation input wrapper struct corresponding to the operation associated with the test that was passed into ServerProtocolTestGenerator. We then assert that what we've deserialized is what we expected in params.

Instead, we should be running the actual service defined in the Smithy model of the protocol test. Maybe not run a Hyper server over localhost, but at the very least invoking the tower::Service that we get from the OperationRegistry. This is a "higher-level" test that has some advantages over how we're currently doing things:

  • we test a larger surface area:
    • construction of the OperationRegistry, conversion into the Router Service,
    • the routing logic in Router (we could have protocol tests specifically exercising possibly ambiguous routing decisions),
  • the test does not need to pull in internal details of the framework like the operation wrapper structs, or the FromRequest/IntoResponse traits, to which the service implementer does not have access in their code,
  • we get to use the method field from the test cases; as of now we're ignoring it and sending only GET requests, and none of the tests have failed because there's no exercised code path that looks at the HTTP method (if our Router had been in the code path, it would have caught a possible failure),

Overall we get more assurances.

Note though that the actual assertions against paramss would be made inside the operation handlers that we'd code-generate (perhaps as closures). It's unclear what we should return from the operation handlers though, unless the output operation struct is Default.

For httpMalformedRequestTests, the assertions are against HTTP responses, so they'd continue to go in the test functions.

Note that this approach is also how awslabs/smithy-typescript operates.

@david-perez david-perez added the server Rust server SDK label Feb 22, 2022
@weihanglo weihanglo self-assigned this Aug 19, 2022
@david-perez david-perez changed the title Run server httpRequestTests against actual Services Run server httpRequestTests and httpMalformedRequestTests against actual Services Sep 28, 2022
@david-perez
Copy link
Contributor Author

We're just missing running the httpMalformedRequestTests against actual services using the same approach we've taken for the httpRequestTests.

@jjant
Copy link
Contributor

jjant commented Oct 31, 2022

Completed in #1904.

@jjant jjant closed this as completed Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers server Rust server SDK
Projects
None yet
Development

No branches or pull requests

3 participants