Hello, I want to use pants test to do some testing...
# general
h
Hello, I want to use pants test to do some testing in python including database tests. I got >400 test cases and I am really happy that pants runs tests in parallel. But there are a lot of problems, when multiple database tests run at the same time, because they are all changing the database so that many tests are failing. Is there any solution to this problem except using [test].debug = true which disables parallelims?
w
Does this mean that your tests use a shared, common database? Do all of your tests use the database, or just some of them?
h
Yes some tests use a shared database.
w
I'm not sure how to do this offhand, but could those tests be serialized into one partition/set, and the rest in parallel?
h
Ah, this is what the
execution_slot_var
option is for: https://www.pantsbuild.org/docs/reference-pytest#section-execution-slot-var
🤯 1
You set it to the name of an env var, and then at test time Pants sets that env var to an integer from 0 to #parallelism_slots
So you set up #parallelism_slots databases once, and you use that env var to point to a specific one
Does that make sense? Not sure I'm explaining it welll
w
I think that would be a great addition to https://www.pantsbuild.org/docs/python-test-goal - I've seen questions of this flavour asked a couple of times in Slack, and usually the OP lands on asking how to serialize all tests. If this option allows selective parallelism, that's wayyy better