package opentsdb import ( "reflect" "testing" "fmt" "net" "net/http" "net/http/httptest" "net/url" "strconv" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/testutil" //"github.com/stretchr/testify/require" ) func TestCleanTags(t *testing.T) { var tagtests = []struct { ptIn map[string]string outTags TagSet }{ { map[string]string{"one": "two", "three": "four"}, TagSet{"one": "two", "three": "four"}, }, { map[string]string{"aaa": "bbb"}, TagSet{"aaa": "bbb"}, }, { map[string]string{"Sp%ci@l Chars": "g$t repl#ced"}, TagSet{"Sp-ci-l_Chars": "g-t_repl-ced"}, }, { map[string]string{}, TagSet{}, }, } for _, tt := range tagtests { tags := cleanTags(tt.ptIn) if !reflect.DeepEqual(tags, tt.outTags) { t.Errorf("\nexpected %+v\ngot %+v\n", tt.outTags, tags) } } } func TestBuildTagsTelnet(t *testing.T) { var tagtests = []struct { ptIn TagSet outTags string }{ { TagSet{"one": "two", "three": "four"}, "one=two three=four", }, { TagSet{"aaa": "bbb"}, "aaa=bbb", }, { TagSet{"one": "two", "aaa": "bbb"}, "aaa=bbb one=two", }, { TagSet{}, "", }, } for _, tt := range tagtests { tags := tt.ptIn.ToLineFormat() if !reflect.DeepEqual(tags, tt.outTags) { t.Errorf("\nexpected %+v\ngot %+v\n", tt.outTags, tags) } } } func BenchmarkHttpSend(b *testing.B) { const BatchSize = 50 const MetricsCount = 4*BatchSize metrics := make([]telegraf.Metric, MetricsCount) for i:=0; i