Skip to content

feat(cli/exp): add app testing to scaletest workspace-traffic #11633

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 6 commits into from
Jan 19, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
explain how context is used with websocket.NetConn
  • Loading branch information
mafredri committed Jan 19, 2024
commit f52b4929b8a60ea988a37f2a489627eb35bc8c84
4 changes: 4 additions & 0 deletions scaletest/workspacetraffic/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ func (c *wsNetConn) Close() error {
return nil
}

// Cancel before acquiring locks to speed up teardown.
c.cancel()

c.readMu.Lock()
Expand All @@ -371,6 +372,9 @@ func (c *wsNetConn) Close() error {
}

func websocketNetConn(conn *websocket.Conn, msgType websocket.MessageType) net.Conn {
// Since `websocket.NetConn` binds to a context for the lifetime of the
// connection, we need to create a new context that can be canceled when
// the connection is closed.
ctx, cancel := context.WithCancel(context.Background())
nc := websocket.NetConn(ctx, conn, msgType)
return &wsNetConn{cancel: cancel, Conn: nc}
Expand Down