Skip to content
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
fix: Close TURN connections to resolve flake
  • Loading branch information
kylecarbs committed Apr 19, 2022
commit 3873404e9acf94d4bd16e3722485529a6192b424
13 changes: 7 additions & 6 deletions coderd/turnconn/turnconn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ func TestTURNConn(t *testing.T) {
Logger: logger.Named("client"),
})
require.NoError(t, err)
defer func() {
_ = client.Close()
}()

serverDialer, serverTURN := net.Pipe()
turnServer.Accept(serverTURN, &net.TCPAddr{
Expand All @@ -62,6 +65,9 @@ func TestTURNConn(t *testing.T) {
Logger: logger.Named("server"),
})
require.NoError(t, err)
defer func() {
_ = server.Close()
}()
exchange(t, client, server)

_, err = client.Ping()
Expand All @@ -71,12 +77,7 @@ func TestTURNConn(t *testing.T) {
func exchange(t *testing.T, client, server *peer.Conn) {
var wg sync.WaitGroup
wg.Add(2)
t.Cleanup(func() {
_ = client.Close()
_ = server.Close()

wg.Wait()
})
t.Cleanup(wg.Wait)
go func() {
defer wg.Done()
for {
Expand Down