Are there any recommendations on how to run python...
# general
a
Are there any recommendations on how to run python tests that interact with a postgresql database concurrently? I'm hitting concurrency issues despite having used
[pytest].execution_slot_var
(extensions for example), so am now thinking about isolating at the process-level (i.e. having a dedicated temporary postgresql instance per
execution_slot_var
)
h
How are you using
execution_slot_var
today? It is intended to be used to point each test at a separate logical database
You may not need a dedicated postgresql instance, but at least a dedicated tablespace
a
I am suffixing its value to each db name when we create a DB. We do that per
unittest.TestCase
mostly
I'm seeing the sharded dbs get created, but we have alembic migrations that create extensions, and apparently those can race (since multiple `unittest.TestCase`s can run in the same execution slot I'm guessing)
Now that I'm typing this out would it be easier to run 1
unittest.TestCase
per execution slot?
h
Multiple test files can run per slot, yes, depending on how you have test batching set up
But if you have multiple TestCases per file then even single file per batch won't save you...
a
Yeah there are some places where we have more than one TestCase per file. We also subclass it to set up migrations per class etc so without much refactoring the easiest thing to do was to spawn a dedicated pg instance per TestCase. Should hold us over until after we migrate. Would be nice to refactor our test setup afterwards...