promql: Add NaN tests for avg and avg_over_time

Signed-off-by: beorn7 <beorn@grafana.com>
pull/15475/head
beorn7 2024-11-27 13:08:34 +01:00
parent 9ad93ba8df
commit a44c449155
2 changed files with 19 additions and 0 deletions

View File

@ -543,6 +543,7 @@ load 10s
data{test="bigzero",point="b"} -9.988465674311579e+307 data{test="bigzero",point="b"} -9.988465674311579e+307
data{test="bigzero",point="c"} 9.988465674311579e+307 data{test="bigzero",point="c"} 9.988465674311579e+307
data{test="bigzero",point="d"} 9.988465674311579e+307 data{test="bigzero",point="d"} 9.988465674311579e+307
data{test="value is nan"} NaN
eval instant at 1m avg(data{test="ten"}) eval instant at 1m avg(data{test="ten"})
{} 10 {} 10
@ -577,6 +578,10 @@ eval instant at 1m avg(data{test="-big"})
eval instant at 1m avg(data{test="bigzero"}) eval instant at 1m avg(data{test="bigzero"})
{} 0 {} 0
# If NaN is in the mix, the result is NaN.
eval instant at 1m avg(data)
{} NaN
# Test summing and averaging extreme values. # Test summing and averaging extreme values.
clear clear

View File

@ -713,6 +713,7 @@ load 10s
metric8 9.988465674311579e+307 9.988465674311579e+307 metric8 9.988465674311579e+307 9.988465674311579e+307
metric9 -9.988465674311579e+307 -9.988465674311579e+307 -9.988465674311579e+307 metric9 -9.988465674311579e+307 -9.988465674311579e+307 -9.988465674311579e+307
metric10 -9.988465674311579e+307 9.988465674311579e+307 metric10 -9.988465674311579e+307 9.988465674311579e+307
metric11 1 2 3 NaN NaN
eval instant at 55s avg_over_time(metric[1m]) eval instant at 55s avg_over_time(metric[1m])
{} 3 {} 3
@ -806,6 +807,19 @@ eval instant at 45s sum_over_time(metric10[1m])/count_over_time(metric10[1m])
eval instant at 1m sum_over_time(metric10[2m])/count_over_time(metric10[2m]) eval instant at 1m sum_over_time(metric10[2m])/count_over_time(metric10[2m])
{} 0 {} 0
# NaN behavior.
eval instant at 20s avg_over_time(metric11[1m])
{} 2
eval instant at 30s avg_over_time(metric11[1m])
{} NaN
eval instant at 1m avg_over_time(metric11[1m])
{} NaN
eval instant at 1m sum_over_time(metric11[1m])/count_over_time(metric11[1m])
{} NaN
# Test if very big intermediate values cause loss of detail. # Test if very big intermediate values cause loss of detail.
clear clear
load 10s load 10s