Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

test: set test flags from within an init to limit maximum test parallelism#19575

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Emyrk merged 6 commits intomainfromstevenmasley/limit_parallel
Sep 17, 2025

Conversation

Emyrk
Copy link
Member

@EmyrkEmyrk commentedAug 27, 2025
edited
Loading

What this does

This limits the maximum test parallelism to8 by default, matching theMakefile. This will improve the success rate of runninggo test natively.

On systems with less than 8 cores (GOMAXPROCS < 8), this code is a no-op. The smaller number will still be the default. On those systems,go test may still fail due to resource contention between tests.

Manually setting-parallel=<n> still works exactly as expected

Example test and output with the max parallelism set to 1
package paralleltest_testimport ("strconv""testing""time"_"github.com/coder/coder/v2/coderd/coderdtest")varcount=0funcTestParallelism(t*testing.T) {t.Parallel()fori:=0;i<5;i++ {t.Run(strconv.Itoa(i),func(t*testing.T) {t.Parallel()count++time.Sleep(time.Second)})}}
go test ./... -v -count=1=== RUN   TestParallelism=== PAUSE TestParallelism=== CONT  TestParallelism=== RUN   TestParallelism/0=== PAUSE TestParallelism/0=== RUN   TestParallelism/1=== PAUSE TestParallelism/1=== RUN   TestParallelism/2=== PAUSE TestParallelism/2=== RUN   TestParallelism/3=== PAUSE TestParallelism/3=== RUN   TestParallelism/4=== PAUSE TestParallelism/4=== CONT  TestParallelism/0=== CONT  TestParallelism/2=== CONT  TestParallelism/1=== CONT  TestParallelism/4=== CONT  TestParallelism/3--- PASS: TestParallelism (0.00s)    --- PASS: TestParallelism/0 (1.00s)    --- PASS: TestParallelism/2 (1.00s)    --- PASS: TestParallelism/1 (1.00s)    --- PASS: TestParallelism/4 (1.00s)    --- PASS: TestParallelism/3 (1.00s)PASSok      github.com/coder/coder/v2/coderd/coderdtest/paralleltest        5.023s

When you manually set the parallel:

go test ./... -v -count=1 -parallel=5=== RUN   TestParallelism=== PAUSE TestParallelism=== CONT  TestParallelism=== RUN   TestParallelism/0=== PAUSE TestParallelism/0=== RUN   TestParallelism/1=== PAUSE TestParallelism/1=== RUN   TestParallelism/2=== PAUSE TestParallelism/2=== RUN   TestParallelism/3=== PAUSE TestParallelism/3=== RUN   TestParallelism/4=== PAUSE TestParallelism/4=== CONT  TestParallelism/0=== CONT  TestParallelism/4=== CONT  TestParallelism/3=== CONT  TestParallelism/1=== CONT  TestParallelism/2--- PASS: TestParallelism (0.00s)    --- PASS: TestParallelism/2 (1.00s)    --- PASS: TestParallelism/4 (1.00s)    --- PASS: TestParallelism/0 (1.00s)    --- PASS: TestParallelism/1 (1.00s)    --- PASS: TestParallelism/3 (1.00s)PASSok      github.com/coder/coder/v2/coderd/coderdtest/paralleltest        1.020s

@github-actionsgithub-actionsbot added the staleThis issue is like stale bread. labelSep 4, 2025
@EmyrkEmyrk reopened thisSep 12, 2025
@github-actionsgithub-actionsbot removed the staleThis issue is like stale bread. labelSep 13, 2025
@EmyrkEmyrk marked this pull request as ready for reviewSeptember 16, 2025 16:38
@EmyrkEmyrk changed the titletest: experimenting setting test flags from within an init()test: set test flags from within an init to limit maximum test parallelismSep 16, 2025
Copy link
Contributor

@dannykoppingdannykopping left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -0,0 +1,46 @@
package coderdtest
Copy link
Contributor

Choose a reason for hiding this comment

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

Only applies to this pkg? What about others likeclitest?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

We importcoderdtest in nearly every test. Any test that spins up a coderd will inherit thisinit function.

If there are some pkgs that do not import this, they probably do not need the parallism limit

dannykopping reacted with thumbs up emoji
@EmyrkEmyrk merged commit3df9d8e intomainSep 17, 2025
31 checks passed
@EmyrkEmyrk deleted the stevenmasley/limit_parallel branchSeptember 17, 2025 13:24
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsSep 17, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@dannykoppingdannykoppingdannykopping approved these changes

@johnstcnjohnstcnjohnstcn approved these changes

@spikecurtisspikecurtisspikecurtis approved these changes

Assignees

@EmyrkEmyrk

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@Emyrk@dannykopping@johnstcn@spikecurtis

[8]ページ先頭

©2009-2025 Movatter.jp