From 9cf4e7f15a4f8ddc7da2df0892884bb42d1e0e6f Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Tue, 30 Jan 2024 10:04:01 +0400 Subject: [PATCH] fix: prevent agent_test.go from failing on error logs (#11909) We're failing tests on error logs like this: https://github.com/coder/coder/actions/runs/7706053882/job/21000984583 Unfortunately, the error we hit, when the underlying connection is closed, is unexported, so we can't specifically ignore it. Part of the issue is that agent.Close() doesn't wait for these goroutines to complete before returning, so the test harness proceeds to close the connection. This looks to our product code like the network connection failing. It would be possible to fix this, but just doesn't seem worth it for the extra insurance of catching other error logs in these tests. --- agent/agent_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/agent/agent_test.go b/agent/agent_test.go index ca30bf3b98..596471b49f 100644 --- a/agent/agent_test.go +++ b/agent/agent_test.go @@ -35,7 +35,6 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/valyala/fasthttp/fasthttputil" "go.uber.org/goleak" "go.uber.org/mock/gomock" "golang.org/x/crypto/ssh" @@ -2028,8 +2027,9 @@ func setupAgent(t *testing.T, metadata agentsdk.Manifest, ptyTimeout time.Durati agent.Agent, ) { logger := slogtest.Make(t, &slogtest.Options{ - // we get this error when closing the Agent API - IgnoredErrorIs: append(slogtest.DefaultIgnoredErrorIs, fasthttputil.ErrInmemoryListenerClosed), + // Agent can drop errors when shutting down, and some, like the + // fasthttplistener connection closed error, are unexported. + IgnoreErrors: true, }).Leveled(slog.LevelDebug) if metadata.DERPMap == nil { metadata.DERPMap, _ = tailnettest.RunDERPAndSTUN(t)