mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
test: ignore context.Canceled in acquireWithCancel (#17448)
fixes https://github.com/coder/internal/issues/584 Ignore canceled error when sending an acquired job, since dRPC is racy and will sometimes return this error even after successfully sending the job, if the test is quickly finished.
This commit is contained in:
@@ -1270,6 +1270,11 @@ func (a *acquireOne) acquireWithCancel(stream proto.DRPCProvisionerDaemon_Acquir
|
||||
return nil
|
||||
}
|
||||
err := stream.Send(a.job)
|
||||
assert.NoError(a.t, err)
|
||||
// dRPC is racy, and sometimes will return context.Canceled after it has successfully sent the message if we cancel
|
||||
// right away, e.g. in unit tests that complete. So, just swallow the error in that case. If we are canceled before
|
||||
// the job was acquired, presumably something else in the test will have failed.
|
||||
if !xerrors.Is(err, context.Canceled) {
|
||||
assert.NoError(a.t, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user