Skip to content

Commit

Permalink
Make the benchmark work in spite of golang/dep#433
Browse files Browse the repository at this point in the history
Since we can't rely on sub-packages of logrus, just define a
plausible-enough null logger for benchmarks.
  • Loading branch information
asf-stripe committed Sep 14, 2017
1 parent d394215 commit 964b888
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"testing"
"time"

"github.com/Sirupsen/logrus"
"github.com/golang/protobuf/proto"
"github.com/sirupsen/logrus/hooks/test"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stripe/veneur/protocol"
Expand Down Expand Up @@ -877,6 +877,17 @@ func TestNewFromServerConfigRenamedVariables(t *testing.T) {
assert.Equal(t, 99, addr.Port)
}

// This is necessary until we can import
// github.com/sirupsen/logrus/test - it's currently failing due to dep
// insisting on pulling the repo in with its capitalized name.
//
// TODO: Revisit once https://github.com/golang/dep/issues/433 is fixed
func nullLogger() *logrus.Logger {
logger := logrus.New()
logger.Out = ioutil.Discard
return logger
}

// BenchmarkSendSSFUNIX sends b.N metrics to veneur and waits until
// all of them have been read (not processed).
func BenchmarkSendSSFUNIX(b *testing.B) {
Expand All @@ -902,8 +913,7 @@ func BenchmarkSendSSFUNIX(b *testing.B) {
b.Fatal(err)
}
// Simulate a metrics worker:
logger, _ := test.NewNullLogger()
w := NewWorker(0, nil, logger)
w := NewWorker(0, nil, nullLogger())
s.Workers = []*Worker{w}
go func() {
}()
Expand Down Expand Up @@ -978,8 +988,7 @@ func BenchmarkSendSSFUDP(b *testing.B) {
require.NoError(b, err)

// Simulate a metrics worker:
logger, _ := test.NewNullLogger()
w := NewWorker(0, nil, logger)
w := NewWorker(0, nil, nullLogger())
s.Workers = []*Worker{w}

go func() {
Expand Down

0 comments on commit 964b888

Please sign in to comment.