Deliver empty metric tracking group immediately (#5176)
This commit is contained in:
@@ -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 {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user