feat(tests): add local integration test suite for proxy and plugins#13
feat(tests): add local integration test suite for proxy and plugins#13nik-localstack wants to merge 2 commits into
Conversation
87aba3e to
1c4344d
Compare
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1c4344d to
17640a3
Compare
cloutierMat
left a comment
There was a problem hiding this comment.
Great first push into having a consistent way of testing the proxy on its own! I left a few question/comment but nothing major. Thanks for the initiative 🚀
| ## Which command should I use? | ||
|
|
||
| - Fastest full local run with disposable Postgres: `make test` | ||
| - Run only proxy tests (using your own Postgres): `python -m pytest tests/test_proxy.py -vv` | ||
| - Run only plugin tests: `python -m pytest tests/test_plugins.py -vv` | ||
|
|
||
| ## 1) Full local suite (recommended) | ||
|
|
||
| `make test` starts a temporary PostgreSQL container, waits for readiness, sets DB env vars, then runs: | ||
|
|
||
| ```bash | ||
| python -m pytest -vv | ||
| ``` | ||
|
|
||
| Use it when you want one command that matches normal contributor workflow. | ||
|
|
||
| ```bash | ||
| make test | ||
| ``` | ||
|
|
||
| ## 2) DB-backed proxy tests against an existing PostgreSQL | ||
|
|
||
| If you already have PostgreSQL running, set connection env vars and run only proxy tests: | ||
|
|
||
| ```bash | ||
| export E2E_PG_HOST=127.0.0.1 | ||
| export E2E_PG_PORT=5432 | ||
| export E2E_PG_USER=postgres | ||
| export E2E_PG_PASSWORD=postgres | ||
| export E2E_PG_DB=postgres | ||
| python -m pytest tests/test_proxy.py -vv | ||
| ``` | ||
|
|
||
| If PostgreSQL is not reachable, tests fail fast at startup. | ||
|
|
||
| ## 3) Plugin integration tests | ||
|
|
||
| ```bash | ||
| python -m pytest tests/test_plugins.py -vv | ||
| ``` | ||
|
|
||
| Requires PostgreSQL to be running with the `E2E_PG_*` env vars set (see section 2). |
There was a problem hiding this comment.
This could probably be simplified a bit it is quite verbose, with 2 and 3 being essentially the same. Basically, there are 2 ways to run the tests, one using the postgres with a managed lifecycle and the other with an external postgres instance
| - Run only proxy tests (using your own Postgres): `python -m pytest tests/test_proxy.py -vv` | ||
| - Run only plugin tests: `python -m pytest tests/test_plugins.py -vv` | ||
|
|
||
| ## 1) Full local suite (recommended) |
There was a problem hiding this comment.
nit: we could probably make it clearer this is under ## Which command should I use? by adding making this a header 3 instead with ### 1) Full local suite (recommended)
| err_tail = "\n".join((result.stderr or "").splitlines()[-20:]) | ||
| pytest.fail( | ||
| "psql -f batch failed over SSL via proxy " | ||
| f"(run={run_idx + 1}, rc={result.returncode}, elapsed={elapsed:.2f}s) " |
There was a problem hiding this comment.
nit: elapsed={elapsed:.2f} can also be simplified as {elapsed=:.2f}
e60886b to
6125cff
Compare
|
Thanks @cloutierMat I addressed the review comments and also made a small follow-up cleanup in the last commit: moved the testing guide into the root README.md, pinned test/lint dependencies, and added a proper python -m postgresql_proxy entry point. |
Stacked on #12.
This PR adds end-to-end and plugin integration tests, along with shared test fixtures for a disposable PostgreSQL container. It also adds local testing and linting workflows via
Makefiletargets, moves the testing guide into the rootREADME.md, pins test/lint dependencies, and adds apython -m postgresql_proxyentry point.Changes
tests/test_proxy.py: proxy behavior tests for connection handling, SSL, and hang regressions, includingtest_psql_ssl_file_batch_stress_no_hangfor UNC-472tests/test_plugins.py: plugin integration tests for HLL rewrite behaviortests/conftest.py: shared fixtures with a disposable PostgreSQL containerMakefiletargets:install-test,install-lint,lint, andtest(spins up a local Docker PostgreSQL container)requirements-test.txtandrequirements-lint.txtwith pinned dependenciesREADME.mdand updateInstalling/Runningsections for Python 3.13+postgresql_proxy/__main__.pyso the proxy can be started withpython -m postgresql_proxysetup.pyclassifiers for Python 3.13+