Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: fix hang in teardown of TestConn_CoordinatorRollingRestart #15624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions enterprise/coderd/coderd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,30 +852,26 @@ func TestConn_CoordinatorRollingRestart(t *testing.T) {
}

func tcpEchoServer(t *testing.T) string {
var listenerWg sync.WaitGroup
tcpListener, err := net.Listen("tcp", "127.0.0.1:0")
require.NoError(t, err)
t.Cleanup(func() {
_ = tcpListener.Close()
listenerWg.Wait()
})
listenerWg.Add(1)
go func() {
defer listenerWg.Done()
for {
conn, err := tcpListener.Accept()
if err != nil {
return
}
listenerWg.Add(1)
t.Cleanup(func() {
_ = conn.Close()
})
go func() {
defer listenerWg.Done()
defer conn.Close()
_, _ = io.Copy(conn, conn)
}()
}
}()

return tcpListener.Addr().String()
}

Expand Down
Loading