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

rich-dawn-84724

11/05/2021, 2:40 PM
Hello 👋 I'm wondering if there is any way to configure a particular
python_tests
target to to run in series? Using pants 2.7
👋 2
Use case: I'm attempting to introduce pants to an existing repository, which has a test suite relying on
pytest-docker
to bring up a backing service which the tests share (not unlike a test database in Django). Obviously if this happens for all tests, there may be port conflicts etc. In the ideal world, the tests would be independent, but I'm wondering if there's any way to sacrifice parallelism as a workaround.
c

clean-city-64472

11/05/2021, 3:22 PM
If you can tolerate having
n
docker instances running where
n
is the number of concurrent executions, you can use the
execution_slot_var = "PANTS_EXECUTION_SLOT"
config value to broker tests between the different docker instances. This how we handle boostrapping multiple copies of the DB when running tests in a parallel environemt. Basically the
PANTS_EXEUCTION_SLOT
environment variable is a number between
1
and
n
that we use to name/reference a DB.
👀 1
👍 1
If you want only one docker you could hardcode a list of targets (or use tags) and run tests just for those targets with concurrency set to 1.
r

rich-dawn-84724

11/05/2021, 4:00 PM
Thank you! 🙏 Execution slot vars seem promising
with concurrency set to 1
How does one set concurrency to 1? I noticed there is a
--no-concurrent
option, but this seems to be related to pants invocations rather than test runs (and is the default behaviour).
h

happy-kitchen-89482

11/05/2021, 4:15 PM
But of course you are slowing down your builds quite a bit if you forgo concurrency, so if you can run N backing services and use the
execution_slot_var
mechanism to assign a unique one to each running test you'd get the best of both worlds!
Even if N is smaller than the number of cores (which is the default concurrency setting) but greater than 1 that's still a partial win!
2 Views