mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 20:57:36 +03:00
fix flaky counting of 0-RTT packets in integration test (#3669)
This commit is contained in:
parent
b52d34008f
commit
a2e52e31a8
1 changed files with 25 additions and 18 deletions
|
@ -246,7 +246,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
It("waits for a connection until the handshake is done", func() {
|
It("waits for a connection until the handshake is done", func() {
|
||||||
tlsConf, clientConf := dialAndReceiveSessionTicket(nil)
|
tlsConf, clientConf := dialAndReceiveSessionTicket(nil)
|
||||||
|
|
||||||
zeroRTTData := GeneratePRData(2 * 1100) // 2 packets
|
zeroRTTData := GeneratePRData(5 << 10)
|
||||||
oneRTTData := PRData
|
oneRTTData := PRData
|
||||||
|
|
||||||
tracer := newPacketTracer()
|
tracer := newPacketTracer()
|
||||||
|
@ -262,7 +262,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer ln.Close()
|
defer ln.Close()
|
||||||
|
|
||||||
// now dial the second connection, and use 0-RTT to send some data
|
// now accept the second connection, and receive the 0-RTT data
|
||||||
go func() {
|
go func() {
|
||||||
defer GinkgoRecover()
|
defer GinkgoRecover()
|
||||||
conn, err := ln.Accept(context.Background())
|
conn, err := ln.Accept(context.Background())
|
||||||
|
@ -280,7 +280,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
Expect(conn.CloseWithError(0, "")).To(Succeed())
|
Expect(conn.CloseWithError(0, "")).To(Succeed())
|
||||||
}()
|
}()
|
||||||
|
|
||||||
proxy, num0RTTPackets := runCountingProxy(ln.Addr().(*net.UDPAddr).Port)
|
proxy, _ := runCountingProxy(ln.Addr().(*net.UDPAddr).Port)
|
||||||
defer proxy.Close()
|
defer proxy.Close()
|
||||||
|
|
||||||
conn, err := quic.DialAddrEarly(
|
conn, err := quic.DialAddrEarly(
|
||||||
|
@ -289,17 +289,11 @@ var _ = Describe("0-RTT", func() {
|
||||||
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}),
|
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}),
|
||||||
)
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
sent0RTT := make(chan struct{})
|
firstStr, err := conn.OpenUniStream()
|
||||||
go func() {
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer GinkgoRecover()
|
_, err = firstStr.Write(zeroRTTData)
|
||||||
defer close(sent0RTT)
|
Expect(err).ToNot(HaveOccurred())
|
||||||
str, err := conn.OpenUniStream()
|
Expect(firstStr.Close()).To(Succeed())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
_, err = str.Write(zeroRTTData)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
Expect(str.Close()).To(Succeed())
|
|
||||||
}()
|
|
||||||
Eventually(sent0RTT).Should(BeClosed())
|
|
||||||
|
|
||||||
// wait for the handshake to complete
|
// wait for the handshake to complete
|
||||||
Eventually(conn.HandshakeComplete().Done()).Should(BeClosed())
|
Eventually(conn.HandshakeComplete().Done()).Should(BeClosed())
|
||||||
|
@ -310,10 +304,23 @@ var _ = Describe("0-RTT", func() {
|
||||||
Expect(str.Close()).To(Succeed())
|
Expect(str.Close()).To(Succeed())
|
||||||
<-conn.Context().Done()
|
<-conn.Context().Done()
|
||||||
|
|
||||||
num0RTT := atomic.LoadUint32(num0RTTPackets)
|
// check that 0-RTT packets only contain STREAM frames for the first stream
|
||||||
fmt.Fprintf(GinkgoWriter, "Sent %d 0-RTT packets.", num0RTT)
|
var num0RTT int
|
||||||
Expect(num0RTT).To(Or(BeEquivalentTo(2), BeEquivalentTo(3))) // the FIN might be sent in a separate packet
|
for _, p := range tracer.getRcvdLongHeaderPackets() {
|
||||||
Expect(get0RTTPackets(tracer.getRcvdLongHeaderPackets())).To(HaveLen(int(num0RTT)))
|
if p.hdr.Header.Type != protocol.PacketType0RTT {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for _, f := range p.frames {
|
||||||
|
sf, ok := f.(*logging.StreamFrame)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
num0RTT++
|
||||||
|
Expect(sf.StreamID).To(Equal(firstStr.StreamID()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fmt.Fprintf(GinkgoWriter, "received %d STREAM frames in 0-RTT packets\n", num0RTT)
|
||||||
|
Expect(num0RTT).ToNot(BeZero())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("transfers 0-RTT data, when 0-RTT packets are lost", func() {
|
It("transfers 0-RTT data, when 0-RTT packets are lost", func() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue