diff --git a/.circleci/config.yml b/.circleci/config.yml index 8f21c1aa..5c6e6e0e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,12 +24,6 @@ jobs: - run: name: "Build infos" command: go version - - run: - name: "Run benchmark tests" - command: ginkgo -randomizeAllSpecs -trace benchmark -- -size=10 - - run: - name: "Run benchmark tests with race detector" - command: ginkgo -race -randomizeAllSpecs -trace benchmark -- -size=5 - run: name: "Run tools tests" command: ginkgo -race -r -v -randomizeAllSpecs -trace integrationtests/tools diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 1985081c..4b30f747 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -22,18 +22,18 @@ jobs: - name: Run tests env: TIMESCALE_FACTOR: 10 - run: ginkgo -r -v -cover -randomizeAllSpecs -randomizeSuites -trace -skipPackage integrationtests,benchmark + run: ginkgo -r -v -cover -randomizeAllSpecs -randomizeSuites -trace -skipPackage integrationtests - name: Run tests (32 bit) if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX. env: TIMESCALE_FACTOR: 10 GOARCH: 386 - run: ginkgo -r -v -cover -coverprofile coverage.txt -outputdir . -randomizeAllSpecs -randomizeSuites -trace -skipPackage integrationtests,benchmark + run: ginkgo -r -v -cover -coverprofile coverage.txt -outputdir . -randomizeAllSpecs -randomizeSuites -trace -skipPackage integrationtests - name: Run tests with race detector if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow env: TIMESCALE_FACTOR: 20 - run: ginkgo -r -v -race -randomizeAllSpecs -randomizeSuites -trace -skipPackage integrationtests,benchmark + run: ginkgo -r -v -race -randomizeAllSpecs -randomizeSuites -trace -skipPackage integrationtests - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 with: diff --git a/benchmark/benchmark_suite_test.go b/benchmark/benchmark_suite_test.go deleted file mode 100644 index d2334429..00000000 --- a/benchmark/benchmark_suite_test.go +++ /dev/null @@ -1,27 +0,0 @@ -package benchmark - -import ( - "flag" - "math/rand" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestBenchmark(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Benchmark Suite") -} - -var size int // file size in MB, will be read from flags - -func init() { - flag.IntVar(&size, "size", 50, "data length (in MB)") -} - -var _ = BeforeSuite(func() { - rand.Seed(GinkgoRandomSeed()) - - flag.Parse() -}) diff --git a/benchmark/benchmark_test.go b/benchmark/benchmark_test.go deleted file mode 100644 index 451e6dbb..00000000 --- a/benchmark/benchmark_test.go +++ /dev/null @@ -1,92 +0,0 @@ -package benchmark - -import ( - "bytes" - "context" - "crypto/tls" - "fmt" - "io" - "math/rand" - "net" - - quic "github.com/lucas-clemente/quic-go" - "github.com/lucas-clemente/quic-go/internal/protocol" - "github.com/lucas-clemente/quic-go/internal/testdata" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Benchmarks", func() { - for i := range protocol.SupportedVersions { - version := protocol.SupportedVersions[i] - - Context(fmt.Sprintf("with version %s", version), func() { - var data []byte - var dataLen int - - BeforeEach(func() { - dataLen = size * /* MB */ 1e6 - data = make([]byte, dataLen) - rand.Read(data) // no need to check for an error. math.Rand.Read never errors - }) - - Measure("transferring a file", func(b Benchmarker) { - var ln quic.Listener - serverAddr := make(chan net.Addr) - handshakeChan := make(chan struct{}) - // start the server - go func() { - defer GinkgoRecover() - var err error - tlsConf := testdata.GetTLSConfig() - tlsConf.NextProtos = []string{"benchmark"} - ln, err = quic.ListenAddr( - "localhost:0", - tlsConf, - &quic.Config{Versions: []protocol.VersionNumber{version}}, - ) - Expect(err).ToNot(HaveOccurred()) - serverAddr <- ln.Addr() - sess, err := ln.Accept(context.Background()) - Expect(err).ToNot(HaveOccurred()) - // wait for the client to complete the handshake before sending the data - // this should not be necessary, but due to timing issues on the CIs, this is necessary to avoid sending too many undecryptable packets - <-handshakeChan - str, err := sess.OpenStream() - Expect(err).ToNot(HaveOccurred()) - _, err = str.Write(data) - Expect(err).ToNot(HaveOccurred()) - err = str.Close() - Expect(err).ToNot(HaveOccurred()) - }() - - // start the client - addr := <-serverAddr - sess, err := quic.DialAddr( - addr.String(), - &tls.Config{InsecureSkipVerify: true, NextProtos: []string{"benchmark"}}, - &quic.Config{Versions: []protocol.VersionNumber{version}}, - ) - Expect(err).ToNot(HaveOccurred()) - close(handshakeChan) - str, err := sess.AcceptStream(context.Background()) - Expect(err).ToNot(HaveOccurred()) - - buf := &bytes.Buffer{} - // measure the time it takes to download the dataLen bytes - // note we're measuring the time for the transfer, i.e. excluding the handshake - runtime := b.Time("transfer time", func() { - _, err := io.Copy(buf, str) - Expect(err).NotTo(HaveOccurred()) - }) - Expect(buf.Bytes()).To(Equal(data)) - - b.RecordValue("transfer rate [MB/s]", float64(dataLen)/1e6/runtime.Seconds()) - - ln.Close() - sess.CloseWithError(0, "") - }, 3) - }) - } -})