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

miniature-lamp-45970

08/28/2020, 12:30 AM
What is the recommended way to set environment variables that are used within integration tests? Is there an option within python_tests Build Rule to pass environment variables?
w

witty-crayon-22786

08/28/2020, 1:02 AM
there is not a mechanism right now: but if you’re able to describe your usecase on https://github.com/pantsbuild/pants/issues/10644 it will help us implement it soon
m

miniature-lamp-45970

08/28/2020, 1:09 AM
Thanks @witty-crayon-22786, added the my usecase in the issue which is for integration testing. Is there a flag that can i set to disable running tests parallely in pants.
w

witty-crayon-22786

08/28/2020, 1:12 AM
you can adjust the parallelism, but it will affect more than tests: it will affect all processes that pants spawns: see
--process-execution-local-parallelism
on https://www.pantsbuild.org/v2.0/docs/reference-global , which defaults to the number of cores on your machine
why do you want to limit the parallelism?
m

miniature-lamp-45970

08/28/2020, 1:16 AM
@witty-crayon-22786 It is just because we have written integration tests that depend on executing tests in a single thread and not parallely. We are moving from depending on real db, to mocking the Data access layer. Until then need a stop gap solution, limiting the parallelism might work. It is going to be painful! Should be using it only for a few days
w

witty-crayon-22786

08/28/2020, 1:17 AM
so, if you are able to create “numbered” database instances (0 through N), you might be able to use the
--pytest-execution-slot-var
option: https://www.pantsbuild.org/v2.0/docs/reference-pytest
while a test is running, it will have a unique execution slot number.
(…for that instance of pants, at least.)
m

miniature-lamp-45970

08/28/2020, 1:18 AM
okie
Btw, that's a cool feature
❤️ 2
h

hundreds-father-404

08/28/2020, 2:54 AM
Another option is to use
./pants test --debug
, which will run all your tests sequentially in the foreground. It’s not recommended because you lose both parallelism and caching, but it would run them all sequentially
5 Views