forked from pgbouncer/pgbouncer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a python testing framework (pgbouncer#792)
This changes our testing infrastructure to use python instead of bash. Both `test/test.sh` and `test/ssl/test.sh` and have been completely coverted to python. The main reason I want to introduce this change is because Bash is one of the worst languages to write tests in. One of the main goals of tests is to find unexpected errors. And bash makes it very easy not to notice such errors. This made it quite hard for me to write correct tests and review newly introduced tests in PRs for correctness. Another big reason I want this change is because writing tests for pgbouncer#666 requires running multiple pgbouncer processes at the same time. The bash infrastructure did not allow for this. The new python testing infrastructure. Finally there's some other advantages that this new test infrastructure brings: 1. Tests can be run in parallel, which makes them go **much** faster. The duration of the test step in CI is now ~1 minute for non valgrind runs and ~2 minutes for valgrind runs. With the bash testing infrastructure these timings were 5.5 minutes and ~8 minutes respectively. 2. Running tests with `valgrind` locally is now as simple as `ENABLE_VALGRIND=1 pytest -n auto` 3. Some tests would not run on some OSes (e.g. ssl tests on windows). I made sure almost all are now fully cross platform (for the platforms we support in CI). 4. `USE_SUDO=1` tests are now run in CI on MacOS and FreeBSD. (I confirmed `USE_SUDO=1` works with Linux on my local machine, but was unable to get it working in CI due to `iptables` not being allowed in the CI containers). How to run tests can be found in the updated `test/README.md` file. PS. I haven't tested with OpenBSD, since I don't have access to such a machine. I'm fairly confident that the tests will run fine though, since they pass on all CI plaftorms (including MacOS and FreeBSD). But if anyone else has access to an OpenBSD box, it would be great if you could test that tests pass there as well.
- Loading branch information
Showing
28 changed files
with
2,427 additions
and
2,235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ | |
*.exe | ||
*.gz | ||
*.swp | ||
.venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[tool.pytest.ini_options] | ||
addopts = [ | ||
"--import-mode=prepend", | ||
"--showlocals", | ||
"--tb=short", | ||
] | ||
timeout = 30 | ||
|
||
# The asyncio_mode setting doesn't work on outdated versions of pytest-asyncio. | ||
# For python 3.6 no version is available that supports the asyncio_mode | ||
# setting, and for some of the older OSes Python 3.6 is the newest python | ||
# available. So @pytest.mark.asyncio is used everywhere instead. Once none of | ||
# our supported OSes require usage we can drop those marks and rely on the | ||
# asyncio_mode setting instead. | ||
# On these outdated versions having this setting in the config will throw a | ||
# warning, but we still add it anyway. The reason is that by adding it async | ||
# fixtures work on all versions, and are pretty much impossible to make work | ||
# otherwise without lots of version checks. So having a warning on outdated | ||
# versions is a small price to pay to not have to worry about that. | ||
asyncio_mode = 'auto' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pytest | ||
pytest-asyncio | ||
pytest-timeout | ||
pytest-xdist | ||
psycopg | ||
filelock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.