Skip to content

Commit

Permalink
test/e2e: clone DefaultTransport and disable keep-alives (projectcont…
Browse files Browse the repository at this point in the history
…our#5210)

* test/e2e: clone DefaultTransport for HTTP requests
* disable keep alives

Signed-off-by: Steve Kriss <[email protected]>
  • Loading branch information
skriss authored Mar 20, 2023
1 parent be9de2c commit 43f7f4b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion test/e2e/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,17 @@ func (h *HTTP) RequestUntil(opts *HTTPRequestOpts) (*HTTPResponse, bool) {
opt(req)
}

client := &http.Client{}
// Clone the DefaultTransport and disable keep alives
// so we don't reuse connections within this method or
// across multiple calls to this method. This helps
// prevent requests from inadvertently being made to
// a draining Listener.
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.DisableKeepAlives = true

client := &http.Client{
Transport: transport,
}
for _, opt := range opts.ClientOpts {
opt(client)
}
Expand Down Expand Up @@ -196,7 +206,13 @@ func (h *HTTP) SecureRequestUntil(opts *HTTPSRequestOpts) (*HTTPResponse, bool)
opt(req)
}

// Clone the DefaultTransport and disable keep alives
// so we don't reuse connections within this method or
// across multiple calls to this method. This helps
// prevent requests from inadvertently being made to
// a draining Listener.
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.DisableKeepAlives = true
transport.TLSClientConfig = &tls.Config{
ServerName: opts.Host,
//nolint:gosec
Expand Down

0 comments on commit 43f7f4b

Please sign in to comment.