feat: add IgnoreErrorFn to slogtest options #217
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a new option to slogtest:
IgnoreErrorFn
, which allows test code to selectively ignore errors based on the contents of theSinkEntry
.primary use case:
We're still fighting flakes where the error is due to canceling the context on shut down, but when canceling active postgreSQL queries, we can get errors like:
pq: canceling statement due to user request
.e.g. https://github.com/coder/coder/actions/runs/11681605747/job/32527006174
Unfortunately, we can't use
IgnoredErrorIs
for this, because the exportedpq.Error
type encompasses all PostgreSQL errors, not just query canceled. But, if we have the freedom to use a function to ignore errors, we can usedatabase.IsQueryCanceledError
to weed out these flakes.secondary use case:
I decided to pass the entire SinkEntry to the function, so that tests can be really targeted about which errors to ignore, if they want to. They could match on the error message, or even other fields so that you can ignore an error for a request that is expected to fail, but not mask failures for other similar requests that are supposed to succeed.