Skip to content

fix(scaletest/workspacetraffic): wait for non-zero metrics before cancelling in TestRun #9663

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

Merged
merged 3 commits into from
Sep 13, 2023

Conversation

johnstcn
Copy link
Member

@johnstcn johnstcn commented Sep 13, 2023

Hopefully fixes #9661

@johnstcn johnstcn changed the title fix(scaletest/workspacetraffic): TestRun: wait for non-zero metrics before cancelling fix(scaletest/workspacetraffic): wait for non-zero metrics before cancelling in TestRun Sep 13, 2023
@johnstcn johnstcn marked this pull request as ready for review September 13, 2023 14:03
Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

Fingers crossed!

require.NoError(t, runner.Run(ctx, "", &logs), "unexpected error calling Run()")

gotMetrics := make(chan struct{})
go func() {
Copy link
Member

Choose a reason for hiding this comment

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

nit: I'm always confused if there is a possibility of a routine leak. defer goes first then routine is killed, right?

Copy link
Member Author

@johnstcn johnstcn Sep 13, 2023

Choose a reason for hiding this comment

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

Defer runs when the surrounding function returns. So assert.Eventually() has to finish before gotMetrics is closed, and <-gotMetrics will block until that happens. Then we cancel the context passed to runner.Run, which will cause it to exit, then we close runDone, which unblocked <-runDone.

I think goleak would have caught a goroutine leak here as well.

@johnstcn johnstcn merged commit 3be783b into main Sep 13, 2023
@johnstcn johnstcn deleted the cj/flake-workspacetraffic-testrun-pty branch September 13, 2023 14:54
@github-actions github-actions bot locked and limited conversation to collaborators Sep 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test flake: scaletest/workspacetraffic TestRun/PTY
3 participants