Like Prometheus, but for logs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
loki/pkg/ingester/stream_rate_calculator_test.go

25 lines
467 B

package ingester
import (
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestStreamRateCalculator(t *testing.T) {
calc := NewStreamRateCalculator()
defer calc.Stop()
for i := 0; i < 100; i++ {
calc.Record(0, 100)
}
require.Eventually(t, func() bool {
return calc.RateFor(0) == 10000
}, 2*time.Second, 250*time.Millisecond)
require.Eventually(t, func() bool {
return calc.RateFor(0) == 0
}, 2*time.Second, 250*time.Millisecond)
}