forked from quic-go/quic-go
run integration tests with the quic_server with all supported versions
This commit is contained in:
@@ -2,6 +2,7 @@ package gquic_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
mrand "math/rand"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
@@ -24,6 +25,10 @@ func TestIntegration(t *testing.T) {
|
||||
RunSpecs(t, "GQuic Tests Suite")
|
||||
}
|
||||
|
||||
var _ = BeforeSuite(func() {
|
||||
mrand.Seed(GinkgoRandomSeed())
|
||||
})
|
||||
|
||||
var _ = JustBeforeEach(func() {
|
||||
testserver.StartQuicServer(nil)
|
||||
})
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"crypto/x509/pkix"
|
||||
"encoding/asn1"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
mrand "math/rand"
|
||||
@@ -18,9 +19,11 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/integrationtests/tools/testserver"
|
||||
|
||||
quic "github.com/lucas-clemente/quic-go"
|
||||
"github.com/lucas-clemente/quic-go/h2quic"
|
||||
"github.com/lucas-clemente/quic-go/integrationtests/tools/testserver"
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/onsi/gomega/gbytes"
|
||||
@@ -28,7 +31,8 @@ import (
|
||||
)
|
||||
|
||||
var _ = Describe("Server tests", func() {
|
||||
mrand.Seed(time.Now().UnixNano())
|
||||
for i := range protocol.SupportedVersions {
|
||||
version := protocol.SupportedVersions[i]
|
||||
|
||||
var (
|
||||
serverPort string
|
||||
@@ -78,7 +82,7 @@ var _ = Describe("Server tests", func() {
|
||||
|
||||
// download files must be create *before* the quic_server is started
|
||||
// the quic_server reads its data dir on startup, and only serves those files that were already present then
|
||||
startServer := func() {
|
||||
startServer := func(version protocol.VersionNumber) {
|
||||
defer GinkgoRecover()
|
||||
var err error
|
||||
command := exec.Command(
|
||||
@@ -86,6 +90,7 @@ var _ = Describe("Server tests", func() {
|
||||
"--quic_response_cache_dir="+filepath.Join(tmpDir, "quic.clemente.io"),
|
||||
"--key_file="+filepath.Join(tmpDir, "key.pkcs8"),
|
||||
"--certificate_file="+filepath.Join(tmpDir, "cert.pem"),
|
||||
"--quic-version="+strconv.Itoa(int(version)),
|
||||
"--port="+serverPort,
|
||||
)
|
||||
session, err = Start(command, nil, GinkgoWriter)
|
||||
@@ -151,6 +156,9 @@ var _ = Describe("Server tests", func() {
|
||||
client = &http.Client{
|
||||
Transport: &h2quic.RoundTripper{
|
||||
TLSClientConfig: &tls.Config{RootCAs: certPool},
|
||||
QuicConfig: &quic.Config{
|
||||
Versions: []protocol.VersionNumber{version},
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
@@ -162,11 +170,12 @@ var _ = Describe("Server tests", func() {
|
||||
tmpDir = ""
|
||||
})
|
||||
|
||||
Context(fmt.Sprintf("with QUIC version %d", version), func() {
|
||||
It("downloads a hello", func() {
|
||||
data := []byte("Hello world!\n")
|
||||
createDownloadFile("hello", data)
|
||||
|
||||
startServer()
|
||||
startServer(version)
|
||||
defer stopServer()
|
||||
|
||||
rsp, err := client.Get("https://quic.clemente.io:" + serverPort + "/hello")
|
||||
@@ -180,7 +189,7 @@ var _ = Describe("Server tests", func() {
|
||||
It("downloads a small file", func() {
|
||||
createDownloadFile("file.dat", testserver.PRData)
|
||||
|
||||
startServer()
|
||||
startServer(version)
|
||||
defer stopServer()
|
||||
|
||||
rsp, err := client.Get("https://quic.clemente.io:" + serverPort + "/file.dat")
|
||||
@@ -194,7 +203,7 @@ var _ = Describe("Server tests", func() {
|
||||
It("downloads a large file", func() {
|
||||
createDownloadFile("file.dat", testserver.PRDataLong)
|
||||
|
||||
startServer()
|
||||
startServer(version)
|
||||
defer stopServer()
|
||||
|
||||
rsp, err := client.Get("https://quic.clemente.io:" + serverPort + "/file.dat")
|
||||
@@ -205,3 +214,5 @@ var _ = Describe("Server tests", func() {
|
||||
Expect(body).To(Equal(testserver.PRDataLong))
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user