Skip to content

Commit 9cf4e7f

Browse files
authored
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.
1 parent d3983e4 commit 9cf4e7f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

agent/agent_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
"github.com/spf13/afero"
3636
"github.com/stretchr/testify/assert"
3737
"github.com/stretchr/testify/require"
38-
"github.com/valyala/fasthttp/fasthttputil"
3938
"go.uber.org/goleak"
4039
"go.uber.org/mock/gomock"
4140
"golang.org/x/crypto/ssh"
@@ -2028,8 +2027,9 @@ func setupAgent(t *testing.T, metadata agentsdk.Manifest, ptyTimeout time.Durati
20282027
agent.Agent,
20292028
) {
20302029
logger := slogtest.Make(t, &slogtest.Options{
2031-
// we get this error when closing the Agent API
2032-
IgnoredErrorIs: append(slogtest.DefaultIgnoredErrorIs, fasthttputil.ErrInmemoryListenerClosed),
2030+
// Agent can drop errors when shutting down, and some, like the
2031+
// fasthttplistener connection closed error, are unexported.
2032+
IgnoreErrors: true,
20332033
}).Leveled(slog.LevelDebug)
20342034
if metadata.DERPMap == nil {
20352035
metadata.DERPMap, _ = tailnettest.RunDERPAndSTUN(t)

0 commit comments

Comments
 (0)