Today we create a brand new test database for each test, it's completely empty, and then we populate the database with ordered_actions to fill it with the DDL/data we need in the tests.
The idea is that we make use of postgres' template database feature which replicates the state of a database from another database (which happens always, just your default template template1 is empty by default). We avoid tons of python/sqlalchemy stuff, and presumably postgres is optimized to do what it does quickly.
Large test suite
Before: 1204 passed, 3 errors in 1458.88s (0:24:18) (funnily, i got errors on the head version, didn't look into why)
After (Statements, as-is): 1207 passed in 433.54s (0:07:13)
After (Statements -> StaticStatements): 1207 passed in 383.83s (0:06:23)
The above is with -n 4 parallelism. the numbers get better as you increase parallelism. I stopped the original suite after 40 mins without parallelism, whereas with this PR it took 17m (faster than the parallelized pre-PR version)
For pytest-mock-resources' own test suite, it's essentially the same or slightly slower overall because there necessarily tends to be close to a 1-to-1 correspondence between each test and its fixture to test PMR's fixture args/features.
Today we create a brand new test database for each test, it's completely empty, and then we populate the database with
ordered_actions
to fill it with the DDL/data we need in the tests.The idea is that we make use of postgres' template database feature which replicates the state of a database from another database (which happens always, just your default template
template1
is empty by default). We avoid tons of python/sqlalchemy stuff, and presumably postgres is optimized to do what it does quickly.Large test suite
The above is with
-n 4
parallelism. the numbers get better as you increase parallelism. I stopped the original suite after 40 mins without parallelism, whereas with this PR it took 17m (faster than the parallelized pre-PR version)For pytest-mock-resources' own test suite, it's essentially the same or slightly slower overall because there necessarily tends to be close to a 1-to-1 correspondence between each test and its fixture to test PMR's fixture args/features.