Reputation: 21
I want to be able to run a bunch of tests against databases in parallel. For this, I use a docker postgres image that I can deploy in containers that are mapped to ports 5432+n where 0 <= n <=16. Each test knows which container it is supposed to talk to, as it has a resource portoffset.
The different tests need different data. Rather than populating the data in each test individually, I figured it might be better to have images with a lot of data that can be reused by multiple tests. Since I do not want to pollute the disk too much with those images when running all tests or building everything (I found that even kilobyte sized db inserts result in mb sized image layers), I build the images as setup and cleanup via CTest rather than during build.
Here's the thing now: I want that at most M of those images exist at any given time.
I found that I cannot achieve this by assigning a resource to the setup/teardown tests. I would have to attach the resource to the fixture itself instead, which does not seem to be supported.
Any ideas how to achieve what I need?
I think I could run a 17th database with port offset -1 and have the setup/teardown tasks increment and decrement a counter, but that seems like a crazy hack. Also, there's no one who could ensure that CTest doesn't schedule all the setup tests before any of the actual tests.
Upvotes: 0
Views: 17