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 for HTTP Proxy #314

Open
nadiamoe opened this issue Aug 23, 2023 · 0 comments
Open

Add tests for HTTP Proxy #314

nadiamoe opened this issue Aug 23, 2023 · 0 comments

Comments

@nadiamoe
Copy link
Member

Currently, the HTTP proxy only has tests for validations. Request handling and manipulation is tested, albeit at the handler level. This is fine for these request tests, but as more responsibilities are added to the proxy, such as initializing and reporting metrics (#312), these gaps start to show up.

The main blocker to add tests to the HTTP proxy is that, on its Start method, it sets up a listener according to an address supplied through configuration:

p.srv = &http.Server{
Addr: p.config.ListenAddress,
Handler: handler,
}
err = p.srv.ListenAndServe()

Unfortunately, this does not allow parallel tests to be created as the port needs to be chosen in advance, and it is not possible to pick a port that is guaranteed to be unused. The GRPC Proxy is tested, and works around this problem by listening on a unix socket on a randomly generated path. This is, however, not possible to do for HTTP servers.

A possible solution for this could be to move initialization of the listener outside of the HTTP proxy, pass that listener in the constructor, and replace p.srv.ListenAndServe with p.srv.Serve(p.listener) with p.listener being this new listener. This, however, is not free from drawbacks, as it would move the responsibility of creating a listener upwards to the command, which already has a fair amount of responsibilities.

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

No branches or pull requests

1 participant