influxdb/stress/v2/stress_client/commune_test.go

50 lines
1.3 KiB
Go
Raw Normal View History

package stressClient
2016-04-21 18:03:43 +00:00
import (
"testing"
)
func TestCommunePoint(t *testing.T) {
2016-04-28 21:22:39 +00:00
comm := newCommune(5)
2016-04-21 18:03:43 +00:00
pt := "write,tag=tagVal fooField=5 1460912595"
2016-04-28 21:22:39 +00:00
comm.ch <- pt
2016-04-21 18:03:43 +00:00
point := comm.point("s")
if point.Name() != "write" {
t.Errorf("expected: write\ngot: %v", point.Name())
}
if point.Tags()["tag"] != "tagVal" {
t.Errorf("expected: tagVal\ngot: %v", point.Tags()["tag"])
}
if int(point.Fields()["fooField"].(float64)) != 5 {
t.Errorf("expected: 5\ngot: %v\n", point.Fields()["fooField"])
}
// Make sure commune returns the prev point
2016-04-28 21:22:39 +00:00
comm.ch <- ""
2016-04-21 18:03:43 +00:00
point = comm.point("s")
if point.Name() != "write" {
t.Errorf("expected: write\ngot: %v", point.Name())
}
if point.Tags()["tag"] != "tagVal" {
t.Errorf("expected: tagVal\ngot: %v", point.Tags()["tag"])
}
if int(point.Fields()["fooField"].(float64)) != 5 {
t.Errorf("expected: 5\ngot: %v\n", point.Fields()["fooField"])
}
}
func TestSetCommune(t *testing.T) {
sf, _, _ := NewTestStressTest()
2016-04-21 18:03:43 +00:00
ch := sf.SetCommune("foo_name")
ch <- "write,tag=tagVal fooField=5 1460912595"
pt := sf.GetPoint("foo_name", "s")
if pt.Name() != "write" {
t.Errorf("expected: write\ngot: %v", pt.Name())
}
if pt.Tags()["tag"] != "tagVal" {
t.Errorf("expected: tagVal\ngot: %v", pt.Tags()["tag"])
}
if int(pt.Fields()["fooField"].(float64)) != 5 {
t.Errorf("expected: 5\ngot: %v\n", pt.Fields()["fooField"])
}
}