properly stop the testserver at the end of a test in integration tests

This commit is contained in:
Marten Seemann
2017-12-20 17:33:36 +07:00
parent ed212b789c
commit e4e74e0873

View File

@@ -26,6 +26,7 @@ var (
PRDataLong = GeneratePRData(dataLenLong)
server *h2quic.Server
stoppedServing chan struct{}
port string
)
@@ -95,14 +96,18 @@ func StartQuicServer(versions []protocol.VersionNumber) {
Expect(err).NotTo(HaveOccurred())
port = strconv.Itoa(conn.LocalAddr().(*net.UDPAddr).Port)
stoppedServing = make(chan struct{})
go func() {
defer GinkgoRecover()
server.Serve(conn)
close(stoppedServing)
}()
}
func StopQuicServer() {
Expect(server.Close()).NotTo(HaveOccurred())
Eventually(stoppedServing).Should(BeClosed())
}
func Port() string {