- Notifications
You must be signed in to change notification settings - Fork907
fix: add timeouts to test telemetry snapshot#17879
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
coderd/telemetry/telemetry_test.go Outdated
select { | ||
case <-ctx.Done(): | ||
t.Fatal("timed out sending deployment") | ||
case deployment <- dd: | ||
} |
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.
Have a look attestutil.RequireReceive
; that provides a nice abstraction over this pattern.
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.
Thetestutil.Require*
functions were not safe to use from helper goroutines, so I ended up creating 3 new helper functions.
39cbc5b
tocc56091
CompareThere 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.
LGTM, with a non-blocking nit
// The second return value indicates whether the receive was successful. | ||
// | ||
// Safety: can be called from any goroutine. | ||
func AssertReceive[A any](ctx context.Context, t testing.TB, c <-chan A) (A, bool) { |
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.
Nit: could we abstract the logic and either uset.Fatal
ort.Error
in either case? That seems to be the only delta between the implementations.
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.
There's also the extra return value. I suppose we could create internal helper functions which would be called with a bool param by the Require/Assert variants. Not sure if it's worth it here - what do you think?
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.
Nah,
f825477
intomainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
This PR ensures that waits on channels will time out according to the test context, rather than waiting indefinitely. This should alleviate the panic seen incoder/internal#645 and, if the deadlock recurs, allow the test to be retried automatically in CI.