-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
testing: lint against require.Eventually
(or assert.Eventually
)
#100796
Comments
cc @cockroachdb/test-eng |
I wrote a quick & dirty
|
The test is flaky; sadly, the error does not reproduce locally and the precise cause of the flakiness is obscured by cockroachdb#100796. This commit re-enables the test with the fix for cockroachdb#100796, so that the next CI failure can reveal more details about what went wrong. Release note: None
Here is another quick pass, this time using The run below also requires a patch in [1].
This should be pretty close to an exhaustive list for auditing purposes,
|
Thanks for the linter. NB: we should disallow Eventually regardless because of reason (2) - it leaks goroutines even if you don't use the assert/require functions inside the closure. |
Agreed. It's odd that |
The test is flaky; sadly, the error does not reproduce locally and the precise cause of the flakiness is obscured by cockroachdb#100796. This commit re-enables the test with the fix for cockroachdb#100796, so that the next CI failure can reveal more details about what went wrong. Release note: None
Disallowing As for the dangling goroutine, this can be handled by propagating a context to the closure that's cancelled when the test ends. Again, this is good practice in general, even outside of |
We have |
100925: sql: deflake TestErrorDuringExtendedProtocolCommit r=ecwal a=rafiss This uses the traceID to make sure that the error is injected for the correct auto-commit. Previously, internal queries could race with the query we want to error out on. fixes #75549 backport fixes #100480 backport fixes #82010 Release note: None 100993: server: try re-enable TestAdminDecommissionedOperations r=abarganier a=knz The test is flaky; sadly, the error does not reproduce locally and the precise cause of the flakiness is obscured by #100796. This commit re-enables the test with the fix for #100796, so that the next CI failure can reveal more details about what went wrong. Release note: None Epic: None Informs #100791 and #100789. Co-authored-by: Rafi Shamim <[email protected]> Co-authored-by: Raphael 'kena' Poss <[email protected]>
require.Eventually
(or assert.Eventually
) with other require
or assert
call inside closurerequire.Eventually
(or assert.Eventually
)
Describe the problem
There are two design problems in the
require.Eventually
/assert.Eventually
code.t.Fail
(viat.Error
etc) this violates the API of*testing.T
.Eventually
function gives up (e.g. because it gets stuck, or because it takes a longer time) and theEventually
logic fails, there will be a dangling goroutine.t.Fail
after the Eventually call completes and also the surrounding test, the t.Fail call will occur after the test has terminated which is also an API violation.To Reproduce
Example code that demonstrates the problems:
Problem 1:
Problem 2:
Problem 3:
Expected behavior
We should disallow any use of
require.Eventually
outright until the bug is fixed in the require/assert library.testutils.SucceedsSoon
doesn't have this problem.Jira issue: CRDB-26629
The text was updated successfully, but these errors were encountered: