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

Suggestion: ASGI compliance tests #248

Open
simonw opened this issue Mar 28, 2021 · 6 comments
Open

Suggestion: ASGI compliance tests #248

simonw opened this issue Mar 28, 2021 · 6 comments

Comments

@simonw
Copy link
Contributor

simonw commented Mar 28, 2021

I'm always excited to see new ASGI hosting implementations emerge - today I've been trying out this wrapper for Azure Functions for example: Azure/azure-functions-python-library#75

It would be great if there was a really robust way to put these new implementations through their paces. asgiref seems like it might be the right place for that to exist.

My initial idea is a solution with two parts:

  • An ASGI application function that takes the incoming scope and receive arguments, reads from them and sends back a big JSON response derived from what came in
  • A Python script that can be pointed at that hosted function and then sends a carefully curated set of requests to it and verifies that the response comes back as expected

I have a ASGI function that returns the repr of the scope which I use to test out new implementations by eyeballing them - eg here: https://azure-functions-datasette.azurewebsites.net/-/asgi-scope - I'm imagining something a bit like that which pairs up with a asgi-test https://azure-functions-datasette.azurewebsites.net/-/asgi-scope command-line script (which calls a Python function).

@simonw
Copy link
Contributor Author

simonw commented Mar 28, 2021

So three questions:

  • Does this already exist somewhere?
  • If not, should this live in asgiref or in a separate project?
  • Anyone interested in working with me to build this thing?

@simonw
Copy link
Contributor Author

simonw commented Mar 28, 2021

I think there's a lot to be said for implementation-independent test suites like http://acid3.acidtests.org/

@simonw
Copy link
Contributor Author

simonw commented Mar 28, 2021

It strikes me that the first version of this doesn't need to be 100% comprehensive to be useful - just covering things like the default scope keys and making sure they are bytes or strings would be a big win for people trying to spin up new ASGI implementations.

I'd love to build asgi-to-wsgi (see #109) and this would make it a lot easier!

@andrewgodwin
Copy link
Member

There isn't one of these, and I do agree there should be - I've usually called these "acceptance" or "compliance" test suites, and it would help a lot in enforcing that the spec is actually adhered to.

It'd be a little tricky to test both directions given the async nature of both ASGI and its servers - making it robust in the face of all the different event loop implementations is tricky - but it's probably possible.

@simonw simonw changed the title Suggestion: ASGI implementation testing framework Suggestion: ASGI compliance tests Mar 29, 2021
@simonw
Copy link
Contributor Author

simonw commented Mar 29, 2021

I like the term "compliance" for this. Getting it to work for all aspects of async ASGI does sound tricky, but I think just the basics of the HTTP spec (which is the bit that I'm seeing the most activity around) should be achievable without too much trouble.

@Kludex
Copy link
Contributor

Kludex commented Dec 27, 2022

Are you still interested in this @simonw? I'm willing to help here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants