forked from quic-go/quic-go
fix flaky proxy test
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go"
|
"github.com/lucas-clemente/quic-go"
|
||||||
"github.com/lucas-clemente/quic-go/protocol"
|
"github.com/lucas-clemente/quic-go/protocol"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
@@ -46,8 +48,7 @@ var _ = Describe("QUIC Proxy", func() {
|
|||||||
addr, err := net.ResolveUDPAddr("udp", "localhost:"+strconv.Itoa(proxy.LocalPort()))
|
addr, err := net.ResolveUDPAddr("udp", "localhost:"+strconv.Itoa(proxy.LocalPort()))
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
_, err = net.ListenUDP("udp", addr)
|
_, err = net.ListenUDP("udp", addr)
|
||||||
Expect(err).To(MatchError("listen udp 127.0.0.1:" + strconv.Itoa(proxy.LocalPort()) + ": bind: address already in use"))
|
Expect(err).To(MatchError(fmt.Sprintf("listen udp 127.0.0.1:%d: bind: address already in use", proxy.LocalPort())))
|
||||||
|
|
||||||
Expect(proxy.Close()).To(Succeed()) // stopping is tested in the next test
|
Expect(proxy.Close()).To(Succeed()) // stopping is tested in the next test
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -61,9 +62,12 @@ var _ = Describe("QUIC Proxy", func() {
|
|||||||
// check that the proxy port is not in use anymore
|
// check that the proxy port is not in use anymore
|
||||||
addr, err := net.ResolveUDPAddr("udp", "localhost:"+strconv.Itoa(port))
|
addr, err := net.ResolveUDPAddr("udp", "localhost:"+strconv.Itoa(port))
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
ln, err := net.ListenUDP("udp", addr)
|
// sometimes it takes a while for the OS to free the port
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Eventually(func() error {
|
||||||
Expect(ln.Close()).To(Succeed())
|
ln, err := net.ListenUDP("udp", addr)
|
||||||
|
defer ln.Close()
|
||||||
|
return err
|
||||||
|
}).ShouldNot(HaveOccurred())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("has the correct LocalAddr and LocalPort", func() {
|
It("has the correct LocalAddr and LocalPort", func() {
|
||||||
|
|||||||
Reference in New Issue
Block a user