feat: add IgnoreErrorFn to slogtest options#217
Merged
Conversation
Signed-off-by: Spike Curtis <spike@coder.com>
3c57153 to
6f99a7c
Compare
Pull Request Test Coverage Report for Build c81cb4e378f17fe114d95a637ead89e678c6bbe9-PR-217Details
💛 - Coveralls |
coadler
approved these changes
Nov 12, 2024
spikecurtis
added a commit
to coder/coder
that referenced
this pull request
Nov 18, 2024
Refactors our use of `slogtest` to instantiate a "standard logger" across most of our tests. This standard logger incorporates coder/slog#217 to also ignore database query canceled errors by default, which are a source of low-severity flakes. Any test that has set non-default `slogtest.Options` is left alone. In particular, `coderdtest` defaults to ignoring all errors. We might consider revisiting that decision now that we have better tools to target the really common flaky Error logs on shutdown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
IgnoredErrorIsfor this, because the exportedpq.Errortype encompasses all PostgreSQL errors, not just query canceled. But, if we have the freedom to use a function to ignore errors, we can usedatabase.IsQueryCanceledErrorto 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.