Skip to content

Conversation

@cognifloyd
Copy link
Member

@cognifloyd cognifloyd commented Aug 12, 2022

Background

I'm working towards introducing pants. Eventually I would like to use pants to run tests to take advantage of the fine-grained per-file caching of results that accounts for dependencies by python files (pants infers the deps by reading the python files).

pants runs each test file separately in pytest. So, if two files try to modify the same database at the same time, we'll get strange results.

Overview

So, modify the db name for each parallel test to ensure that they can run safely in parallel.

Once we integrate pants, we will configure (in pants.toml) [pytest].execution_slot_var = "ST2TESTS_PARALLEL_SLOT" to take advantage of the env var introduced here.
https://www.pantsbuild.org/docs/reference-pytest#section-execution-slot-var

@cognifloyd cognifloyd added this to the 3.8.0 milestone Aug 12, 2022
@cognifloyd cognifloyd self-assigned this Aug 12, 2022
@pull-request-size pull-request-size bot added the size/XS PR that changes 0-9 lines. Quick fix/merge. label Aug 12, 2022
@cognifloyd cognifloyd requested review from a team, nzlosh and rush-skills August 12, 2022 19:12
@cognifloyd cognifloyd requested a review from Kami August 18, 2022 01:44
@cognifloyd cognifloyd enabled auto-merge (rebase) August 18, 2022 01:45
Copy link
Contributor

@nzlosh nzlosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cognifloyd cognifloyd force-pushed the parallel-db-tests branch 2 times, most recently from 3c7162c to a03fbc8 Compare August 19, 2022 14:47
@cognifloyd cognifloyd requested review from a team and removed request for rush-skills August 19, 2022 14:53
Copy link
Contributor

@winem winem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

pants runs each test file separately in pytest. So, if two files try to
modify the same database at the same time, we'll get strange results.
So, modify the db name to ensure that they are safe in parallel.
@cognifloyd cognifloyd merged commit d0e441a into master Aug 25, 2022
@cognifloyd cognifloyd deleted the parallel-db-tests branch August 25, 2022 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

database enhancement no changelog No Changelog.rst needed for this PR pantsbuild size/XS PR that changes 0-9 lines. Quick fix/merge. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants