tailcall icon indicating copy to clipboard operation
tailcall copied to clipboard

Implement http_spec tests with actual running mock server

Open meskill opened this issue 2 years ago • 2 comments

The problem

Current http_spec test implementation has some limitations:

  • to implement mocks it uses custom HttpClient implementation and the test partially reimplements logic how tailcall server is started. Those implementation could diverge with original implementation and brings burden of supporting both versions of code for actual and test run.
  • assertions with config file like yml for specifying tests doesn't allow to test complex cases like caching, wildcard routes, testing passed headers. Also, it's harder to implement testing for custom protocols, e.g. grpc
  • the tests don't make actual http requests to the mock upstream that could hide possible issues with app that lie in http layer

Solution

Implement mocks for http_spec as separate server (for example, with mockito crate)

That should allow to bypass the limitations above:

  • we will test actual http requests to the mock server
  • we won't need to reimplement server handling for tests and can just start tailcall with different configurations
  • will be able to test more complex cases when we want to test batch requests, caching mechanic

Acceptance terms

When testing http behaviour:

  • we can run mock server
  • we can define mocks for server that could match the request ignoring order of parts of the requests (for example ignore query params order to test batching is worked despite the order)
  • we can start tailcall server based on test config and that will automatically pointed to the mock server as upstream servers
  • we can assert mocks in terms that they were called, what response we've got from tailcall, how many times the mock was called

meskill avatar Nov 29 '23 15:11 meskill

Can you provide a few examples of what we aren't able to test right now but still fall within the scope of http spec.

tusharmath avatar Dec 02 '23 10:12 tusharmath

Can you provide a few examples of what we aren't able to test right now but still fall within the scope of http spec.

I've updated the description with more details and with expected solution

meskill avatar Dec 20 '23 20:12 meskill

Action required: Issue inactive for 30 days. Status update or closure in 7 days.

github-actions[bot] avatar Feb 02 '24 19:02 github-actions[bot]

Issue closed after 7 days of inactivity.

github-actions[bot] avatar Feb 09 '24 20:02 github-actions[bot]