Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make mongo tests safer to run in parallel #5707

Merged
merged 1 commit into from
Aug 25, 2022
Merged

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 nzlosh, rush-skills and a team 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.
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.

None yet

3 participants