Skip to content

Commit 11c5c54

Browse files
improve timeout measurement in the timeout test
When not sending any packets, the idle timeout starts when receiving the HANDSHAKE_DONE frame (on the client side), not when the handshake completes.
1 parent 7ee88de commit 11c5c54

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

integrationtests/self/timeout_test.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import (
1515

1616
quic "github.com/lucas-clemente/quic-go"
1717
quicproxy "github.com/lucas-clemente/quic-go/integrationtests/tools/proxy"
18+
"github.com/lucas-clemente/quic-go/internal/protocol"
1819
"github.com/lucas-clemente/quic-go/internal/utils"
20+
"github.com/lucas-clemente/quic-go/logging"
1921
. "github.com/onsi/ginkgo"
2022
. "github.com/onsi/gomega"
2123
)
@@ -44,6 +46,17 @@ func (c *faultyConn) WriteTo(p []byte, addr net.Addr) (int, error) {
4446
return 0, io.ErrClosedPipe
4547
}
4648

49+
type handshakeCompleteTracer struct {
50+
connTracer
51+
completionTime time.Time
52+
}
53+
54+
func (t *handshakeCompleteTracer) DroppedEncryptionLevel(l protocol.EncryptionLevel) {
55+
if l == protocol.EncryptionHandshake {
56+
t.completionTime = time.Now()
57+
}
58+
}
59+
4760
func areHandshakesRunning() bool {
4861
var b bytes.Buffer
4962
pprof.Lookup("goroutine").WriteTo(&b, 1)
@@ -201,13 +214,13 @@ var _ = Describe("Timeout tests", func() {
201214
close(serverSessionClosed)
202215
}()
203216

217+
tr := &handshakeCompleteTracer{}
204218
sess, err := quic.DialAddr(
205219
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
206220
getTLSClientConfig(),
207-
getQuicConfig(&quic.Config{MaxIdleTimeout: idleTimeout}),
221+
getQuicConfig(&quic.Config{MaxIdleTimeout: idleTimeout, Tracer: newTracer(func() logging.ConnectionTracer { return tr })}),
208222
)
209223
Expect(err).ToNot(HaveOccurred())
210-
startTime := time.Now()
211224
done := make(chan struct{})
212225
go func() {
213226
defer GinkgoRecover()
@@ -216,7 +229,8 @@ var _ = Describe("Timeout tests", func() {
216229
close(done)
217230
}()
218231
Eventually(done, 2*idleTimeout).Should(BeClosed())
219-
dur := time.Since(startTime)
232+
Expect(tr.completionTime).ToNot(BeZero())
233+
dur := time.Since(tr.completionTime)
220234
Expect(dur).To(And(
221235
BeNumerically(">=", idleTimeout),
222236
BeNumerically("<", idleTimeout*6/5),

0 commit comments

Comments
 (0)