What is the recommended way to set environment var...
# general
m
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
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
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
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
@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
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
okie
Btw, that's a cool feature
❤️ 2
h
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