Skip to content

Commit b3aba6d

Browse files
authored
test: ignore context.Canceled in acquireWithCancel (coder#17448)
fixes coder/internal#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.
1 parent daafa0d commit b3aba6d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

provisionerd/provisionerd_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,11 @@ func (a *acquireOne) acquireWithCancel(stream proto.DRPCProvisionerDaemon_Acquir
12701270
return nil
12711271
}
12721272
err := stream.Send(a.job)
1273-
assert.NoError(a.t, err)
1273+
// dRPC is racy, and sometimes will return context.Canceled after it has successfully sent the message if we cancel
1274+
// right away, e.g. in unit tests that complete. So, just swallow the error in that case. If we are canceled before
1275+
// the job was acquired, presumably something else in the test will have failed.
1276+
if !xerrors.Is(err, context.Canceled) {
1277+
assert.NoError(a.t, err)
1278+
}
12741279
return nil
12751280
}

0 commit comments

Comments
 (0)