testing: respect -parallel when t.Run is called concurrently - #80562
Open
harjothkhara wants to merge 1 commit into
Open
testing: respect -parallel when t.Run is called concurrently#80562harjothkhara wants to merge 1 commit into
harjothkhara wants to merge 1 commit into
Conversation
When t.Run is called concurrently from several goroutines, the sequential subtests it starts all share one running slot. Each of them released that slot to make room for its own parallel subtests, so with N concurrent callers the slot was released N times and up to N parallel tests ran at once, exceeding -parallel. Release the shared slot at most once, using a flag on the test that owns it, and let only that subtest reacquire it. Serve a reacquiring test after all tests waiting to start in parallel, so it cannot take a slot from a parallel test that is still waiting. Fixes golang#64470. Change-Id: I5e1774d87327b40442a6a9908dc39f63de05c942
Contributor
|
This PR (HEAD: a3b8fc9) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/805160. Important tips:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When t.Run is called concurrently from several goroutines, the
sequential subtests it starts all share one running slot. Each of them
released that slot to make room for its own parallel subtests, so with
N concurrent callers the slot was released N times and up to N parallel
tests ran at once, exceeding -parallel.
Release the shared slot at most once, using a flag on the test that
owns it, and let only that subtest reacquire it. Serve a reacquiring
test after all tests waiting to start in parallel, so it cannot take a
slot from a parallel test that is still waiting.
Fixes #64470.