mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
chore: add standard test logger ignoring db canceled (#15556)
Refactors our use of `slogtest` to instantiate a "standard logger" across most of our tests. This standard logger incorporates https://github.com/coder/slog/pull/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 commit is contained in:
@@ -44,7 +44,7 @@ func TestHeartbeats_Cleanup(t *testing.T) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
|
||||
defer cancel()
|
||||
logger := slogtest.Make(t, nil).Leveled(slog.LevelDebug)
|
||||
logger := testutil.Logger(t)
|
||||
|
||||
mStore.EXPECT().CleanTailnetCoordinators(gomock.Any()).Times(2).Return(nil)
|
||||
mStore.EXPECT().CleanTailnetLostPeers(gomock.Any()).Times(2).Return(nil)
|
||||
@@ -77,7 +77,7 @@ func TestHeartbeats_recvBeat_resetSkew(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctx := testutil.Context(t, testutil.WaitShort)
|
||||
logger := slogtest.Make(t, nil).Leveled(slog.LevelDebug)
|
||||
logger := testutil.Logger(t)
|
||||
mClock := quartz.NewMock(t)
|
||||
trap := mClock.Trap().Until("heartbeats", "resetExpiryTimerWithLock")
|
||||
defer trap.Close()
|
||||
@@ -133,7 +133,7 @@ func TestHeartbeats_LostCoordinator_MarkLost(t *testing.T) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
|
||||
defer cancel()
|
||||
logger := slogtest.Make(t, nil).Leveled(slog.LevelDebug)
|
||||
logger := testutil.Logger(t)
|
||||
|
||||
uut := &heartbeats{
|
||||
ctx: ctx,
|
||||
|
||||
Reference in New Issue
Block a user