-
Notifications
You must be signed in to change notification settings - Fork 891
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
Conversation
return test.banner, nil | ||
} | ||
client.mu.Unlock() | ||
time.Sleep(updateInterval) | ||
<-ready | ||
<-ready // Wait for two updates to ensure the value has propagated. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this 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" |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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!
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:
After (additionally, these 10s are available for parallel execution of other tests):