Deliver empty metric tracking group immediately (#5176)

This commit is contained in:
Daniel Nelson
2018-12-26 19:36:10 -08:00
committed by GitHub
parent 72089042be
commit 7497a2027b
2 changed files with 33 additions and 11 deletions

View File

@@ -9,7 +9,6 @@ import (
"time"
"github.com/influxdata/telegraf"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -127,6 +126,21 @@ func TestSetPrecision(t *testing.T) {
}
}
func TestAddTrackingMetricGroupEmpty(t *testing.T) {
ch := make(chan telegraf.Metric, 10)
metrics := []telegraf.Metric{}
acc := NewAccumulator(&TestMetricMaker{}, ch).WithTracking(1)
id := acc.AddTrackingMetricGroup(metrics)
select {
case tracking := <-acc.Delivered():
require.Equal(t, tracking.ID(), id)
default:
t.Fatal("empty group should be delivered immediately")
}
}
type TestMetricMaker struct {
}