forked from quic-go/quic-go
use new random data for each integration test
This commit is contained in:
@@ -119,10 +119,11 @@ var _ = Describe("Chrome tests", func() {
|
||||
}, 10)
|
||||
|
||||
It("downloads a small file", func() {
|
||||
dataMan.GenerateData(dataLen)
|
||||
err := wd.Get("https://quic.clemente.io/data")
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Eventually(func() int { return getDownloadSize("data") }, 30, 0.1).Should(Equal(dataLen))
|
||||
Expect(getDownloadMD5("data")).To(Equal(dataMD5))
|
||||
Expect(getDownloadMD5("data")).To(Equal(dataMan.GetMD5()))
|
||||
}, 60)
|
||||
})
|
||||
}
|
||||
|
||||
30
integrationtests/data_manager.go
Normal file
30
integrationtests/data_manager.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package integrationtests
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"crypto/rand"
|
||||
)
|
||||
|
||||
type dataManager struct {
|
||||
data []byte
|
||||
md5 []byte
|
||||
}
|
||||
|
||||
func (m *dataManager) GenerateData(len int) error {
|
||||
m.data = make([]byte, len)
|
||||
_, err := rand.Read(m.data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sum := md5.Sum(m.data)
|
||||
m.md5 = sum[:]
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *dataManager) GetData() []byte {
|
||||
return m.data
|
||||
}
|
||||
|
||||
func (m *dataManager) GetMD5() []byte {
|
||||
return m.md5
|
||||
}
|
||||
28
integrationtests/data_manager_test.go
Normal file
28
integrationtests/data_manager_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package integrationtests
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("Data Manager", func() {
|
||||
dm := dataManager{}
|
||||
|
||||
It("generates data", func() {
|
||||
dm.GenerateData(1337)
|
||||
data := dm.GetData()
|
||||
Expect(data).To(HaveLen(1337))
|
||||
Expect(dm.GetMD5()).To(HaveLen(16))
|
||||
})
|
||||
|
||||
It("generates random data", func() {
|
||||
dm.GenerateData(1337)
|
||||
data1 := dm.GetData()
|
||||
md51 := dm.GetMD5()
|
||||
dm.GenerateData(1337)
|
||||
data2 := dm.GetData()
|
||||
md52 := dm.GetMD5()
|
||||
Expect(data1).ToNot(Equal(data2))
|
||||
Expect(md51).ToNot(Equal(md52))
|
||||
})
|
||||
})
|
||||
@@ -20,6 +20,10 @@ import (
|
||||
)
|
||||
|
||||
var _ = PDescribe("Drop Proxy", func() {
|
||||
BeforeEach(func() {
|
||||
dataMan.GenerateData(dataLen)
|
||||
})
|
||||
|
||||
var dropproxy *proxy.UDPProxy
|
||||
|
||||
runDropTest := func(incomingPacketDropper, outgoingPacketDropper proxy.DropCallback, version protocol.VersionNumber) {
|
||||
@@ -49,7 +53,7 @@ var _ = PDescribe("Drop Proxy", func() {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
defer session.Kill()
|
||||
Eventually(session, 20).Should(Exit(0))
|
||||
Expect(bytes.Contains(session.Out.Contents(), data)).To(BeTrue())
|
||||
Expect(bytes.Contains(session.Out.Contents(), dataMan.GetData())).To(BeTrue())
|
||||
}
|
||||
|
||||
AfterEach(func() {
|
||||
|
||||
@@ -20,6 +20,10 @@ import (
|
||||
)
|
||||
|
||||
var _ = Describe("Integration tests", func() {
|
||||
BeforeEach(func() {
|
||||
dataMan.GenerateData(dataLen)
|
||||
})
|
||||
|
||||
clientPath := fmt.Sprintf(
|
||||
"%s/src/github.com/lucas-clemente/quic-clients/client-%s-debug",
|
||||
os.Getenv("GOPATH"),
|
||||
@@ -61,7 +65,7 @@ var _ = Describe("Integration tests", func() {
|
||||
Expect(session.Out).To(Say("Response:\nheaders: HTTP/1.1 200\nstatus: 200\n\nbody: foo\n"))
|
||||
})
|
||||
|
||||
It("gets a large file", func() {
|
||||
It("gets a file", func() {
|
||||
command := exec.Command(
|
||||
clientPath,
|
||||
"--quic-version="+strconv.Itoa(int(version)),
|
||||
@@ -73,10 +77,10 @@ var _ = Describe("Integration tests", func() {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
defer session.Kill()
|
||||
Eventually(session, 2).Should(Exit(0))
|
||||
Expect(bytes.Contains(session.Out.Contents(), data)).To(BeTrue())
|
||||
Expect(bytes.Contains(session.Out.Contents(), dataMan.GetData())).To(BeTrue())
|
||||
})
|
||||
|
||||
It("gets many large files in parallel", func() {
|
||||
It("gets many copies of a file in parallel", func() {
|
||||
wg := sync.WaitGroup{}
|
||||
for i := 0; i < 10; i++ {
|
||||
wg.Add(1)
|
||||
@@ -94,7 +98,7 @@ var _ = Describe("Integration tests", func() {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
defer session.Kill()
|
||||
Eventually(session, 10).Should(Exit(0))
|
||||
Expect(bytes.Contains(session.Out.Contents(), data)).To(BeTrue())
|
||||
Expect(bytes.Contains(session.Out.Contents(), dataMan.GetData())).To(BeTrue())
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
@@ -2,8 +2,6 @@ package integrationtests
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -32,8 +30,7 @@ const (
|
||||
|
||||
var (
|
||||
server *h2quic.Server
|
||||
data []byte
|
||||
dataMD5 []byte
|
||||
dataMan dataManager
|
||||
port string
|
||||
|
||||
docker *gexec.Session
|
||||
@@ -59,11 +56,6 @@ var _ = AfterSuite(func() {
|
||||
|
||||
func setupHTTPHandlers() {
|
||||
defer GinkgoRecover()
|
||||
data = make([]byte, dataLen)
|
||||
_, err := rand.Read(data)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
sum := md5.Sum(data)
|
||||
dataMD5 = sum[:]
|
||||
|
||||
http.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) {
|
||||
defer GinkgoRecover()
|
||||
@@ -73,6 +65,8 @@ func setupHTTPHandlers() {
|
||||
|
||||
http.HandleFunc("/data", func(w http.ResponseWriter, r *http.Request) {
|
||||
defer GinkgoRecover()
|
||||
data := dataMan.GetData()
|
||||
Expect(data).ToNot(HaveLen(0))
|
||||
_, err := w.Write(data)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@@ -19,6 +19,10 @@ import (
|
||||
)
|
||||
|
||||
var _ = Describe("Random RTT", func() {
|
||||
BeforeEach(func() {
|
||||
dataMan.GenerateData(dataLen)
|
||||
})
|
||||
|
||||
var rttProxy *proxy.UDPProxy
|
||||
|
||||
runRTTTest := func(minRtt, maxRtt time.Duration, version protocol.VersionNumber) {
|
||||
@@ -47,7 +51,7 @@ var _ = Describe("Random RTT", func() {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
defer session.Kill()
|
||||
Eventually(session, 4).Should(Exit(0))
|
||||
Expect(bytes.Contains(session.Out.Contents(), data)).To(BeTrue())
|
||||
Expect(bytes.Contains(session.Out.Contents(), dataMan.GetData())).To(BeTrue())
|
||||
}
|
||||
|
||||
AfterEach(func() {
|
||||
|
||||
@@ -19,6 +19,10 @@ import (
|
||||
)
|
||||
|
||||
var _ = Describe("non-zero RTT", func() {
|
||||
BeforeEach(func() {
|
||||
dataMan.GenerateData(dataLen)
|
||||
})
|
||||
|
||||
var rttProxy *proxy.UDPProxy
|
||||
|
||||
runRTTTest := func(rtt time.Duration, version protocol.VersionNumber) {
|
||||
@@ -47,7 +51,7 @@ var _ = Describe("non-zero RTT", func() {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
defer session.Kill()
|
||||
Eventually(session, 4).Should(Exit(0))
|
||||
Expect(bytes.Contains(session.Out.Contents(), data)).To(BeTrue())
|
||||
Expect(bytes.Contains(session.Out.Contents(), dataMan.GetData())).To(BeTrue())
|
||||
}
|
||||
|
||||
AfterEach(func() {
|
||||
|
||||
Reference in New Issue
Block a user