Skip to content

Commit

Permalink
New attempt to fix this test. Could it be aborted connections?
Browse files Browse the repository at this point in the history
  • Loading branch information
julienduchesne committed Oct 9, 2024
1 parent 87645c1 commit 79ff135
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions crypto/tls/test/tls_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"time"

"github.com/gogo/status"
"github.com/hashicorp/go-cleanhttp"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -103,6 +104,7 @@ func newIntegrationClientServer(

serv, err := server.New(cfg)
require.NoError(t, err)
defer serv.Shutdown()

serv.HTTP.HandleFunc("/hello", func(w http.ResponseWriter, _ *http.Request) {
fmt.Fprintf(w, "OK")
Expand Down Expand Up @@ -136,12 +138,13 @@ func newIntegrationClientServer(
grpcHost := net.JoinHostPort("localhost", strconv.Itoa(grpcAddr.Port))

for _, tc := range tcs {
tlsClientConfig, err := tc.tlsConfig.GetTLSConfig()
require.NoError(t, err)

// HTTP
t.Run("HTTP/"+tc.name, func(t *testing.T) {
transport := &http.Transport{TLSClientConfig: tlsClientConfig, MaxIdleConnsPerHost: 100} // DefaultMaxIdleConnsPerHost is 2
tlsClientConfig, err := tc.tlsConfig.GetTLSConfig()
require.NoError(t, err)

transport := cleanhttp.DefaultTransport()
transport.TLSClientConfig = tlsClientConfig
client := &http.Client{Transport: transport}

resp, err := client.Get(httpURL)
Expand All @@ -150,6 +153,7 @@ func newIntegrationClientServer(
}
if tc.httpExpectError != nil {
tc.httpExpectError(t, err)
time.Sleep(500 * time.Millisecond) // This prevents test flakiness: See https://go-review.googlesource.com/c/go/+/527196/6/src/net/http/server.go
return
}
if err != nil {
Expand Down Expand Up @@ -193,10 +197,7 @@ func newIntegrationClientServer(
assert.Equal(t, grpc_health_v1.HealthCheckResponse_SERVING, resp.Status)
}
})

}

serv.Shutdown()
}

func TestServerWithoutTlsEnabled(t *testing.T) {
Expand Down

0 comments on commit 79ff135

Please sign in to comment.