rewrite the QUIC proxy used in the integrationtests

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.
This commit is contained in:
Marten Seemann
2017-04-22 23:34:51 +07:00
parent 61f5f1e668
commit 08cf78d2b0
10 changed files with 635 additions and 526 deletions

View File

@@ -5,7 +5,6 @@ import (
"fmt"
"os/exec"
"strconv"
"time"
_ "github.com/lucas-clemente/quic-clients" // download clients
"github.com/lucas-clemente/quic-go/integrationtests/proxy"
@@ -21,21 +20,21 @@ var _ = Describe("Drop Proxy", func() {
dataMan.GenerateData(dataLen)
})
var dropproxy *proxy.UDPProxy
var proxy *quicproxy.QuicProxy
runDropTest := func(incomingPacketDropper, outgoingPacketDropper proxy.DropCallback, version protocol.VersionNumber) {
proxyPort := 12345
iPort, _ := strconv.Atoi(port)
runDropTest := func(dropCallback quicproxy.DropCallback, version protocol.VersionNumber) {
var err error
dropproxy, err = proxy.NewUDPProxy(proxyPort, "localhost", iPort, incomingPacketDropper, outgoingPacketDropper, 0, 0)
proxy, err = quicproxy.NewQuicProxy("localhost:0", quicproxy.Opts{
RemoteAddr: "localhost:" + port,
DropPacket: dropCallback,
})
Expect(err).ToNot(HaveOccurred())
command := exec.Command(
clientPath,
"--quic-version="+strconv.Itoa(int(version)),
"--host=127.0.0.1",
"--port="+strconv.Itoa(proxyPort),
"--port="+strconv.Itoa(proxy.LocalPort()),
"https://quic.clemente.io/data",
)
@@ -47,8 +46,7 @@ var _ = Describe("Drop Proxy", func() {
}
AfterEach(func() {
dropproxy.Stop()
time.Sleep(time.Millisecond)
Expect(proxy.Close()).To(Succeed())
})
for i := range protocol.SupportedVersions {
@@ -64,11 +62,15 @@ var _ = Describe("Drop Proxy", func() {
}
It("gets a file when many outgoing packets are dropped", func() {
runDropTest(nil, dropper, version)
runDropTest(func(d quicproxy.Direction, p protocol.PacketNumber) bool {
return d == quicproxy.DirectionOutgoing && dropper(p)
}, version)
})
It("gets a file when many incoming packets are dropped", func() {
runDropTest(dropper, nil, version)
runDropTest(func(d quicproxy.Direction, p protocol.PacketNumber) bool {
return d == quicproxy.DirectionIncoming && dropper(p)
}, version)
})
})
})