promql: Organize legacy tests into appropriate files (#7989)

* Separate tests into:
** Aggregators
** Functions
** Operators
** Selectors
* Remove simple files and place tests into other files.
* Eliminate some of the _over_time tests since there are already plenty of
  edge cases present in the functions.test file.

Relates to #740

Signed-off-by: Harold Dost <harolddost@gmail.com>
This commit is contained in:
Harold Dost 2020-10-07 11:09:20 +02:00 committed by GitHub
parent 6be3ebdfe7
commit bf7c771f54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 388 additions and 394 deletions

View file

@ -77,7 +77,108 @@ eval instant at 50m sum by (group) (http_requests{job="api-server"})
eval instant at 50m sum(sum by (group) (http_requests{job="api-server"})) by (job)
{} 1000
eval instant at 50m SUM(http_requests)
{} 3600
eval instant at 50m SUM(http_requests{instance="0"}) BY(job)
{job="api-server"} 400
{job="app-server"} 1200
eval instant at 50m SUM(http_requests) BY (job)
{job="api-server"} 1000
{job="app-server"} 2600
# Non-existent labels mentioned in BY-clauses shouldn't propagate to output.
eval instant at 50m SUM(http_requests) BY (job, nonexistent)
{job="api-server"} 1000
{job="app-server"} 2600
eval instant at 50m COUNT(http_requests) BY (job)
{job="api-server"} 4
{job="app-server"} 4
eval instant at 50m SUM(http_requests) BY (job, group)
{group="canary", job="api-server"} 700
{group="canary", job="app-server"} 1500
{group="production", job="api-server"} 300
{group="production", job="app-server"} 1100
eval instant at 50m AVG(http_requests) BY (job)
{job="api-server"} 250
{job="app-server"} 650
eval instant at 50m MIN(http_requests) BY (job)
{job="api-server"} 100
{job="app-server"} 500
eval instant at 50m MAX(http_requests) BY (job)
{job="api-server"} 400
{job="app-server"} 800
eval instant at 50m abs(-1 * http_requests{group="production",job="api-server"})
{group="production", instance="0", job="api-server"} 100
{group="production", instance="1", job="api-server"} 200
eval instant at 50m floor(0.004 * http_requests{group="production",job="api-server"})
{group="production", instance="0", job="api-server"} 0
{group="production", instance="1", job="api-server"} 0
eval instant at 50m ceil(0.004 * http_requests{group="production",job="api-server"})
{group="production", instance="0", job="api-server"} 1
{group="production", instance="1", job="api-server"} 1
eval instant at 50m round(0.004 * http_requests{group="production",job="api-server"})
{group="production", instance="0", job="api-server"} 0
{group="production", instance="1", job="api-server"} 1
# Round should correctly handle negative numbers.
eval instant at 50m round(-1 * (0.004 * http_requests{group="production",job="api-server"}))
{group="production", instance="0", job="api-server"} 0
{group="production", instance="1", job="api-server"} -1
# Round should round half up.
eval instant at 50m round(0.005 * http_requests{group="production",job="api-server"})
{group="production", instance="0", job="api-server"} 1
{group="production", instance="1", job="api-server"} 1
eval instant at 50m round(-1 * (0.005 * http_requests{group="production",job="api-server"}))
{group="production", instance="0", job="api-server"} 0
{group="production", instance="1", job="api-server"} -1
eval instant at 50m round(1 + 0.005 * http_requests{group="production",job="api-server"})
{group="production", instance="0", job="api-server"} 2
{group="production", instance="1", job="api-server"} 2
eval instant at 50m round(-1 * (1 + 0.005 * http_requests{group="production",job="api-server"}))
{group="production", instance="0", job="api-server"} -1
{group="production", instance="1", job="api-server"} -2
# Round should accept the number to round nearest to.
eval instant at 50m round(0.0005 * http_requests{group="production",job="api-server"}, 0.1)
{group="production", instance="0", job="api-server"} 0.1
{group="production", instance="1", job="api-server"} 0.1
eval instant at 50m round(2.1 + 0.0005 * http_requests{group="production",job="api-server"}, 0.1)
{group="production", instance="0", job="api-server"} 2.2
{group="production", instance="1", job="api-server"} 2.2
eval instant at 50m round(5.2 + 0.0005 * http_requests{group="production",job="api-server"}, 0.1)
{group="production", instance="0", job="api-server"} 5.3
{group="production", instance="1", job="api-server"} 5.3
# Round should work correctly with negative numbers and multiple decimal places.
eval instant at 50m round(-1 * (5.2 + 0.0005 * http_requests{group="production",job="api-server"}), 0.1)
{group="production", instance="0", job="api-server"} -5.2
{group="production", instance="1", job="api-server"} -5.3
# Round should work correctly with big toNearests.
eval instant at 50m round(0.025 * http_requests{group="production",job="api-server"}, 5)
{group="production", instance="0", job="api-server"} 5
{group="production", instance="1", job="api-server"} 5
eval instant at 50m round(0.045 * http_requests{group="production",job="api-server"}, 5)
{group="production", instance="0", job="api-server"} 5
{group="production", instance="1", job="api-server"} 10
# Standard deviation and variance.
eval instant at 50m stddev(http_requests)
@ -108,7 +209,6 @@ eval instant at 50m stdvar(http_requests)
{} 0.0
# Regression test for missing separator byte in labelsToGroupingKey.
clear
load 5m

View file

@ -8,4 +8,15 @@ load 1s
eval instant at 4s count by(namespace, pod, cpu) (node_cpu_seconds_total{cpu=~".*",job="node-exporter",mode="idle",namespace="observability",pod="node-exporter-l454v"}) * on(namespace, pod) group_left(node) node_namespace_pod:kube_pod_info:{namespace="observability",pod="node-exporter-l454v"}
{cpu="10",namespace="observability",node="gke-search-infra-custom-96-253440-fli-d135b119-jx00",pod="node-exporter-l454v"} 1
{cpu="35",namespace="observability",node="gke-search-infra-custom-96-253440-fli-d135b119-jx00",pod="node-exporter-l454v"} 1
{cpu="89",namespace="observability",node="gke-search-infra-custom-96-253440-fli-d135b119-jx00",pod="node-exporter-l454v"} 1
{cpu="89",namespace="observability",node="gke-search-infra-custom-96-253440-fli-d135b119-jx00",pod="node-exporter-l454v"} 1
clear
# Test duplicate labelset in promql output.
load 5m
testmetric1{src="a",dst="b"} 0
testmetric2{src="a",dst="b"} 1
eval_fail instant at 0m ceil({__name__=~'testmetric1|testmetric2'})
clear

View file

@ -95,6 +95,64 @@ eval instant at 30m increase(http_requests[30m])
clear
# Tests for rate().
load 5m
testcounter_reset_middle 0+10x4 0+10x5
testcounter_reset_end 0+10x9 0 10
# Counter resets at in the middle of range are handled correctly by rate().
eval instant at 50m rate(testcounter_reset_middle[50m])
{} 0.03
# Counter resets at end of range are ignored by rate().
eval instant at 50m rate(testcounter_reset_end[5m])
{} 0
clear
load 5m
calculate_rate_offset{x="a"} 0+10x10
calculate_rate_offset{x="b"} 0+20x10
calculate_rate_window 0+80x10
# Rates should calculate per-second rates.
eval instant at 50m rate(calculate_rate_window[50m])
{} 0.26666666666666666
eval instant at 50m rate(calculate_rate_offset[10m] offset 5m)
{x="a"} 0.03333333333333333
{x="b"} 0.06666666666666667
clear
load 4m
testcounter_zero_cutoff{start="0m"} 0+240x10
testcounter_zero_cutoff{start="1m"} 60+240x10
testcounter_zero_cutoff{start="2m"} 120+240x10
testcounter_zero_cutoff{start="3m"} 180+240x10
testcounter_zero_cutoff{start="4m"} 240+240x10
testcounter_zero_cutoff{start="5m"} 300+240x10
# Zero cutoff for left-side extrapolation.
eval instant at 10m rate(testcounter_zero_cutoff[20m])
{start="0m"} 0.5
{start="1m"} 0.55
{start="2m"} 0.6
{start="3m"} 0.65
{start="4m"} 0.7
{start="5m"} 0.6
# Normal half-interval cutoff for left-side extrapolation.
eval instant at 50m rate(testcounter_zero_cutoff[20m])
{start="0m"} 0.6
{start="1m"} 0.6
{start="2m"} 0.6
{start="3m"} 0.6
{start="4m"} 0.6
{start="5m"} 0.6
clear
# Tests for irate().
load 5m
http_requests{path="/foo"} 0+10x10
@ -578,6 +636,9 @@ eval instant at 0m year()
eval instant at 1ms time()
0.001
eval instant at 50m time()
3000
eval instant at 0m year(vector(1136239445))
{} 2006
@ -671,6 +732,54 @@ eval instant at 1m max_over_time(data[1m])
clear
# Test for absent()
eval instant at 50m absent(nonexistent)
{} 1
eval instant at 50m absent(nonexistent{job="testjob", instance="testinstance", method=~".x"})
{instance="testinstance", job="testjob"} 1
eval instant at 50m absent(nonexistent{job="testjob",job="testjob2",foo="bar"})
{foo="bar"} 1
eval instant at 50m absent(nonexistent{job="testjob",job="testjob2",job="three",foo="bar"})
{foo="bar"} 1
eval instant at 50m absent(nonexistent{job="testjob",job=~"testjob2",foo="bar"})
{foo="bar"} 1
clear
# Don't return anything when there's something there.
load 5m
http_requests{job="api-server", instance="0", group="production"} 0+10x10
eval instant at 50m absent(http_requests)
eval instant at 50m absent(sum(http_requests))
clear
eval instant at 50m absent(sum(nonexistent{job="testjob", instance="testinstance"}))
{} 1
eval instant at 50m absent(max(nonexistant))
{} 1
eval instant at 50m absent(nonexistant > 1)
{} 1
eval instant at 50m absent(a + b)
{} 1
eval instant at 50m absent(a and b)
{} 1
eval instant at 50m absent(rate(nonexistant[5m]))
{} 1
clear
# Testdata for absent_over_time()
eval instant at 1m absent_over_time(http_requests[5m])
{} 1
@ -734,3 +843,68 @@ eval instant at 5m absent_over_time({job="ingress"}[4m])
eval instant at 10m absent_over_time({job="ingress"}[4m])
{job="ingress"} 1
clear
# Testing exp() sqrt() log2() log10() ln()
load 5m
exp_root_log{l="x"} 10
exp_root_log{l="y"} 20
eval instant at 5m exp(exp_root_log)
{l="x"} 22026.465794806718
{l="y"} 485165195.4097903
eval instant at 5m exp(exp_root_log - 10)
{l="y"} 22026.465794806718
{l="x"} 1
eval instant at 5m exp(exp_root_log - 20)
{l="x"} 4.5399929762484854e-05
{l="y"} 1
eval instant at 5m ln(exp_root_log)
{l="x"} 2.302585092994046
{l="y"} 2.995732273553991
eval instant at 5m ln(exp_root_log - 10)
{l="y"} 2.302585092994046
{l="x"} -Inf
eval instant at 5m ln(exp_root_log - 20)
{l="y"} -Inf
{l="x"} NaN
eval instant at 5m exp(ln(exp_root_log))
{l="y"} 20
{l="x"} 10
eval instant at 5m sqrt(exp_root_log)
{l="x"} 3.1622776601683795
{l="y"} 4.47213595499958
eval instant at 5m log2(exp_root_log)
{l="x"} 3.3219280948873626
{l="y"} 4.321928094887363
eval instant at 5m log2(exp_root_log - 10)
{l="y"} 3.3219280948873626
{l="x"} -Inf
eval instant at 5m log2(exp_root_log - 20)
{l="x"} NaN
{l="y"} -Inf
eval instant at 5m log10(exp_root_log)
{l="x"} 1
{l="y"} 1.301029995663981
eval instant at 5m log10(exp_root_log - 10)
{l="y"} 1
{l="x"} -Inf
eval instant at 5m log10(exp_root_log - 20)
{l="x"} NaN
{l="y"} -Inf
clear

View file

@ -1,391 +0,0 @@
load 5m
http_requests{job="api-server", instance="0", group="production"} 0+10x10
http_requests{job="api-server", instance="1", group="production"} 0+20x10
http_requests{job="api-server", instance="0", group="canary"} 0+30x10
http_requests{job="api-server", instance="1", group="canary"} 0+40x10
http_requests{job="app-server", instance="0", group="production"} 0+50x10
http_requests{job="app-server", instance="1", group="production"} 0+60x10
http_requests{job="app-server", instance="0", group="canary"} 0+70x10
http_requests{job="app-server", instance="1", group="canary"} 0+80x10
load 5m
x{y="testvalue"} 0+10x10
load 5m
testcounter_reset_middle 0+10x4 0+10x5
testcounter_reset_end 0+10x9 0 10
load 4m
testcounter_zero_cutoff{start="0m"} 0+240x10
testcounter_zero_cutoff{start="1m"} 60+240x10
testcounter_zero_cutoff{start="2m"} 120+240x10
testcounter_zero_cutoff{start="3m"} 180+240x10
testcounter_zero_cutoff{start="4m"} 240+240x10
testcounter_zero_cutoff{start="5m"} 300+240x10
load 5m
label_grouping_test{a="aa", b="bb"} 0+10x10
label_grouping_test{a="a", b="abb"} 0+20x10
load 5m
vector_matching_a{l="x"} 0+1x100
vector_matching_a{l="y"} 0+2x50
vector_matching_b{l="x"} 0+4x25
load 5m
cpu_count{instance="0", type="numa"} 0+30x10
cpu_count{instance="0", type="smp"} 0+10x20
cpu_count{instance="1", type="smp"} 0+20x10
eval instant at 50m SUM(http_requests)
{} 3600
eval instant at 50m SUM(http_requests{instance="0"}) BY(job)
{job="api-server"} 400
{job="app-server"} 1200
eval instant at 50m SUM(http_requests) BY (job)
{job="api-server"} 1000
{job="app-server"} 2600
# Non-existent labels mentioned in BY-clauses shouldn't propagate to output.
eval instant at 50m SUM(http_requests) BY (job, nonexistent)
{job="api-server"} 1000
{job="app-server"} 2600
eval instant at 50m COUNT(http_requests) BY (job)
{job="api-server"} 4
{job="app-server"} 4
eval instant at 50m SUM(http_requests) BY (job, group)
{group="canary", job="api-server"} 700
{group="canary", job="app-server"} 1500
{group="production", job="api-server"} 300
{group="production", job="app-server"} 1100
eval instant at 50m AVG(http_requests) BY (job)
{job="api-server"} 250
{job="app-server"} 650
eval instant at 50m MIN(http_requests) BY (job)
{job="api-server"} 100
{job="app-server"} 500
eval instant at 50m MAX(http_requests) BY (job)
{job="api-server"} 400
{job="app-server"} 800
# Single-letter label names and values.
eval instant at 50m x{y="testvalue"}
x{y="testvalue"} 100
# Rates should calculate per-second rates.
eval instant at 50m rate(http_requests{group="canary", instance="1", job="app-server"}[50m])
{group="canary", instance="1", job="app-server"} 0.26666666666666666
# Counter resets at in the middle of range are handled correctly by rate().
eval instant at 50m rate(testcounter_reset_middle[50m])
{} 0.03
# Counter resets at end of range are ignored by rate().
eval instant at 50m rate(testcounter_reset_end[5m])
{} 0
# Zero cutoff for left-side extrapolation.
eval instant at 10m rate(testcounter_zero_cutoff[20m])
{start="0m"} 0.5
{start="1m"} 0.55
{start="2m"} 0.6
{start="3m"} 0.65
{start="4m"} 0.7
{start="5m"} 0.6
# Normal half-interval cutoff for left-side extrapolation.
eval instant at 50m rate(testcounter_zero_cutoff[20m])
{start="0m"} 0.6
{start="1m"} 0.6
{start="2m"} 0.6
{start="3m"} 0.6
{start="4m"} 0.6
{start="5m"} 0.6
eval instant at 50m http_requests{group!="canary"}
http_requests{group="production", instance="1", job="app-server"} 600
http_requests{group="production", instance="0", job="app-server"} 500
http_requests{group="production", instance="1", job="api-server"} 200
http_requests{group="production", instance="0", job="api-server"} 100
eval instant at 50m http_requests{job=~".+-server",group!="canary"}
http_requests{group="production", instance="1", job="app-server"} 600
http_requests{group="production", instance="0", job="app-server"} 500
http_requests{group="production", instance="1", job="api-server"} 200
http_requests{group="production", instance="0", job="api-server"} 100
eval instant at 50m http_requests{job!~"api-.+",group!="canary"}
http_requests{group="production", instance="1", job="app-server"} 600
http_requests{group="production", instance="0", job="app-server"} 500
eval instant at 50m http_requests{group="production",job=~"api-.+"}
http_requests{group="production", instance="0", job="api-server"} 100
http_requests{group="production", instance="1", job="api-server"} 200
eval instant at 50m abs(-1 * http_requests{group="production",job="api-server"})
{group="production", instance="0", job="api-server"} 100
{group="production", instance="1", job="api-server"} 200
eval instant at 50m floor(0.004 * http_requests{group="production",job="api-server"})
{group="production", instance="0", job="api-server"} 0
{group="production", instance="1", job="api-server"} 0
eval instant at 50m ceil(0.004 * http_requests{group="production",job="api-server"})
{group="production", instance="0", job="api-server"} 1
{group="production", instance="1", job="api-server"} 1
eval instant at 50m round(0.004 * http_requests{group="production",job="api-server"})
{group="production", instance="0", job="api-server"} 0
{group="production", instance="1", job="api-server"} 1
# Round should correctly handle negative numbers.
eval instant at 50m round(-1 * (0.004 * http_requests{group="production",job="api-server"}))
{group="production", instance="0", job="api-server"} 0
{group="production", instance="1", job="api-server"} -1
# Round should round half up.
eval instant at 50m round(0.005 * http_requests{group="production",job="api-server"})
{group="production", instance="0", job="api-server"} 1
{group="production", instance="1", job="api-server"} 1
eval instant at 50m round(-1 * (0.005 * http_requests{group="production",job="api-server"}))
{group="production", instance="0", job="api-server"} 0
{group="production", instance="1", job="api-server"} -1
eval instant at 50m round(1 + 0.005 * http_requests{group="production",job="api-server"})
{group="production", instance="0", job="api-server"} 2
{group="production", instance="1", job="api-server"} 2
eval instant at 50m round(-1 * (1 + 0.005 * http_requests{group="production",job="api-server"}))
{group="production", instance="0", job="api-server"} -1
{group="production", instance="1", job="api-server"} -2
# Round should accept the number to round nearest to.
eval instant at 50m round(0.0005 * http_requests{group="production",job="api-server"}, 0.1)
{group="production", instance="0", job="api-server"} 0.1
{group="production", instance="1", job="api-server"} 0.1
eval instant at 50m round(2.1 + 0.0005 * http_requests{group="production",job="api-server"}, 0.1)
{group="production", instance="0", job="api-server"} 2.2
{group="production", instance="1", job="api-server"} 2.2
eval instant at 50m round(5.2 + 0.0005 * http_requests{group="production",job="api-server"}, 0.1)
{group="production", instance="0", job="api-server"} 5.3
{group="production", instance="1", job="api-server"} 5.3
# Round should work correctly with negative numbers and multiple decimal places.
eval instant at 50m round(-1 * (5.2 + 0.0005 * http_requests{group="production",job="api-server"}), 0.1)
{group="production", instance="0", job="api-server"} -5.2
{group="production", instance="1", job="api-server"} -5.3
# Round should work correctly with big toNearests.
eval instant at 50m round(0.025 * http_requests{group="production",job="api-server"}, 5)
{group="production", instance="0", job="api-server"} 5
{group="production", instance="1", job="api-server"} 5
eval instant at 50m round(0.045 * http_requests{group="production",job="api-server"}, 5)
{group="production", instance="0", job="api-server"} 5
{group="production", instance="1", job="api-server"} 10
eval instant at 50m avg_over_time(http_requests{group="production",job="api-server"}[1h])
{group="production", instance="0", job="api-server"} 50
{group="production", instance="1", job="api-server"} 100
eval instant at 50m count_over_time(http_requests{group="production",job="api-server"}[1h])
{group="production", instance="0", job="api-server"} 11
{group="production", instance="1", job="api-server"} 11
eval instant at 50m max_over_time(http_requests{group="production",job="api-server"}[1h])
{group="production", instance="0", job="api-server"} 100
{group="production", instance="1", job="api-server"} 200
eval instant at 50m min_over_time(http_requests{group="production",job="api-server"}[1h])
{group="production", instance="0", job="api-server"} 0
{group="production", instance="1", job="api-server"} 0
eval instant at 50m sum_over_time(http_requests{group="production",job="api-server"}[1h])
{group="production", instance="0", job="api-server"} 550
{group="production", instance="1", job="api-server"} 1100
eval instant at 50m time()
3000
eval instant at 50m {__name__=~".+"}
http_requests{group="canary", instance="0", job="api-server"} 300
http_requests{group="canary", instance="0", job="app-server"} 700
http_requests{group="canary", instance="1", job="api-server"} 400
http_requests{group="canary", instance="1", job="app-server"} 800
http_requests{group="production", instance="0", job="api-server"} 100
http_requests{group="production", instance="0", job="app-server"} 500
http_requests{group="production", instance="1", job="api-server"} 200
http_requests{group="production", instance="1", job="app-server"} 600
testcounter_reset_end 0
testcounter_reset_middle 50
x{y="testvalue"} 100
label_grouping_test{a="a", b="abb"} 200
label_grouping_test{a="aa", b="bb"} 100
vector_matching_a{l="x"} 10
vector_matching_a{l="y"} 20
vector_matching_b{l="x"} 40
cpu_count{instance="1", type="smp"} 200
cpu_count{instance="0", type="smp"} 100
cpu_count{instance="0", type="numa"} 300
eval instant at 50m {job=~".+-server", job!~"api-.+"}
http_requests{group="canary", instance="0", job="app-server"} 700
http_requests{group="canary", instance="1", job="app-server"} 800
http_requests{group="production", instance="0", job="app-server"} 500
http_requests{group="production", instance="1", job="app-server"} 600
eval instant at 50m absent(nonexistent)
{} 1
eval instant at 50m absent(nonexistent{job="testjob", instance="testinstance", method=~".x"})
{instance="testinstance", job="testjob"} 1
eval instant at 50m absent(nonexistent{job="testjob",job="testjob2",foo="bar"})
{foo="bar"} 1
eval instant at 50m absent(nonexistent{job="testjob",job="testjob2",job="three",foo="bar"})
{foo="bar"} 1
eval instant at 50m absent(nonexistent{job="testjob",job=~"testjob2",foo="bar"})
{foo="bar"} 1
eval instant at 50m absent(http_requests)
eval instant at 50m absent(sum(http_requests))
eval instant at 50m absent(sum(nonexistent{job="testjob", instance="testinstance"}))
{} 1
eval instant at 50m absent(max(nonexistant))
{} 1
eval instant at 50m absent(nonexistant > 1)
{} 1
eval instant at 50m absent(a + b)
{} 1
eval instant at 50m absent(a and b)
{} 1
eval instant at 50m absent(rate(nonexistant[5m]))
{} 1
eval instant at 50m http_requests{group="production",job="api-server"} offset 5m
http_requests{group="production", instance="0", job="api-server"} 90
http_requests{group="production", instance="1", job="api-server"} 180
eval instant at 50m rate(http_requests{group="production",job="api-server"}[10m] offset 5m)
{group="production", instance="0", job="api-server"} 0.03333333333333333
{group="production", instance="1", job="api-server"} 0.06666666666666667
eval instant at 50m http_requests{group="canary", instance="0", job="api-server"} / 0
{group="canary", instance="0", job="api-server"} +Inf
eval instant at 50m -1 * http_requests{group="canary", instance="0", job="api-server"} / 0
{group="canary", instance="0", job="api-server"} -Inf
eval instant at 50m 0 * http_requests{group="canary", instance="0", job="api-server"} / 0
{group="canary", instance="0", job="api-server"} NaN
eval instant at 50m 0 * http_requests{group="canary", instance="0", job="api-server"} % 0
{group="canary", instance="0", job="api-server"} NaN
eval instant at 50m exp(vector_matching_a)
{l="x"} 22026.465794806718
{l="y"} 485165195.4097903
eval instant at 50m exp(vector_matching_a - 10)
{l="y"} 22026.465794806718
{l="x"} 1
eval instant at 50m exp(vector_matching_a - 20)
{l="x"} 4.5399929762484854e-05
{l="y"} 1
eval instant at 50m ln(vector_matching_a)
{l="x"} 2.302585092994046
{l="y"} 2.995732273553991
eval instant at 50m ln(vector_matching_a - 10)
{l="y"} 2.302585092994046
{l="x"} -Inf
eval instant at 50m ln(vector_matching_a - 20)
{l="y"} -Inf
{l="x"} NaN
eval instant at 50m exp(ln(vector_matching_a))
{l="y"} 20
{l="x"} 10
eval instant at 50m sqrt(vector_matching_a)
{l="x"} 3.1622776601683795
{l="y"} 4.47213595499958
eval instant at 50m log2(vector_matching_a)
{l="x"} 3.3219280948873626
{l="y"} 4.321928094887363
eval instant at 50m log2(vector_matching_a - 10)
{l="y"} 3.3219280948873626
{l="x"} -Inf
eval instant at 50m log2(vector_matching_a - 20)
{l="x"} NaN
{l="y"} -Inf
eval instant at 50m log10(vector_matching_a)
{l="x"} 1
{l="y"} 1.301029995663981
eval instant at 50m log10(vector_matching_a - 10)
{l="y"} 1
{l="x"} -Inf
eval instant at 50m log10(vector_matching_a - 20)
{l="x"} NaN
{l="y"} -Inf
# Matrix tests.
clear
load 1h
testmetric{aa="bb"} 1
testmetric{a="abb"} 2
eval instant at 0h testmetric
testmetric{aa="bb"} 1
testmetric{a="abb"} 2
clear
# Test duplicate labelset in promql output.
load 5m
testmetric1{src="a",dst="b"} 0
testmetric2{src="a",dst="b"} 1
eval_fail instant at 0m ceil({__name__=~'testmetric1|testmetric2'})

View file

@ -39,7 +39,7 @@ eval instant at 50m -2^---1*3
-1.5
eval instant at 50m 2/-2^---1*3+2
-10
-10
eval instant at 50m -10^3 * - SUM(http_requests) BY (job) ^ -1
{job="api-server"} 1
@ -89,6 +89,18 @@ eval instant at 50m SUM(http_requests) BY (job) / 0
{job="api-server"} +Inf
{job="app-server"} +Inf
eval instant at 50m http_requests{group="canary", instance="0", job="api-server"} / 0
{group="canary", instance="0", job="api-server"} +Inf
eval instant at 50m -1 * http_requests{group="canary", instance="0", job="api-server"} / 0
{group="canary", instance="0", job="api-server"} -Inf
eval instant at 50m 0 * http_requests{group="canary", instance="0", job="api-server"} / 0
{group="canary", instance="0", job="api-server"} NaN
eval instant at 50m 0 * http_requests{group="canary", instance="0", job="api-server"} % 0
{group="canary", instance="0", job="api-server"} NaN
eval instant at 50m SUM(http_requests) BY (job) + SUM(http_requests) BY (job)
{job="api-server"} 2000
{job="app-server"} 5200

View file

@ -111,3 +111,91 @@ load 1m
eval instant at 90m metric1 offset 15m or metric2 offset 45m
metric1{a="a"} 75
metric2{b="b"} 45
clear
load 5m
x{y="testvalue"} 0+10x10
load 5m
cpu_count{instance="0", type="numa"} 0+30x10
cpu_count{instance="0", type="smp"} 0+10x20
cpu_count{instance="1", type="smp"} 0+20x10
load 5m
label_grouping_test{a="aa", b="bb"} 0+10x10
label_grouping_test{a="a", b="abb"} 0+20x10
load 5m
http_requests{job="api-server", instance="0", group="production"} 0+10x10
http_requests{job="api-server", instance="1", group="production"} 0+20x10
http_requests{job="api-server", instance="0", group="canary"} 0+30x10
http_requests{job="api-server", instance="1", group="canary"} 0+40x10
http_requests{job="app-server", instance="0", group="production"} 0+50x10
http_requests{job="app-server", instance="1", group="production"} 0+60x10
http_requests{job="app-server", instance="0", group="canary"} 0+70x10
http_requests{job="app-server", instance="1", group="canary"} 0+80x10
# Single-letter label names and values.
eval instant at 50m x{y="testvalue"}
x{y="testvalue"} 100
# Basic Regex
eval instant at 50m {__name__=~".+"}
http_requests{group="canary", instance="0", job="api-server"} 300
http_requests{group="canary", instance="0", job="app-server"} 700
http_requests{group="canary", instance="1", job="api-server"} 400
http_requests{group="canary", instance="1", job="app-server"} 800
http_requests{group="production", instance="0", job="api-server"} 100
http_requests{group="production", instance="0", job="app-server"} 500
http_requests{group="production", instance="1", job="api-server"} 200
http_requests{group="production", instance="1", job="app-server"} 600
x{y="testvalue"} 100
label_grouping_test{a="a", b="abb"} 200
label_grouping_test{a="aa", b="bb"} 100
cpu_count{instance="1", type="smp"} 200
cpu_count{instance="0", type="smp"} 100
cpu_count{instance="0", type="numa"} 300
eval instant at 50m {job=~".+-server", job!~"api-.+"}
http_requests{group="canary", instance="0", job="app-server"} 700
http_requests{group="canary", instance="1", job="app-server"} 800
http_requests{group="production", instance="0", job="app-server"} 500
http_requests{group="production", instance="1", job="app-server"} 600
eval instant at 50m http_requests{group!="canary"}
http_requests{group="production", instance="1", job="app-server"} 600
http_requests{group="production", instance="0", job="app-server"} 500
http_requests{group="production", instance="1", job="api-server"} 200
http_requests{group="production", instance="0", job="api-server"} 100
eval instant at 50m http_requests{job=~".+-server",group!="canary"}
http_requests{group="production", instance="1", job="app-server"} 600
http_requests{group="production", instance="0", job="app-server"} 500
http_requests{group="production", instance="1", job="api-server"} 200
http_requests{group="production", instance="0", job="api-server"} 100
eval instant at 50m http_requests{job!~"api-.+",group!="canary"}
http_requests{group="production", instance="1", job="app-server"} 600
http_requests{group="production", instance="0", job="app-server"} 500
eval instant at 50m http_requests{group="production",job=~"api-.+"}
http_requests{group="production", instance="0", job="api-server"} 100
http_requests{group="production", instance="1", job="api-server"} 200
eval instant at 50m http_requests{group="production",job="api-server"} offset 5m
http_requests{group="production", instance="0", job="api-server"} 90
http_requests{group="production", instance="1", job="api-server"} 180
clear
# Matrix tests.
load 1h
testmetric{aa="bb"} 1
testmetric{a="abb"} 2
eval instant at 0h testmetric
testmetric{aa="bb"} 1
testmetric{a="abb"} 2
clear