Skip to content

Commit

Permalink
Merged pull request influxdata#1493 from influxdata/nc-update-benchmark
Browse files Browse the repository at this point in the history
update benchmark to use better helper methods
  • Loading branch information
nathanielc committed Jul 20, 2017
2 parents cf187bb + 9438033 commit a16064c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
21 changes: 6 additions & 15 deletions integrations/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"bytes"
"fmt"
"io"
"log"
"net/http"
"net/http/httptest"
"net/url"
Expand All @@ -26,8 +25,6 @@ import (

"github.com/influxdata/kapacitor"
"github.com/influxdata/kapacitor/services/httpd"
"github.com/influxdata/kapacitor/services/logging/loggingtest"
"github.com/influxdata/kapacitor/services/noauth"
)

const (
Expand Down Expand Up @@ -172,13 +169,6 @@ func Bench(b *testing.B, tasksCount, pointCount, expectedProcessedCount int, tic
config := httpd.NewConfig()
config.BindAddress = ":0" // Choose port dynamically
config.LogEnabled = false
httpdService := httpd.NewService(config, "localhost", logService.NewLogger("[http] ", log.LstdFlags), logService)

httpdService.Handler.AuthService = noauth.NewService(logService.NewLogger("[noauth] ", log.LstdFlags))
err := httpdService.Open()
if err != nil {
b.Fatal(err)
}

writes := make([]struct {
request *http.Request
Expand All @@ -197,12 +187,12 @@ func Bench(b *testing.B, tasksCount, pointCount, expectedProcessedCount int, tic
for i := 0; i < b.N; i++ {
// Do not time setup
b.StopTimer()
tm := kapacitor.NewTaskMaster("bench", newServerInfo(), loggingtest.New())
tm.HTTPDService = httpdService
tm.UDFService = nil
tm.TaskStore = taskStore{}
tm.DeadmanService = deadman{}
tm, err := createTaskMaster()
if err != nil {
b.Fatal(err)
}
tm.Open()
httpdService := tm.HTTPDService.(*httpd.Service)

httpdService.Handler.PointsWriter = tm
tasks := createTasks(b, tm, tasksCount, tickScript, dbrps)
Expand Down Expand Up @@ -241,6 +231,7 @@ func Bench(b *testing.B, tasksCount, pointCount, expectedProcessedCount int, tic
validateTasks(b, tm, tasks, expectedProcessedCount)

tm.Close()
httpdService.Close()
}
}

Expand Down
2 changes: 2 additions & 0 deletions integrations/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"net/http/httptest"
"reflect"
"testing"
"time"

"github.com/influxdata/kapacitor"
Expand All @@ -23,6 +24,7 @@ func newHTTPDService() *httpd.Service {
// create API server
config := httpd.NewConfig()
config.BindAddress = ":0" // Choose port dynamically
config.LogEnabled = testing.Verbose()
httpService := httpd.NewService(config, "localhost", logService.NewLogger("[http] ", log.LstdFlags), logService)
err := httpService.Open()
if err != nil {
Expand Down

0 comments on commit a16064c

Please sign in to comment.