Skip to content

Add t.Parallel() to several tsh tests#28470

Merged
jakule merged 1 commit intomasterfrom
jakule/add-missing-parallel
Jul 3, 2023
Merged

Add t.Parallel() to several tsh tests#28470
jakule merged 1 commit intomasterfrom
jakule/add-missing-parallel

Conversation

@jakule
Copy link
Copy Markdown
Contributor

@jakule jakule commented Jun 29, 2023

Added the t.Parallel() function call in each test function to enable parallel test execution. This should reduce the overall time it takes to run all these tests by enabling them to run concurrently.

Added the `t.Parallel()` function call in each test function to enable parallel test execution. This should reduce the overall time it takes to run all these tests by enabling them to run concurrently.
@jakule jakule marked this pull request as ready for review June 29, 2023 18:58
@github-actions github-actions Bot requested a review from ibeckermayer June 29, 2023 18:58
@github-actions github-actions Bot added size/sm tsh tsh - Teleport's command line tool for logging into nodes running Teleport. labels Jun 29, 2023
@github-actions github-actions Bot requested a review from ryanclark June 29, 2023 18:58
@ibeckermayer
Copy link
Copy Markdown
Contributor

Potentially worth running these in parallel manually like

func TestTest(t *testing.T) {
    for i := 0; i < 10; i++ {
        t.Run(fmt.Sprintf("iteration %d", i), TestTheTestIWantToRepro)
    }
}

to double check that it doesn't cause issues.

@jakule
Copy link
Copy Markdown
Contributor Author

jakule commented Jul 3, 2023

Potentially worth running these in parallel manually like

func TestTest(t *testing.T) {
    for i := 0; i < 10; i++ {
        t.Run(fmt.Sprintf("iteration %d", i), TestTheTestIWantToRepro)
    }
}

to double check that it doesn't cause issues.

Is there any difference between this method and go test -count=10?

@jakule jakule enabled auto-merge July 3, 2023 16:51
@jakule jakule added this pull request to the merge queue Jul 3, 2023
Merged via the queue into master with commit c29765b Jul 3, 2023
@jakule jakule deleted the jakule/add-missing-parallel branch July 3, 2023 17:11
@public-teleport-github-review-bot
Copy link
Copy Markdown

@jakule See the table below for backport results.

Branch Result
branch/v13 Create PR

@ibeckermayer
Copy link
Copy Markdown
Contributor

Potentially worth running these in parallel manually like

func TestTest(t *testing.T) {
    for i := 0; i < 10; i++ {
        t.Run(fmt.Sprintf("iteration %d", i), TestTheTestIWantToRepro)
    }
}

to double check that it doesn't cause issues.

Is there any difference between this method and go test -count=10?

Yes I believe there is. Subtests and Sub-benchmarks gives the examples:

image

showing how to cause tests run in parallel with and only with each other. So the example code I gave would have the TestTheTestIWantToRepro running in parallel 10 times (with itself).

OTOH as far as I've been able to tell, -count=10 simply runs the entire test suite 10 times sequentially. So, presuming you're just running a single test rather than the entire suite, a call like

go test -count=10 -run ^TestTheTestIWantToRepro$

won't run anything in parallel, it will just run TestTheTestIWantToRepro 10 times, one after the other.

If you're running the entire test suite then it's a different story, as the test in question will be run parallel to other t.Parallel() tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/sm tsh tsh - Teleport's command line tool for logging into nodes running Teleport.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants