Skip to content

fix: Close TURN connections to resolve flake #1079

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
Apr 19, 2022
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