forked from quic-go/quic-go
The new QUIC proxy allows to listen on “:0”, which allows us to get rid of all “address already in use” errors. The constructor now takes an Opts struct, which makes configuring it easier.
67 lines
1.6 KiB
Go
67 lines
1.6 KiB
Go
package integrationtests
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"os/exec"
|
|
"strconv"
|
|
"time"
|
|
|
|
_ "github.com/lucas-clemente/quic-clients" // download clients
|
|
"github.com/lucas-clemente/quic-go/integrationtests/proxy"
|
|
"github.com/lucas-clemente/quic-go/protocol"
|
|
|
|
. "github.com/onsi/ginkgo"
|
|
. "github.com/onsi/gomega"
|
|
. "github.com/onsi/gomega/gexec"
|
|
)
|
|
|
|
var _ = Describe("non-zero RTT", func() {
|
|
BeforeEach(func() {
|
|
dataMan.GenerateData(dataLen)
|
|
})
|
|
|
|
var proxy *quicproxy.QuicProxy
|
|
|
|
runRTTTest := func(rtt time.Duration, version protocol.VersionNumber) {
|
|
var err error
|
|
proxy, err = quicproxy.NewQuicProxy("localhost:", quicproxy.Opts{
|
|
RemoteAddr: "localhost:" + port,
|
|
DelayPacket: func(_ quicproxy.Direction, _ protocol.PacketNumber) time.Duration {
|
|
return rtt / 2
|
|
},
|
|
})
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
command := exec.Command(
|
|
clientPath,
|
|
"--quic-version="+strconv.Itoa(int(version)),
|
|
"--host=127.0.0.1",
|
|
"--port="+strconv.Itoa(proxy.LocalPort()),
|
|
"https://quic.clemente.io/data",
|
|
)
|
|
|
|
session, err := Start(command, nil, GinkgoWriter)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
defer session.Kill()
|
|
Eventually(session, 4).Should(Exit(0))
|
|
Expect(bytes.Contains(session.Out.Contents(), dataMan.GetData())).To(BeTrue())
|
|
}
|
|
|
|
AfterEach(func() {
|
|
err := proxy.Close()
|
|
Expect(err).ToNot(HaveOccurred())
|
|
time.Sleep(time.Millisecond)
|
|
})
|
|
|
|
for i := range protocol.SupportedVersions {
|
|
version := protocol.SupportedVersions[i]
|
|
|
|
Context(fmt.Sprintf("with quic version %d", version), func() {
|
|
It("gets a file with 10ms RTT", func() {
|
|
runRTTTest(10*time.Millisecond, version)
|
|
})
|
|
})
|
|
}
|
|
})
|