move benchmark test to a separate package

This commit is contained in:
Marten Seemann
2017-07-25 09:41:39 +07:00
parent 2c2ca2e670
commit d108e10420
3 changed files with 21 additions and 7 deletions

View File

@@ -4,16 +4,16 @@ set -e
go get -t ./...
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
if [ ${TESTMODE} == "integration" ]; then
# run benchmark tests
ginkgo --randomizeAllSpecs --randomizeSuites --trace --progress -focus "Benchmark"
ginkgo --randomizeAllSpecs --randomizeSuites --trace --progress benchmark
# run benchmark tests with the Go race detector
# The Go race detector only works on amd64.
if [ ${TRAVIS_GOARCH} == 'amd64' ]; then
ginkgo --race --randomizeAllSpecs --randomizeSuites --trace --progress -focus "Benchmark"
ginkgo --race --randomizeAllSpecs --randomizeSuites --trace --progress benchmark
fi
# run integration tests
ginkgo -v -r --randomizeAllSpecs --randomizeSuites --trace --progress integrationtests

View 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")
}

View File

@@ -1,4 +1,4 @@
package quic
package benchmark
import (
"bytes"
@@ -8,6 +8,7 @@ import (
"math/rand"
"net"
quic "github.com/lucas-clemente/quic-go"
"github.com/lucas-clemente/quic-go/protocol"
"github.com/lucas-clemente/quic-go/testdata"
. "github.com/onsi/ginkgo"
@@ -25,14 +26,14 @@ var _ = Describe("Benchmarks", func() {
Context(fmt.Sprintf("with version %d", version), func() {
Measure("transferring a file", func(b Benchmarker) {
var ln Listener
var ln quic.Listener
serverAddr := make(chan net.Addr)
handshakeChan := make(chan struct{})
// start the server
go func() {
defer GinkgoRecover()
var err error
ln, err = ListenAddr("localhost:0", testdata.GetTLSConfig(), nil)
ln, err = quic.ListenAddr("localhost:0", testdata.GetTLSConfig(), nil)
Expect(err).ToNot(HaveOccurred())
serverAddr <- ln.Addr()
sess, err := ln.Accept()
@@ -50,7 +51,7 @@ var _ = Describe("Benchmarks", func() {
// start the client
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())
close(handshakeChan)
str, err := sess.AcceptStream()