diff --git a/pkg/streamingpromql/testdata/ours/functions.test b/pkg/streamingpromql/testdata/ours/functions.test index fb0ebaef5a..ef1ada5e28 100644 --- a/pkg/streamingpromql/testdata/ours/functions.test +++ b/pkg/streamingpromql/testdata/ours/functions.test @@ -682,3 +682,104 @@ eval range from 0 to 7m step 1m last_over_time(some_metric_count[3m]) some_metric_count{env="prod", cluster="eu"} _ _ _ 0 1 2 3 4 some_metric_count{env="prod", cluster="us"} _ _ _ 0 2 4 6 8 some_metric_count{env="prod", cluster="au"} _ _ _ {{count:5}} {{count:10}} {{count:15}} {{count:20}} {{count:25}} + +# Test time-related functions. +load 5m + histogram_sample {{schema:0 sum:1 count:1}} + +eval range from 0 to 7m step 1m year() + {} 1970 1970 1970 1970 1970 1970 1970 1970 + +eval range from 0 to 7m step 1m time() + {} 0 60 120 180 240 300 360 420 + +eval range from 0 to 7m step 1m year(vector(1136239445)) + {} 2006 2006 2006 2006 2006 2006 2006 2006 + +eval range from 0 to 7m step 1m month() + {} 1 1 1 1 1 1 1 1 + +eval range from 0 to 7m step 1m month(vector(1136239445)) + {} 1 1 1 1 1 1 1 1 + +eval range from 0 to 7m step 1m day_of_month() + {} 1 1 1 1 1 1 1 1 + +eval range from 0 to 7m step 1m day_of_month(vector(1136239445)) + {} 2 2 2 2 2 2 2 2 + +eval range from 0 to 7m step 1m day_of_year() + {} 1 1 1 1 1 1 1 1 + +eval range from 0 to 7m step 1m day_of_year(vector(1136239445)) + {} 2 2 2 2 2 2 2 2 + +# Thursday. +eval range from 0 to 7m step 1m day_of_week() + {} 4 4 4 4 4 4 4 4 + +eval range from 0 to 7m step 1m day_of_week(vector(1136239445)) + {} 1 1 1 1 1 1 1 1 + +eval range from 0 to 7m step 1m hour() + {} 0 0 0 0 0 0 0 0 + +eval range from 0 to 7m step 1m hour(vector(1136239445)) + {} 22 22 22 22 22 22 22 22 + +eval range from 0 to 7m step 1m minute() + {} 0 1 2 3 4 5 6 7 + +eval range from 0 to 7m step 1m minute(vector(1136239445)) + {} 4 4 4 4 4 4 4 4 + +# 2008-12-31 23:59:59 just before leap second. +eval range from 0 to 7m step 1m year(vector(1230767999)) + {} 2008 2008 2008 2008 2008 2008 2008 2008 + +# 2009-01-01 00:00:00 just after leap second. +eval range from 0 to 7m step 1m year(vector(1230768000)) + {} 2009 2009 2009 2009 2009 2009 2009 2009 + +# 2016-02-29 23:59:59 February 29th in leap year. +eval range from 0 to 7m step 1m month(vector(1456790399)) + day_of_month(vector(1456790399)) / 100 + {} 2.29 2.29 2.29 2.29 2.29 2.29 2.29 2.29 + +# 2016-03-01 00:00:00 March 1st in leap year. +eval range from 0 to 7m step 1m month(vector(1456790400)) + day_of_month(vector(1456790400)) / 100 + {} 3.01 3.01 3.01 3.01 3.01 3.01 3.01 3.01 + +# 2016-12-31 13:37:00 366th day in leap year. +eval range from 0 to 7m step 1m day_of_year(vector(1483191420)) + {} 366 366 366 366 366 366 366 366 + +# 2022-12-31 13:37:00 365th day in non-leap year. +eval range from 0 to 7m step 1m day_of_year(vector(1672493820)) + {} 365 365 365 365 365 365 365 365 + +# February 1st 2016 in leap year. +eval range from 0 to 7m step 1m days_in_month(vector(1454284800)) + {} 29 29 29 29 29 29 29 29 + +# February 1st 2017 not in leap year. +eval range from 0 to 7m step 1m days_in_month(vector(1485907200)) + {} 28 28 28 28 28 28 28 28 + +# Test for histograms. +eval range from 0 to 7m step 1m day_of_month(histogram_sample) + +eval range from 0 to 7m step 1m day_of_week(histogram_sample) + +eval range from 0 to 7m step 1m day_of_year(histogram_sample) + +eval range from 0 to 7m step 1m days_in_month(histogram_sample) + +eval range from 0 to 7m step 1m hour(histogram_sample) + +eval range from 0 to 7m step 1m minute(histogram_sample) + +eval range from 0 to 7m step 1m month(histogram_sample) + +eval range from 0 to 7m step 1m year(histogram_sample) + +clear