Skip to content

feat(tests): add local integration test suite for proxy and plugins#13

Merged
nik-localstack merged 3 commits into
masterfrom
unc-472-local-tests
May 15, 2026
Merged

feat(tests): add local integration test suite for proxy and plugins#13
nik-localstack merged 3 commits into
masterfrom
unc-472-local-tests

Conversation

@nik-localstack
Copy link
Copy Markdown

@nik-localstack nik-localstack commented May 12, 2026

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 Makefile targets, moves the testing guide into the root README.md, pins test/lint dependencies, and adds a python -m postgresql_proxy entry point.

Changes

  • Add tests/test_proxy.py: proxy behavior tests for connection handling, SSL, and hang regressions, including test_psql_ssl_file_batch_stress_no_hang for UNC-472
  • Add tests/test_plugins.py: plugin integration tests for HLL rewrite behavior
  • Add tests/conftest.py: shared fixtures with a disposable PostgreSQL container
  • Add Makefile targets: install-test, install-lint, lint, and test (spins up a local Docker PostgreSQL container)
  • Add requirements-test.txt and requirements-lint.txt with pinned dependencies
  • Move testing guide into root README.md and update Installing / Running sections for Python 3.13+
  • Add postgresql_proxy/__main__.py so the proxy can be started with python -m postgresql_proxy
  • Update setup.py classifiers for Python 3.13+

Copy link
Copy Markdown
Member

@cloutierMat cloutierMat left a comment

Choose a reason for hiding this comment

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

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 🚀

Comment thread tests/README.md Outdated
Comment on lines +21 to +62
## 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).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Comment thread tests/README.md Outdated
- 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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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)

Comment thread Makefile Outdated
Comment thread Makefile Outdated
Comment thread tests/README.md Outdated
Comment thread tests/test_proxy.py
Comment thread tests/test_proxy.py Outdated
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) "
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: elapsed={elapsed:.2f} can also be simplified as {elapsed=:.2f}

Comment thread tests/test_proxy.py Outdated
@nik-localstack
Copy link
Copy Markdown
Author

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.

Copy link
Copy Markdown
Member

@cloutierMat cloutierMat left a comment

Choose a reason for hiding this comment

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

Thanks for the follow up!

My apologies, I still had one pending comment, I never pushed during the previous review. I think it can be addressed as a follow up though. I think the current process of the make test command is a bit backward and could use some cleanup to be more user friendly.

Feel free to merge so we can start working on the CI PR 🚀

Comment thread Makefile Outdated
@nik-localstack nik-localstack changed the base branch from unc-472-fix-ssl-copy-stall to master May 15, 2026 09:46
@nik-localstack nik-localstack merged commit d3bdfb9 into master May 15, 2026
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