Skip to content

test(agent): use afero for motd tests to allow parallel execution #8329

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
Jul 6, 2023

Conversation

mafredri
Copy link
Member

@mafredri mafredri commented Jul 5, 2023

This PR uses afero.Fs to read mtod so that test can be run in parallel. A small race-issue is also fixed in the motd update test where we didn't have a guarantee that the service banner value had propagated yet.

Before:

ok  	github.com/coder/coder/agent	38.457s

After (additionally, these 10s are available for parallel execution of other tests):

ok  	github.com/coder/coder/agent	10.758s

return test.banner, nil
}
client.mu.Unlock()
time.Sleep(updateInterval)
<-ready
<-ready // Wait for two updates to ensure the value has propagated.
Copy link
Member Author

Choose a reason for hiding this comment

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

Review: This is the race fix, if we only wait for one ready, the service banner may not yet be stored in the agents atomic pointer.

Copy link
Member

Choose a reason for hiding this comment

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

Ahh good find! Thank you for fixing!

@mafredri mafredri requested review from code-asher and kylecarbs July 5, 2023 18:53
Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

That is a lovely reduction in execution time.

@@ -466,50 +467,51 @@ func TestAgent_Session_TTY_QuietLogin(t *testing.T) {
}

wantNotMOTD := "Welcome to your Coder workspace!"
wantServiceBanner := "Service banner text goes here"
wantMaybeServiceBanner := "Service banner text goes here"
Copy link
Member

Choose a reason for hiding this comment

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

👍 I like the use of maybe; I wish I had thought of that.

return test.banner, nil
}
client.mu.Unlock()
time.Sleep(updateInterval)
<-ready
<-ready // Wait for two updates to ensure the value has propagated.
Copy link
Member

Choose a reason for hiding this comment

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

Ahh good find! Thank you for fixing!

@mafredri mafredri merged commit 3f058f2 into main Jul 6, 2023
@mafredri mafredri deleted the mafredri/test-speed-up-motd-tests branch July 6, 2023 07:57
@github-actions github-actions bot locked and limited conversation to collaborators Jul 6, 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.

2 participants