forked from quic-go/quic-go
move benchmark test to a separate package
This commit is contained in:
@@ -4,16 +4,16 @@ set -e
|
|||||||
|
|
||||||
go get -t ./...
|
go get -t ./...
|
||||||
if [ ${TESTMODE} == "unit" ]; then
|
if [ ${TESTMODE} == "unit" ]; then
|
||||||
ginkgo -r --cover --randomizeAllSpecs --randomizeSuites --trace --progress --skipPackage integrationtests --skipMeasurements
|
ginkgo -r --cover --randomizeAllSpecs --randomizeSuites --trace --progress --skipPackage integrationtests,benchmark
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ${TESTMODE} == "integration" ]; then
|
if [ ${TESTMODE} == "integration" ]; then
|
||||||
# run benchmark tests
|
# run benchmark tests
|
||||||
ginkgo --randomizeAllSpecs --randomizeSuites --trace --progress -focus "Benchmark"
|
ginkgo --randomizeAllSpecs --randomizeSuites --trace --progress benchmark
|
||||||
# run benchmark tests with the Go race detector
|
# run benchmark tests with the Go race detector
|
||||||
# The Go race detector only works on amd64.
|
# The Go race detector only works on amd64.
|
||||||
if [ ${TRAVIS_GOARCH} == 'amd64' ]; then
|
if [ ${TRAVIS_GOARCH} == 'amd64' ]; then
|
||||||
ginkgo --race --randomizeAllSpecs --randomizeSuites --trace --progress -focus "Benchmark"
|
ginkgo --race --randomizeAllSpecs --randomizeSuites --trace --progress benchmark
|
||||||
fi
|
fi
|
||||||
# run integration tests
|
# run integration tests
|
||||||
ginkgo -v -r --randomizeAllSpecs --randomizeSuites --trace --progress integrationtests
|
ginkgo -v -r --randomizeAllSpecs --randomizeSuites --trace --progress integrationtests
|
||||||
|
|||||||
13
benchmark/benchmark_suite_test.go
Normal file
13
benchmark/benchmark_suite_test.go
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package benchmark
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestBenchmark(t *testing.T) {
|
||||||
|
RegisterFailHandler(Fail)
|
||||||
|
RunSpecs(t, "Benchmark Suite")
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package quic
|
package benchmark
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
|
quic "github.com/lucas-clemente/quic-go"
|
||||||
"github.com/lucas-clemente/quic-go/protocol"
|
"github.com/lucas-clemente/quic-go/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/testdata"
|
"github.com/lucas-clemente/quic-go/testdata"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
@@ -25,14 +26,14 @@ var _ = Describe("Benchmarks", func() {
|
|||||||
|
|
||||||
Context(fmt.Sprintf("with version %d", version), func() {
|
Context(fmt.Sprintf("with version %d", version), func() {
|
||||||
Measure("transferring a file", func(b Benchmarker) {
|
Measure("transferring a file", func(b Benchmarker) {
|
||||||
var ln Listener
|
var ln quic.Listener
|
||||||
serverAddr := make(chan net.Addr)
|
serverAddr := make(chan net.Addr)
|
||||||
handshakeChan := make(chan struct{})
|
handshakeChan := make(chan struct{})
|
||||||
// start the server
|
// start the server
|
||||||
go func() {
|
go func() {
|
||||||
defer GinkgoRecover()
|
defer GinkgoRecover()
|
||||||
var err error
|
var err error
|
||||||
ln, err = ListenAddr("localhost:0", testdata.GetTLSConfig(), nil)
|
ln, err = quic.ListenAddr("localhost:0", testdata.GetTLSConfig(), nil)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
serverAddr <- ln.Addr()
|
serverAddr <- ln.Addr()
|
||||||
sess, err := ln.Accept()
|
sess, err := ln.Accept()
|
||||||
@@ -50,7 +51,7 @@ var _ = Describe("Benchmarks", func() {
|
|||||||
|
|
||||||
// start the client
|
// start the client
|
||||||
addr := <-serverAddr
|
addr := <-serverAddr
|
||||||
sess, err := DialAddr(addr.String(), &tls.Config{InsecureSkipVerify: true}, nil)
|
sess, err := quic.DialAddr(addr.String(), &tls.Config{InsecureSkipVerify: true}, nil)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
close(handshakeChan)
|
close(handshakeChan)
|
||||||
str, err := sess.AcceptStream()
|
str, err := sess.AcceptStream()
|
||||||
Reference in New Issue
Block a user