Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jackzampolin committed Apr 28, 2016
1 parent 92c5e38 commit 9a8a794
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 129 deletions.
1 change: 0 additions & 1 deletion stress/v2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func RunStress(file string) {
resp := blankResponse()
s.ResultsChan <- resp
resp.Tracer.Wait()
// close s.ResultsChan

// Compile all Reports
for _, stmt := range stmts {
Expand Down
19 changes: 6 additions & 13 deletions stress/v2/ponyExpress/commune.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,13 @@ import (
// Communes are a method for passing points between InsertStatements and QueryStatements.

type commune struct {
ch <-chan string
ch chan string
storedPoint models.Point
}

// NewCommune creates a new commune with a buffered chan of length n
func newCommune(n int) (*commune, chan<- string) {
ch := make(chan string, n)
c := &commune{
ch: ch,
}
return c, ch
func newCommune(n int) *commune {
return &commune{ch: make(chan string, n)}
}

func (c *commune) point(precision string) models.Point {
Expand All @@ -33,23 +29,20 @@ func (c *commune) point(precision string) models.Point {
log.Fatalf("Error parsing point for commune\n point: %v\n error: %v\n", pt, err)
}

if len(p) != 0 {
c.storedPoint = p[0]
}

if len(p) == 0 {
return c.storedPoint
}

c.storedPoint = p[0]
return p[0]
}

// SetCommune creates a new commune on the StoreFront
func (sf *StoreFront) SetCommune(name string) chan<- string {
com, comCh := newCommune(10)
com := newCommune(10)
sf.communes[name] = com

return comCh
return com.ch
}

// GetPoint is called by a QueryStatement and retrieves a point sent by the associated InsertStatement
Expand Down
6 changes: 3 additions & 3 deletions stress/v2/ponyExpress/commune_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
)

func TestCommunePoint(t *testing.T) {
comm, ch := newCommune(5)
comm := newCommune(5)
pt := "write,tag=tagVal fooField=5 1460912595"
ch <- pt
comm.ch <- pt
point := comm.point("s")
if point.Name() != "write" {
t.Errorf("expected: write\ngot: %v", point.Name())
Expand All @@ -19,7 +19,7 @@ func TestCommunePoint(t *testing.T) {
t.Errorf("expected: 5\ngot: %v\n", point.Fields()["fooField"])
}
// Make sure commune returns the prev point
ch <- ""
comm.ch <- ""
point = comm.point("s")
if point.Name() != "write" {
t.Errorf("expected: write\ngot: %v", point.Name())
Expand Down
8 changes: 0 additions & 8 deletions stress/v2/ponyExpress/ponyExpress_test.go

This file was deleted.

84 changes: 0 additions & 84 deletions stress/v2/ponyExpress/ponyExpress_write_test.go

This file was deleted.

8 changes: 7 additions & 1 deletion stress/v2/statement/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@ func TestExecRun(t *testing.T) {
e := newTestExec()
s, _, _ := ponyExpress.NewTestStoreFront()
e.Run(s)
if e == nil {
t.Fail()
}
}

func TestExecReport(t *testing.T) {
e := newTestExec()
s, _, _ := ponyExpress.NewTestStoreFront()
e.Report(s)
rep := e.Report(s)
if rep != "" {
t.Fail()
}
}

func newTestExec() *ExecStatement {
Expand Down
8 changes: 7 additions & 1 deletion stress/v2/statement/go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@ func TestGoRun(t *testing.T) {
e := newTestGo()
s, _, _ := ponyExpress.NewTestStoreFront()
e.Run(s)
if e == nil {
t.Fail()
}
}

func TestGoReport(t *testing.T) {
e := newTestGo()
s, _, _ := ponyExpress.NewTestStoreFront()
e.Report(s)
report := e.Report(s)
if report != "Go " {
t.Errorf("Expected: %v\nGot: %v\n", "Go ", report)
}
}

func newTestGo() *GoStatement {
Expand Down
15 changes: 7 additions & 8 deletions stress/v2/statement/insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,15 @@ func (i *InsertStatement) Run(s *ponyExpress.StoreFront) {
buf = temp
}

// TODO: Racy
// Has to do with InsertStatement and QueryStatement communication
if len(comCh) < cap(comCh) {
go func(point string) {
select {
case comCh <- point:
break
default:
break
}
}(point)
select {
case comCh <- point:
break
default:
break
}
}

}
Expand Down
5 changes: 0 additions & 5 deletions stress/v2/statement/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ import (
// TODO: Refactor this file to utilize a common interface
// This will make adding new reports easier in the future

// type report interface {
// String() string
// Point() *influx.Point
// }

// Runs performance numbers for insert statements
type insertReport struct {
name string
Expand Down
8 changes: 4 additions & 4 deletions stress/v2/statement/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,30 @@ func (i *SetStatement) Run(s *ponyExpress.StoreFront) {
// Set the date for the first point entered into the database
case "startdate":
s.Lock()
defer s.Unlock()
s.StartDate = d.Value
s.Unlock()

// Lives on StoreFront
// Set the BatchSize for writes
case "batchsize":
s.Lock()
defer s.Unlock()
s.BatchSize = parseInt(d.Value)
s.Unlock()

// Lives on StoreFront
// Reset the ResultsClient to have a new address
case "resultsaddress":
s.Lock()
defer s.Unlock()
s.SetResultsClient(influx.HTTPConfig{Addr: fmt.Sprintf("http://%v/", d.Value)})
s.Unlock()

// TODO: Make TestName actually change the reporting DB
// Lives on StoreFront
// Set the TestName that controls reporting DB
case "testname":
s.Lock()
defer s.Unlock()
s.TestName = d.Value
s.Unlock()

// All other variables live on ponyExpress
default:
Expand Down
9 changes: 8 additions & 1 deletion stress/v2/statement/wait_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package statement

import (
"strings"
"testing"

"github.com/influxdata/influxdb/stress/v2/ponyExpress"
Expand All @@ -19,12 +20,18 @@ func TestWaitRun(t *testing.T) {
e := newTestWait()
s, _, _ := ponyExpress.NewTestStoreFront()
e.Run(s)
if e == nil {
t.Fail()
}
}

func TestWaitReport(t *testing.T) {
e := newTestWait()
s, _, _ := ponyExpress.NewTestStoreFront()
e.Report(s)
rpt := e.Report(s)
if !strings.Contains(rpt, "WAIT") {
t.Fail()
}
}

func newTestWait() *WaitStatement {
Expand Down

0 comments on commit 9a8a794

Please sign in to comment.