Commit 2f2b5785 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net/http: deflake TestIdleConnH2Crash

Fixes #17838

Change-Id: Ifafb4542a0ed6f2e29c9a83e30842e2fc18d6546
Reviewed-on: https://go-review.googlesource.com/33015
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarTom Bergan <tombergan@google.com>
Reviewed-by: default avatarMichael Munday <munday@ca.ibm.com>
parent 22c70f26
......@@ -3667,12 +3667,12 @@ func TestIdleConnH2Crash(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
gotErr := make(chan bool, 1)
sawDoErr := make(chan bool, 1)
testDone := make(chan struct{})
defer close(testDone)
cst.tr.IdleConnTimeout = 5 * time.Millisecond
cst.tr.DialTLS = func(network, addr string) (net.Conn, error) {
cancel()
<-gotErr
c, err := tls.Dial(network, addr, &tls.Config{
InsecureSkipVerify: true,
NextProtos: []string{"h2"},
......@@ -3686,6 +3686,17 @@ func TestIdleConnH2Crash(t *testing.T) {
c.Close()
return nil, errors.New("bogus")
}
cancel()
failTimer := time.NewTimer(5 * time.Second)
defer failTimer.Stop()
select {
case <-sawDoErr:
case <-testDone:
case <-failTimer.C:
t.Error("timeout in DialTLS, waiting too long for cst.c.Do to fail")
}
return c, nil
}
......@@ -3696,7 +3707,7 @@ func TestIdleConnH2Crash(t *testing.T) {
res.Body.Close()
t.Fatal("unexpected success")
}
gotErr <- true
sawDoErr <- true
// Wait for the explosion.
time.Sleep(cst.tr.IdleConnTimeout * 10)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment