https://pantsbuild.org/ logo
#general
Title
# general
h

happy-family-315

07/27/2022, 8:30 AM
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

wide-midnight-78598

07/27/2022, 12:10 PM
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

happy-family-315

07/27/2022, 12:13 PM
Yes some tests use a shared database.
w

wide-midnight-78598

07/27/2022, 12:16 PM
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

happy-kitchen-89482

07/27/2022, 2:16 PM
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

wide-midnight-78598

07/27/2022, 3:23 PM
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
3 Views