pgtap
pgtap copied to clipboard
Parallel testing with fixtures
Hey folks!
What would be the right way to test in parallel with setup fixtures?
I am thinking about something that will:
- Run my test in a separate isolated database using
CREATE DATABASE my_new_database TEMPLATE my_old_database;
(as a substitute forBEGIN; ROLLBACK;
capability which would be unavailable across multiple transactions) - Execute
runtests()
using the new database, with each stage run in parallel (with connections = function count for that stage) - Emit the test output
- Drop the newly created database
Am I missing anything here? This would be a pretty simple job to whip up in Python, and I'm happy to do it. I'm just wondering why this doesn't yet exist/isn't built into pg_prove already (which is phenomenal as-is! don't get me wrong!)
Thoughts?
I guess the -j
flag on pg_prove
doesn't work for runtests()
tests?
To be honest I haven't tried it, but don't you say that yourself in the docs? https://pgtap.org/documentation.html#runtests - ("Note that all tests executed by runtests() are run within a single transaction...")
On Thu, 11 Mar 2021, 12:29 David E. Wheeler, [email protected] wrote:
I guess the -j flag on pg_prove doesn't work for runtests() tests?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/theory/pgtap/issues/267#issuecomment-796384727, or unsubscribe https://github.com/notifications/unsubscribe-auth/AETC4JOQOFSR3T2KBL422QDTDAMF7ANCNFSM4Y2NUZTQ .
Yes, you're right, that's what the docs say. I think the simplest way to get parallelism is to create multiple test scripts, each of which runs a discrete subset of the tests, then use pg_prove -j
to run them all. Would be interesting to think about how one might do it in pg_prove
itself, but I don't think it can be done in pgTAP. Have you tried your approach with Python? Curious how it turned out.