Skip to content

Conversation

baalimago
Copy link

@baalimago baalimago commented Sep 16, 2025

This PR will setup testing for all the python native packages which have a test defined.

Read the README section! TL;DR:

  1. Deploy the app
  2. Run ./testing/run-all-tests-via-api.py --host https://build-scripts.wasmer.<env> --port 443 to run all tests on edge

@baalimago baalimago requested a review from zebreus September 16, 2025 16:57
@baalimago baalimago force-pushed the qa-209-convert-build-scripts-into-a-python-test-project branch from 503999d to 26265fb Compare September 17, 2025 05:15
@baalimago baalimago force-pushed the qa-209-convert-build-scripts-into-a-python-test-project branch from 304df25 to a943e0c Compare September 17, 2025 05:23
@baalimago baalimago force-pushed the qa-209-convert-build-scripts-into-a-python-test-project branch from de01f92 to 79b03a3 Compare September 17, 2025 06:13
@baalimago baalimago force-pushed the qa-209-convert-build-scripts-into-a-python-test-project branch from b987678 to 232ca57 Compare September 17, 2025 14:20
A bit liberal in that commit summary, but it's not entirely wrong.

We don't yet have support for pytest, which was the original plan. So
instead I've re-engineered Lennart's solution, but in python (since I
couldn't get his solution to work).

What we get is a python script which runs all the tests found in ./tests
(or as specified as TEST_DIR). It also tracks success/failures, so it
does the same things as pytest, but bare minimum for our usecase.
@baalimago baalimago force-pushed the qa-209-convert-build-scripts-into-a-python-test-project branch from 232ca57 to ecba365 Compare September 17, 2025 14:22
This way we can call the checks whenever we want. And hopefully shipit
can do whatever magic it does to make it #justwork when deployed to edge
Although the <api>/check endpoint worked just fine locally, it times out
the workload on edge. So we need to be able to call each test one by
one.

So in addition to this, I added a <api>/list endpoint which lists all
tests, then a /check/<test> endpoint which calls a singular test. This
allows us to run just a specific test, if need be.

Also added instructions on how this works to README.md
@baalimago baalimago force-pushed the qa-209-convert-build-scripts-into-a-python-test-project branch from 729addf to 24467a3 Compare September 18, 2025 11:39
@baalimago baalimago marked this pull request as ready for review September 18, 2025 11:39
Comment on lines +9 to +17
def _has_network() -> bool:
try:
socket.getaddrinfo("httpbin.org", 443)
return True
except Exception:
return False


HAS_NET = _has_network()
Copy link
Collaborator

Choose a reason for hiding this comment

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

good idea

Copy link
Author

Choose a reason for hiding this comment

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

Hmm, I noticed that it only works with pytest, which we don't support (yet!). I wrote this when I had the intent of using pytest, instead of needing to write my own version

So it always fails on this, and requests aren't tested. But perhaps it's fine?


Run tests:

- `uv pip compile pyproject.toml --python-version=3.13 --universal --extra-index-url https://pythonindex.wasix.org/simple --index-url=https://pypi.org/simple --emit-index-url --only-binary :all: -o wasmer-requirements.txt`
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you may be able to convert the test script to a PEP 723 script with URL based specifiers. That way we should be able to just uv run the tests.

Copy link
Author

Choose a reason for hiding this comment

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

I don't really know what that means or how it would work. These preconditionals are just copy-pasted from what Syrus had in the fastapi template.

I vote for out of scope/future improvement!

@baalimago baalimago force-pushed the qa-209-convert-build-scripts-into-a-python-test-project branch from 3ec07f7 to be1323e Compare September 18, 2025 16:17
@baalimago baalimago force-pushed the qa-209-convert-build-scripts-into-a-python-test-project branch from be1323e to 953ffe4 Compare September 18, 2025 16:21
@baalimago baalimago changed the title feat: Setup local testing with pytest feat(QA-200): Automated pythonindex package tests Sep 18, 2025
@baalimago baalimago requested a review from zebreus September 18, 2025 16:31
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.

2 participants