Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJurijs Klopovskis <jurijs.klopovskis@zabbix.com>2021-12-15 11:02:59 +0300
committerJurijs Klopovskis <jurijs.klopovskis@zabbix.com>2021-12-15 11:02:59 +0300
commitee4f5af9d62e84cf374452aa0e4afb4d4cdb3551 (patch)
tree492dd2aab13245631bb603e2d81560eaf8758424 /tests
parent9b5c0f361ca1e660bd4fbfe6108921319155baac (diff)
parent494b200d053820d0fc211c9207f9c90194913315 (diff)
.......... [ZBXNEXT-4922] merged latest changes from master
conflicts: tests/libs/zbxprometheus/zbx_prometheus_pattern.yaml
Diffstat (limited to 'tests')
-rw-r--r--tests/libs/zbxeval/zbx_eval_execute.yaml11
-rw-r--r--tests/libs/zbxprometheus/Makefile.am1
-rw-r--r--tests/libs/zbxprometheus/prometheus_filter_init.c4
-rw-r--r--tests/libs/zbxprometheus/prometheus_filter_init.yaml2
-rw-r--r--tests/libs/zbxprometheus/zbx_prometheus_pattern.c11
-rw-r--r--tests/libs/zbxprometheus/zbx_prometheus_pattern.yaml520
-rw-r--r--tests/zabbix_server/preprocessor/Makefile.am1
-rw-r--r--tests/zabbix_server/preprocessor/zbx_item_preproc.c6
-rw-r--r--tests/zabbix_server/preprocessor/zbx_item_preproc.yaml17
-rw-r--r--tests/zabbix_server/trapper/Makefile.am5
-rw-r--r--tests/zabbix_server/trapper/zbx_trapper_preproc_test_run.c11
11 files changed, 421 insertions, 168 deletions
diff --git a/tests/libs/zbxeval/zbx_eval_execute.yaml b/tests/libs/zbxeval/zbx_eval_execute.yaml
index d24a1779ef3..c1227f846aa 100644
--- a/tests/libs/zbxeval/zbx_eval_execute.yaml
+++ b/tests/libs/zbxeval/zbx_eval_execute.yaml
@@ -2206,7 +2206,16 @@ in:
rules: [ZBX_EVAL_PARSE_FUNCTION,ZBX_EVAL_PARSE_VAR]
expression: 'histogram_quantile(0.8, 0.1, 1, 0.2, 2, "+Inf", 0)'
out:
- result: FAIL
+ result: SUCCEED
+ value: '0.16000000000000003'
+---
+test case: Expression 'histogram_quantile(0.8, 0.1, 0, 0.2, 0, +Inf, 0)'
+in:
+ rules: [ZBX_EVAL_PARSE_FUNCTION,ZBX_EVAL_PARSE_VAR]
+ expression: 'histogram_quantile(0.8, 0.1, 0, 0.2, 0, "+Inf", 0)'
+out:
+ result: SUCCEED
+ value: '-1'
---
test case: Expression 'histogram_quantile(-0.1, 0.2, 10, 0.4, 20, 1.0, 60, 1.2, 70, +Inf, 80)'
in:
diff --git a/tests/libs/zbxprometheus/Makefile.am b/tests/libs/zbxprometheus/Makefile.am
index 5f20a24e458..df7ab2b2fef 100644
--- a/tests/libs/zbxprometheus/Makefile.am
+++ b/tests/libs/zbxprometheus/Makefile.am
@@ -7,6 +7,7 @@ PROMETHEUS_LIBS = \
$(top_srcdir)/tests/libzbxmocktest.a \
$(top_srcdir)/tests/libzbxmockdata.a \
$(top_srcdir)/src/libs/zbxprometheus/libzbxprometheus.a \
+ $(top_srcdir)/src/libs/zbxeval/libzbxeval.a \
$(top_srcdir)/src/libs/zbxalgo/libzbxalgo.a \
$(top_srcdir)/src/libs/zbxjson/libzbxjson.a \
$(top_srcdir)/src/libs/zbxregexp/libzbxregexp.a \
diff --git a/tests/libs/zbxprometheus/prometheus_filter_init.c b/tests/libs/zbxprometheus/prometheus_filter_init.c
index b13aad1cbec..3e81057167f 100644
--- a/tests/libs/zbxprometheus/prometheus_filter_init.c
+++ b/tests/libs/zbxprometheus/prometheus_filter_init.c
@@ -87,7 +87,9 @@ void zbx_mock_test_entry(void **state)
filter = zbx_mock_get_parameter_string("in.filter");
- ret = zbx_prometheus_filter_parse(filter, &metric, &labels, &value, &error);
+ if (SUCCEED != (ret = zbx_prometheus_filter_parse(filter, &metric, &labels, &value, &error)))
+ printf("filter parsing error: %s\n", error);
+
expected_ret = zbx_mock_str_to_return_code(zbx_mock_get_parameter_string("out.return"));
zbx_mock_assert_result_eq("prometheus filter parsing", expected_ret, ret);
diff --git a/tests/libs/zbxprometheus/prometheus_filter_init.yaml b/tests/libs/zbxprometheus/prometheus_filter_init.yaml
index eae93b0715f..28f3aef01a6 100644
--- a/tests/libs/zbxprometheus/prometheus_filter_init.yaml
+++ b/tests/libs/zbxprometheus/prometheus_filter_init.yaml
@@ -403,5 +403,3 @@ out:
pattern: inf
op: ==
...
-
-
diff --git a/tests/libs/zbxprometheus/zbx_prometheus_pattern.c b/tests/libs/zbxprometheus/zbx_prometheus_pattern.c
index 1bec96b4b87..cb1b6d305ce 100644
--- a/tests/libs/zbxprometheus/zbx_prometheus_pattern.c
+++ b/tests/libs/zbxprometheus/zbx_prometheus_pattern.c
@@ -27,7 +27,7 @@
void zbx_mock_test_entry(void **state)
{
- const char *data, *params, *value_type;
+ const char *data, *params, *output, *request;
char *ret_err = NULL, *ret_output = NULL;
int ret, expected_ret;
@@ -35,18 +35,17 @@ void zbx_mock_test_entry(void **state)
data = zbx_mock_get_parameter_string("in.data");
params = zbx_mock_get_parameter_string("in.params");
- value_type = zbx_mock_get_parameter_string("in.value_type");
+ output = zbx_mock_get_parameter_string("in.output");
+ request = zbx_mock_get_parameter_string("in.request");
- if (SUCCEED != (ret = zbx_prometheus_pattern(data, params, value_type, &ret_output, &ret_err)))
- zabbix_log(LOG_LEVEL_DEBUG, "Error: %s", ret_err);
+ if (SUCCEED != (ret = zbx_prometheus_pattern(data, params, request, output, &ret_output, &ret_err)))
+ printf("Error: %s\n", ret_err);
expected_ret = zbx_mock_str_to_return_code(zbx_mock_get_parameter_string("out.result"));
zbx_mock_assert_result_eq("Invalid zbx_prometheus_pattern() return value", expected_ret, ret);
if (SUCCEED == ret)
{
- const char *output;
-
output = zbx_mock_get_parameter_string("out.output");
zbx_mock_assert_str_eq("Invalid zbx_prometheus_pattern() returned output", output, ret_output);
zbx_free(ret_output);
diff --git a/tests/libs/zbxprometheus/zbx_prometheus_pattern.yaml b/tests/libs/zbxprometheus/zbx_prometheus_pattern.yaml
index 4110a6ce110..acea15f32b3 100644
--- a/tests/libs/zbxprometheus/zbx_prometheus_pattern.yaml
+++ b/tests/libs/zbxprometheus/zbx_prometheus_pattern.yaml
@@ -3,7 +3,8 @@ test case: 'Get metric value using params: "wmi_os_physical_memory_free_bytes"'
in:
data: wmi_os_physical_memory_free_bytes 8.492331008e+09
params: wmi_os_physical_memory_free_bytes
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 8.492331008e+09
@@ -17,7 +18,8 @@ in:
cpu_usage_system{cpu="cpu0"} 1.1940298507220641
cpu_usage_system{cpu="cpu1"} 1.1340298507220641
params: cpu_usage_system{cpu="cpu-total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -31,7 +33,8 @@ in:
wmi_logical_disk_free_bytes{volume="D:"} 2.627731456e+09
wmi_logical_disk_free_bytes{volume="HarddiskVolume4"} 4.59276288e+08
params: 'wmi_logical_disk_free_bytes{volume="{#VOLUME}"}'
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 3.5180249088e+11
@@ -45,7 +48,8 @@ in:
wmi_logical_disk_free_bytes{volume="{#VOLUME}"} 2.627731456e+09
wmi_logical_disk_free_bytes{volume="HarddiskVolume4"} 4.59276288e+08
params: 'wmi_logical_disk_free_bytes{volume="{#VOLUME}"}'
- value_type: volume
+ request: label
+ output: volume
out:
result: SUCCEED
output: '{#VOLUME}'
@@ -59,7 +63,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1"} 1.1940298507220641
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
params: cpu_usage_system{cpu="cpu-total",host=~".*"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -73,7 +78,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1"} 1.1940298507220641
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
params: cpu_usage_system{cpu="cpu-total",host=~".*"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -87,7 +93,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1"} 1.1940298507220641
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
params: cpu_usage_system{cpu="cpu-total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -101,7 +108,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1"} 1.1940298507220641
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
params: cpu_usage_system{cpu=~"cpu-tot.+"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -115,7 +123,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1"} 1.1940298507220641
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
params: '{__name__=~"cpu_usage_syst.+",cpu=~"cpu-tot.+"}'
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -129,7 +138,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1"} 1.1940298507220641
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
params: cpu_usage_system{cpu=~".*"}
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -142,7 +152,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1"} 1.1940298507220641
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
params: cpu_usage_system{cpu=~"cpu-tot.+"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -172,7 +183,8 @@ in:
wmi_service_state{name="diagnosticshub.standardcollector.service",state="stopped"} 1
wmi_service_state{name="diagnosticshub.standardcollector.service",state="unknown"} 0
params: wmi_service_state{name="dhcp"} == 1
- value_type: state
+ request: label
+ output: state
out:
result: SUCCEED
output: 'running'
@@ -184,7 +196,8 @@ in:
# TYPE wmi_os_timezone gauge
wmi_os_timezone{timezone="MSK"} 1
params: wmi_os_timezone{timezone=~".*"} == 1
- value_type: timezone
+ request: label
+ output: timezone
out:
result: SUCCEED
output: 'MSK'
@@ -197,7 +210,8 @@ in:
http_requests_total{method="post",code="200"} 1027 1395066363000
http_requests_total{method="post",code="400"} 3 1395066363000
params: http_requests_total{code="400"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 3
@@ -206,7 +220,8 @@ test case: 'Escaping in label values'
in:
data: msdos_file_access_time_seconds{path="C:\\DIR\\FILE.TXT",error="Cannot find file:\n\"FILE.TXT\""} 1.458255915e9
params: msdos_file_access_time_seconds{error="Cannot find file:\n\"FILE.TXT\""} == 1.458255915e9
- value_type: path
+ request: label
+ output: path
out:
result: SUCCEED
output: 'C:\DIR\FILE.TXT'
@@ -215,7 +230,8 @@ test case: 'Minimalistic line'
in:
data: metric_without_timestamp_and_labels 12.47
params: metric_without_timestamp_and_labels
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 12.47
@@ -224,7 +240,8 @@ test case: 'A weird metric from before the epoch'
in:
data: something_weird{problem="division by zero"} +Inf -3982045
params: something_weird
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: +Inf
@@ -243,7 +260,8 @@ in:
http_request_duration_seconds_sum 53423
http_request_duration_seconds_count 144320
params: http_request_duration_seconds_bucket{le="+Inf"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 144320
@@ -261,7 +279,8 @@ in:
rpc_duration_seconds_sum 1.7560473e+07
rpc_duration_seconds_count 2693
params: rpc_duration_seconds_sum
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.7560473e+07
@@ -270,7 +289,8 @@ test case: 'Invalid metric (expected "fail"): empty metric'
in:
data: ""
params: wmi_os_timezone
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -278,7 +298,8 @@ test case: 'Empty params'
in:
data: wmi_os_timezone{timezone="MSK"} 1
params: ""
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1
@@ -287,7 +308,8 @@ test case: 'Empty params but value_type is set'
in:
data: wmi_os_timezone{timezone="MSK"} 1
params: ""
- value_type: timezone
+ request: label
+ output: timezone
out:
result: SUCCEED
output: 'MSK'
@@ -300,7 +322,8 @@ in:
wmi_service_state{name="dhcp",state="stop pending"} 0
wmi_service_state{name="postdhcp",state="stopped"} 1
params: ""
- value_type: state
+ request: label
+ output: state
out:
result: FAIL
---
@@ -308,7 +331,8 @@ test case: 'Invalid metric (expected "fail"): empty metric and empty params'
in:
data: ""
params: ""
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -316,7 +340,8 @@ test case: 'Invalid metric (expected "fail"): metric consists of spaces only #1'
in:
data: ' '
params: wmi_os_timezone
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -324,7 +349,8 @@ test case: 'Params hold multiple spaces only'
in:
data: wmi_os_timezone{timezone="MSK"} 1
params: ' '
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1
@@ -340,7 +366,8 @@ in:
rpc_duration_seconds_sum 1.7560473e+07
rpc_duration_seconds_count 2693
params: ' '
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -348,7 +375,8 @@ test case: 'Invalid metric (expected "fail"): metric consists of spaces only #2'
in:
data: ' '
params: ' '
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -356,7 +384,8 @@ test case: 'Empty multiline metric'
in:
data: "\n\n\n\n"
params: wmi_os_timezone
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -364,7 +393,8 @@ test case: 'Empty value_type'
in:
data: wmi_os_physical_memory_free_bytes 8.492331008e+09
params: wmi_os_physical_memory_free_bytes
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 8.492331008e+09
@@ -373,7 +403,8 @@ test case: 'Invalid metric (expected "fail"): metric without value'
in:
data: wmi_os_physical_memory_free_bytes
params: wmi_os_physical_memory_free_bytes
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -384,7 +415,8 @@ in:
# TYPE wmi_os_timezone gauge
wmi_os_timezone{timezone=} 1
params: wmi_os_timezone
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -395,7 +427,8 @@ in:
# TYPE wmi_os_timezone gauge
wmi_os_timezone{timezone} 1
params: wmi_os_timezone
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -406,7 +439,8 @@ in:
# TYPE wmi_os_timezone gauge
wmi_os_timezone{timezone} 1
params: wmi_os_timezone == 1
- value_type: timezone
+ request: label
+ output: timezone
out:
result: FAIL
---
@@ -417,7 +451,8 @@ in:
# TYPE wmi_os_timezone gauge
wmi_os_timezone{timezone} 1
params: wmi_os_timezone{timezone=~".*"} == 1
- value_type: timezone
+ request: label
+ output: timezone
out:
result: FAIL
---
@@ -425,7 +460,8 @@ test case: 'Invalid metric (expected "fail"): wrong metric data'
in:
data: asdlkdlkasdasd09814mnvclmx
params: wmi_os_timezone
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -433,7 +469,8 @@ test case: 'Invalid metric (expected "fail"): wrong metric data (a space within)
in:
data: asdlkdlkasda sd09814mnvclmx
params: wmi_os_timezone
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -441,7 +478,8 @@ test case: 'Invalid metric (expected "fail"): metric name with unsupported chara
in:
data: wmi_os_physical_^&;memory_free_bytes 8.492331008e+09
params: wmi_os_physical_^&;memory_free_bytes
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -452,7 +490,8 @@ in:
# TYPE wmi_os_timezone gauge
asdlkdlkasdasd09814mnvclmx
params: wmi_os_timezone
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -460,7 +499,8 @@ test case: 'Invalid metric (expected "fail"): metric consists of hash symbol onl
in:
data: '#'
params: wmi_os_timezone
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -468,7 +508,8 @@ test case: 'Invalid metric (expected "fail"): metric consists of empty space onl
in:
data: ' '
params: wmi_os_timezone
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -476,7 +517,8 @@ test case: 'Invalid metric (expected "fail"): metric consists of 3 byte UTF-8 ch
in:
data: "ࠀ"
params: wmi_os_timezone
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -488,7 +530,8 @@ in:
http_requests_total{method="post",code="200"} 1027 1395066363000
http_requests_total{method="post",code="-⃠"} 3 1395066363000
params: http_requests_total == 3
- value_type: code
+ request: label
+ output: code
out:
result: SUCCEED
output: '-⃠'
@@ -497,7 +540,8 @@ test case: 'Invalid metric (expected "fail"): metric with missing "{"'
in:
data: cpu_usage_systemcpu="cpu-total"} 1.1940298507220641
params: cpu_usage_system{cpu="cpu-total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -505,7 +549,8 @@ test case: 'Invalid metric (expected "fail"): metric with missing "}"'
in:
data: cpu_usage_system{cpu="cpu-total" 1.1940298507220641
params: cpu_usage_system{cpu="cpu-total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -513,7 +558,8 @@ test case: 'Invalid metric (expected "fail"): metric with missing "'
in:
data: cpu_usage_system{cpu=cpu-total"} 1.1940298507220641
params: cpu_usage_system{cpu="cpu-total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -521,7 +567,8 @@ test case: 'Invalid metric (expected "fail"): metric with missing ","'
in:
data: cpu_usage_system{cpu="cpu-total"host="host1"} 1.1940298507220641
params: cpu_usage_system{cpu="cpu-total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -529,7 +576,8 @@ test case: 'Invalid metric (expected "fail"): metric with missing "," and params
in:
data: cpu_usage_system{cpu="cpu-total"host="host1"} 1.1940298507220641
params: ""
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -542,7 +590,8 @@ in:
cpu_usage_system{cpu=="cpu0"} 1.1940298507220641
cpu_usage_system{cpu="cpu1"} 1.1340298507220641
params: cpu_usage_system{cpu="cpu-total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -555,7 +604,8 @@ in:
cpu_usage_system{cpu="cpu0"} 1.1940298507220641
cpu_usage_system{cpu="cpu1"} 1.1340298507220641
params: cpu_usage_system{cpu="cpu-total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -563,7 +613,8 @@ test case: 'Invalid metric (expected "fail"): double equal sign (==) instead of
in:
data: cpu_usage_system{cpu=="cpu-total"} 1.1940298507220641
params: cpu_usage_system{cpu="cpu-total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -571,7 +622,8 @@ test case: 'Label value and params holds new line character'
in:
data: "cpu_usage_system{cpu=\"cpu\ntotal\"} 1.1940298507220641"
params: "cpu_usage_system{cpu=\"cpu\ntotal\"}"
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -580,7 +632,8 @@ test case: 'Invalid metric (expected "fail"): metric name holds new line charact
in:
data: "cpu_usa\nge_system{cpu=\"cputotal\"} 1.1940298507220641"
params: 'cpu_usage_system{cpu="cputotal"}'
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -588,7 +641,8 @@ test case: 'Invalid params (expected "fail"): params hold new line character'
in:
data: 'cpu_usage_system{cpu=\"cputotal\"} 1.1940298507220641'
params: "cpu_usa\nge_system{cpu=\"cputotal\"}"
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -596,7 +650,8 @@ test case: 'Invalid metric (expected "fail"): metric name and params hold new li
in:
data: "cpu_usa\nge_system{cpu=\"cputotal\"} 1.1940298507220641"
params: "cpu_usa\nge_system{cpu=\"cputotal\"}"
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -609,7 +664,8 @@ in:
cpu_usage_system{cpu="cpu0"} 1.1940298507220641
cpu_usage_system{cpu="cpu1"} 1.1340298507220641
params: cpu_usage_system{cpu=="cpu-total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -622,7 +678,8 @@ in:
cpu_usage_system{cpu="cpu0"} 1.1940298507220641
cpu_usage_system{cpu="cpu1"} 1.1340298507220641
params: cpu_usage_system{cpu="cpu-total"} = 1.1940298507220641
- value_type: cpu
+ request: label
+ output: cpu
out:
result: FAIL
---
@@ -635,7 +692,8 @@ in:
cpu_usage_system{cpu="cpu0"} 1.1940298507220641
cpu_usage_system{cpu="cpu1"} 1.1340298507220641
params: cpu_usage_system{cpu="cpu-total"} = 1.1940298507220641
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -664,7 +722,8 @@ in:
wmi_service_state{name="diagnosticshub.standardcollector.service",state="stopped"} 1
wmi_service_state{name="diagnosticshub.standardcollector.service",state="unknown"} 0
params: wmi_service_state{name="dhcp"} == 1
- value_type: state
+ request: label
+ output: state
out:
result: FAIL
---
@@ -680,7 +739,8 @@ in:
wmi_service_state{name="dhcp",state="stopped"} 1
wmi_service_state{name="dhcp",state="unknown"} 1
params: wmi_service_state{name="dhcp"} == 1
- value_type: state
+ request: label
+ output: state
out:
result: FAIL
---
@@ -704,7 +764,8 @@ in:
wmi_service_state{name="dhcp",state="stopped"} 1
wmi_service_state{name="dhcp",state="unknown"} 1
params: wmi_service_state{name="dhcp"} == 1
- value_type: state
+ request: label
+ output: state
out:
result: FAIL
---
@@ -730,7 +791,8 @@ in:
wmi_service_state{name="dhcp",state="unknown"} 1
wmi_service_state{name="dhcp",state="unknown"} 0
params: wmi_service_state == 1
- value_type: state
+ request: label
+ output: state
out:
result: FAIL
---
@@ -738,7 +800,8 @@ test case: 'Metric with "Nan" value'
in:
data: wmi_os_physical_memory_free_bytes Nan
params: wmi_os_physical_memory_free_bytes
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: Nan
@@ -747,7 +810,8 @@ test case: 'Metric with "+Inf" value'
in:
data: wmi_os_physical_memory_free_bytes +Inf
params: wmi_os_physical_memory_free_bytes
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: +Inf
@@ -756,7 +820,8 @@ test case: 'Metric with "-Inf" value'
in:
data: wmi_os_physical_memory_free_bytes -Inf
params: wmi_os_physical_memory_free_bytes
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: -Inf
@@ -765,7 +830,8 @@ test case: 'Invalid metric (expected "fail"): metric with "NAN" value'
in:
data: wmi_os_physical_memory_free_bytes NAN
params: wmi_os_physical_memory_free_bytes
- value_type: ""
+ request: value
+ output: ""
out:
output: NAN
result: SUCCEED
@@ -774,7 +840,8 @@ test case: 'Metric with timestamp'
in:
data: wmi_os_physical_memory_free_bytes 8.492331008e+09 25
params: wmi_os_physical_memory_free_bytes
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 8.492331008e+09
@@ -788,7 +855,8 @@ in:
cpu_usage_system{cpu="cpu0"} 1.1940298507220641
cpu_usage_system{cpu="cpu1"} 1.1340298507220641
params: cpu_usage_system{cpu="cpu-total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -797,7 +865,8 @@ test case: 'Metric with negative timestamp'
in:
data: http_requests_total{method="post",code="200"} 1027 -123
params: http_requests_total
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1027
@@ -806,7 +875,8 @@ test case: 'Metric with negative value'
in:
data: http_requests_total{method="post",code="200"} -1027
params: http_requests_total
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: -1027
@@ -820,7 +890,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1"} 1.1940298507220641
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
params: '{__name__=~"cpu_usage_syst.+",cpu=~"cpu-tot.+"}'
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: -654
@@ -834,7 +905,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1"} 1.1940298507220641
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
params: '{cpu="cpu-total",__name__="cpu_usage_system"}'
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -848,7 +920,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1"} 1.1940298507220641
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
params: '{cpu=~"cpu-tot.+",__name__=~"cpu_usage_syst.+"}'
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -862,7 +935,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1"} 1.1940298507220641
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
params: cpu_usage_system{cpu="cpu-total"}
- value_type: something
+ request: label
+ output: something
out:
result: FAIL
---
@@ -875,7 +949,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1"} 1.19402985
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
params: 'cpu_usage_system{__name__=~"cpu_usage_syst.+",cpu=~"cpu-tot.+"}'
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -888,7 +963,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1"} 1.19402985
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
params: 'cpu_usage_system{__name__=~"cpu_age_syst.+",cpu=~"cpu-tot.+"}'
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -899,7 +975,8 @@ in:
# TYPE wmi_logical_disk_free_bytes gauge
wmi_logical_disk_free_bytes{volume="C:"} 3.5180249088e+11
params: wmi_logical_disk_free_bytes
- value_type: \\&{},.13%},.
+ request: label
+ output: \\&{},.13%},.
out:
result: FAIL
---
@@ -913,7 +990,8 @@ in:
cpu_usage_system{cpu="cpu0"} 1.1940298507220641
cpu_usage_system{cpu="cpu1"} 1.1340298507220641
params: cpu_usage_system{cpu="cpu-total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -928,7 +1006,8 @@ in:
cpu_usage_system{cpu="cpu0"} 1.1940298507220641
cpu_usage_system{cpu="cpu1"} 1.1340298507220641
params: cpu_usage_system{cpu="cpu-total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -942,7 +1021,8 @@ in:
cpu_usage_system{cpu="cpu0"} 1.1940298507220641
cpu_usage_system{cpu="cpu1"} 1.1340298507220641
params: cpu_usage_system{cpu="cpu-total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -956,7 +1036,8 @@ in:
cpu_usage_system{cpu="cpu0"} 1.1940298507220641
cpu_usage_system{cpu="cpu1"} 1.1340298507220641
params: cpu_usage_system{cpu="cpu-total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -970,7 +1051,8 @@ in:
cpu_usage_system{cpu="cpu0"} 1.1940298507220641
cpu_usage_system{cpu="cpu1"} 1.1340298507220641
params: cpu_usage_system{cpu="cpu-total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -979,7 +1061,8 @@ test case: 'Multiple spaces before metric value'
in:
data: wmi_os_physical_memory_free_bytes 8.492331008e+09
params: wmi_os_physical_memory_free_bytes
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 8.492331008e+09
@@ -992,7 +1075,8 @@ in:
cpu_usage_system{cpu="cpu0"} 1.1940298507220641
cpu_usage_system{cpu="cpu1"} 1.1340298507220641
params: cpu_usage_system{cpu="cpu-total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -1001,7 +1085,8 @@ test case: 'Invalid metric (expected "fail"): unsupported characters in label na
in:
data: cpu_usage_system{cp%^&u="cpu-total"} 1.1940298507220641
params: cpu_usage_system{cp%^&u="cpu-total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -1012,7 +1097,8 @@ in:
# TYPE wmi_os_timezone gauge
wmi_os_timezone{timezone="MSK"} 1
params: wmi_os_timezone
- value_type: timezone
+ request: label
+ output: timezone
out:
result: SUCCEED
output: 'MSK'
@@ -1021,7 +1107,8 @@ test case: 'Metric name consists of all supported characters'
in:
data: AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz:_0123456789 1
params: AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz:_0123456789
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1
@@ -1030,7 +1117,8 @@ test case: 'Label name consists of all supported characters'
in:
data: cpu_usage_system{AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz_0123456789="test"} 1
params: cpu_usage_system == 1
- value_type: AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz_0123456789
+ request: label
+ output: AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz_0123456789
out:
result: SUCCEED
output: 'test'
@@ -1044,7 +1132,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1"} 1.1940298507220641
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
params: cpu_usage_system{cpu="cpu-total",host=".*"}
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -1057,7 +1146,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1"} 1.1940298507220641
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
params: cpu_usage_system{cpu="cpu-total",host=~"[0-9"}
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -1070,7 +1160,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1"} 1.1940298507220641
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
params: '{__name__="cpu_usage_system",__cpu__="cpu-total"}'
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -1083,7 +1174,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1"} 1.1940298507220641
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
params: '{__name__=~"cpu_usage_syst.+",__cpu__=~"cpu-tot.+"}'
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -1091,7 +1183,8 @@ test case: 'Invalid metric (expected "fail"): incorrect float'
in:
data: wmi_logical_disk_free_bytes{volume="D:"} 8.49233.1008e+09
params: wmi_logical_disk_free_bytes
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -1104,7 +1197,8 @@ in:
cpu_usage_system{cpu="cpu0"} 1.1940298507220641
cpu_usage_system{cpu="cpu1"} 1.1340298507220641
params: '{}'
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -1117,7 +1211,8 @@ in:
a{cpu="cpu0"} 1.1940298507220641
a{cpu="cpu1"} 1.1340298507220641
params: a{}
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -1125,7 +1220,8 @@ test case: 'Invalid metric (expected "fail"): "{}"'
in:
data: '{}'
params: metric
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -1136,7 +1232,8 @@ in:
# TYPE wmi_os_timezone gauge
wmi_os_timezone{timezone="MSK"} -1
params: wmi_os_timezone{timezone="MSK"} == -1
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: -1
@@ -1147,7 +1244,8 @@ in:
random_date{year="2019",month="february",day="02/12/2019"} 1
random_date{year="2019",month="march",day="03/07/2019"} 2
params: random_date{year="2019",day=~"^([0-2][0-9]|(3)[0-1])(\\/)(((0)[0-9])|((1)[0-2]))(\\/)\\d{4}$"} == 1
- value_type: month
+ request: label
+ output: month
out:
result: SUCCEED
output: 'february'
@@ -1158,7 +1256,8 @@ in:
random_date{year="2019",month="february",day="02/12/2019"} 1
random_date{year="2019",month="march",day="03/07/2019"} 2
params: random_date{year="2019",day=~"^([0-2][0-9]|(3)[0-1])(\\/)(((0)[0-9])|((1)[0-2]))(\\/)\\d{4}$"} == 2
- value_type: month
+ request: label
+ output: month
out:
result: SUCCEED
output: 'march'
@@ -1169,7 +1268,8 @@ in:
random_date{year="2019",month="february",day="02/12/2019"} 1
random_date{year="2019",month="march",day="03/07/2019"} 2
params: random_date{year="2019",day=~"^([0-2][0-9]|(3)[0-1])(\\/)(((0)[0-9])|((1)[0-2]))(\\/)\\d{4}$"} == 2
- value_type: day
+ request: label
+ output: day
out:
result: SUCCEED
output: '03/07/2019'
@@ -1180,7 +1280,8 @@ in:
random_date{year="2019",month="february",day="02/12/2019"} 1
random_date{year="2019",month="march",day="03-07-2019"} 2
params: random_date{year="2019",day=~"^([0-2][0-9]|(3)[0-1])(\\/)(((0)[0-9])|((1)[0-2]))(\\/)\\d{4}$"} == 2
- value_type: day
+ request: label
+ output: day
out:
result: FAIL
---
@@ -1190,7 +1291,8 @@ in:
random_date{year="2019",month="february",day="02/12/2019"} 1
random_date{year="2019",month="march",day="03/07/2019"} 2
params: random_date{year="2019",day=~"^([0-2][0-9]|(3)[0-1])(\\/)(((0)[0-9])|((1)[0-2]))(\\/)\\d{4}$"}
- value_type: day
+ request: label
+ output: day
out:
result: FAIL
---
@@ -1201,7 +1303,8 @@ in:
# TYPE wmi_os_timezone gauge
wmi_os_timezone{timezone="MSK"} 1
params: wmi_os_timezone 1
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -1212,7 +1315,8 @@ in:
some_user{country="lv",addr="user2@domain.org"} 2
some_user{country="lv",addr="no_valid_addr"} 2
params: some_user{country="lv",addr=~"[-\\w\\.]+@([\\w-]+\\.)+[\\w-]{2,4}"} == 1
- value_type: addr
+ request: label
+ output: addr
out:
result: SUCCEED
output: 'user1@domain.com'
@@ -1224,7 +1328,8 @@ in:
some_user{country="lv",addr="user2@domain.org"} 2
some_user{country="lv",addr="no_valid_addr"} 2
params: some_user{country="lv",addr=~"^[-\\w\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$"} == 2
- value_type: addr
+ request: label
+ output: addr
out:
result: SUCCEED
output: 'user2@domain.org'
@@ -1236,7 +1341,8 @@ in:
some_user{country="lv",addr="user2@domain.org"} 2
some_user{country="lv",addr="no_valid_addr"} 3
params: some_user{country="lv",addr=~"^[-\\w\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$"} == 3
- value_type: addr
+ request: label
+ output: addr
out:
result: FAIL
---
@@ -1247,7 +1353,8 @@ in:
some_user{country="lv",addr="user2@domain.org"} 2
some_user{country="lv",addr="no_valid_addr"} 3
params: some_user{country="lv",addr=~"^[-\\w\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$"}
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -1255,7 +1362,8 @@ test case: 'Label value holds "{"'
in:
data: cpu_usage_system{cpu="cpu{total"} 1.1940298507220641
params: cpu_usage_system{cpu="cpu{total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -1264,7 +1372,8 @@ test case: 'Label value holds "{}"'
in:
data: cpu_usage_system{cpu="cpu{}total"} 1.1940298507220641
params: cpu_usage_system{cpu="cpu{}total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -1273,7 +1382,8 @@ test case: 'Label value holds "}"'
in:
data: cpu_usage_system{cpu="cpu}total"} 1.1940298507220641
params: cpu_usage_system{cpu="cpu}total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -1282,7 +1392,8 @@ test case: 'Label value holds ","'
in:
data: important_metric{important_number="42,0"} 42
params: important_metric{important_number="42,0"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 42
@@ -1291,7 +1402,8 @@ test case: 'Get label value (cpu) using params: "cpu_usage_system{cpu="cpu{total
in:
data: cpu_usage_system{cpu="cpu{total"} 1.1940298507220641
params: cpu_usage_system{cpu="cpu{total"} == 1.1940298507220641
- value_type: cpu
+ request: label
+ output: cpu
out:
result: SUCCEED
output: 'cpu{total'
@@ -1300,7 +1412,8 @@ test case: 'Get label value (cpu) using params: "cpu_usage_system{cpu="cpu}total
in:
data: cpu_usage_system{cpu="cpu}total"} 1.1940298507220641
params: cpu_usage_system{cpu="cpu}total"} == 1.1940298507220641
- value_type: cpu
+ request: label
+ output: cpu
out:
result: SUCCEED
output: 'cpu}total'
@@ -1309,7 +1422,8 @@ test case: 'Metric with five values'
in:
data: cpu_usage_system{cpu="cputotal"} 1.1940298507220641 2.23443 333 four five
params: cpu_usage_system{cpu="cputotal"} == 1.1940298507220641
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -1324,7 +1438,8 @@ in:
wmi_os_timezone{timezone="MSK"} 1
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
params: cpu_usage_system{cpu="cpu1",host=~".*"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1340298507220641
@@ -1339,7 +1454,8 @@ in:
wmi_os_timezone{timezone="MSK"} 1
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
params: wmi_os_timezone
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1
@@ -1357,7 +1473,8 @@ in:
http_requests_total{method="post",code="200"} 1027 1395066363000
http_requests_total{method="post",code="400"} 3 1395066363000
params: http_requests_total == 3
- value_type: code
+ request: label
+ output: code
out:
result: SUCCEED
output: 400
@@ -1375,7 +1492,8 @@ in:
http_requests_total{method="post",code="200"} 1027 1395066363000
http_requests_total{method="post",code="400"} 3 1395066363000
params: '{cpu="cpu0"}'
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -1393,7 +1511,8 @@ in:
http_requests_total{method="post",code="200"} 1027 1395066363000
http_requests_total{method="post",code="400",host="host1"} 3 1395066363000
params: '{host="host1"}'
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -1406,7 +1525,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1",perf="100"} 1.1940298507220641
cpu_usage_system{cpu="cpu1",host="host1",perf="100"} 1.1340298507220641
params: cpu_usage_system { cpu = "cpu-total" , host = "host1",perf="100" }
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -1419,7 +1539,8 @@ in:
http_requests_total{method="post2",code="200"} 1027 1395066363000
http_requests_total{method="post1",code="400"} 3 1395066363000
params: http_requests_total{code="400"}==3
- value_type: "method"
+ request: label
+ output: "method"
out:
result: SUCCEED
output: post1
@@ -1432,7 +1553,8 @@ in:
http_requests_total{method="post1",code="200"} 1027 1395066363000
http_requests_total{method="post2",code="400"} 3 1395066363000
params: http_requests_total{code="400"} == 3
- value_type: "method"
+ request: label
+ output: "method"
out:
result: SUCCEED
output: post2
@@ -1441,7 +1563,8 @@ test case: 'Invalid metric (expected "fail"): metric with string value'
in:
data: wmi_os_physical_memory_free_bytes some_value
params: wmi_os_physical_memory_free_bytes
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -1452,7 +1575,8 @@ in:
# TYPE wmi_os_timezone gauge
wmi_os_timezone{timezone="MSK"} 1
params: wmi_os_timezone{timezone="MSK"} == some_value
- value_type: "timezone"
+ request: label
+ output: "timezone"
out:
result: FAIL
---
@@ -1465,7 +1589,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1"} 1.1940298507220641
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
params: '{__name__=~".*",cpu="cpu-total",__name__="cpu_usage_system"}'
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -1478,7 +1603,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1",perf="100"} 1.1640298507220641
cpu_usage_system{cpu="cpu1",host="host1",perf="100"} 1.1340298507220641
params: '{cpu=~".*",cpu=~"cpu-tot.+",perf="100"}'
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 1.1940298507220641
@@ -1492,7 +1618,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1",perf="100"} 1.1640298507220641
cpu_usage_system{cpu="cpu1",host="host1",perf="100"} 1.1340298507220641
params: '{cpu=~"z.+",cpu=~"cpu-tot.+",perf="100"}'
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -1505,7 +1632,8 @@ in:
cpu_usage_system{cpu="cpu0",host="host1",perf="100"} 1.1640298507220641
cpu_usage_system{cpu="cpu1",host="host1",perf="100"} 1.1340298507220641
params: '{cpu=~"z.+",cpu=~"y.+",perf="100"}'
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -1516,7 +1644,8 @@ in:
apache{state="yellow"} 0
apache{state="green"} inf
params: apache == INF
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -1527,7 +1656,8 @@ in:
apache{state="yellow"} 0
apache{state="green"} +inf
params: apache == INF
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -1538,7 +1668,8 @@ in:
apache{state="yellow"} 0
apache{state="green"} nan
params: apache == NAN
- value_type: ""
+ request: value
+ output: ""
out:
result: FAIL
---
@@ -1549,7 +1680,8 @@ in:
apache{state="yellow"} 0
apache{state="green"} 0
params: apache == INF
- value_type: state
+ request: label
+ output: state
out:
result: SUCCEED
output: red
@@ -1561,7 +1693,8 @@ in:
apache{state="yellow"} 0
apache{state="green"} 0
params: apache == +INF
- value_type: state
+ request: label
+ output: state
out:
result: SUCCEED
output: red
@@ -1573,7 +1706,8 @@ in:
apache{state="yellow"} -Inf
apache{state="green"} 0
params: apache == -INF
- value_type: state
+ request: label
+ output: state
out:
result: SUCCEED
output: yellow
@@ -1585,7 +1719,8 @@ in:
apache{state="yellow"} NaN
apache{state="green"} 0
params: apache == -INF
- value_type: state
+ request: label
+ output: state
out:
result: FAIL
---
@@ -1596,7 +1731,8 @@ in:
apache{state="yellow"} 0
apache{state="green"} NaN
params: apache == NAN
- value_type: state
+ request: label
+ output: state
out:
result: SUCCEED
output: green
@@ -1608,7 +1744,8 @@ in:
apache{state="yellow"} 0
apache{state="green"} 1.0
params: apache == 1
- value_type: state
+ request: label
+ output: state
out:
result: SUCCEED
output: green
@@ -1620,7 +1757,8 @@ in:
apache{state="yellow"} 0
apache{state="green"} 1e1
params: apache == 10
- value_type: state
+ request: label
+ output: state
out:
result: SUCCEED
output: green
@@ -1632,7 +1770,8 @@ in:
apache{state="yellow"} 0
apache{state="green"} 1.25e2
params: apache == 125
- value_type: state
+ request: label
+ output: state
out:
result: SUCCEED
output: green
@@ -1644,7 +1783,8 @@ in:
apache{state="yellow"} 0
apache{state="green"} 1e-2
params: apache == 00.0100
- value_type: state
+ request: label
+ output: state
out:
result: SUCCEED
output: green
@@ -1656,7 +1796,8 @@ in:
apache{state="yellow"} 1.25e2
apache{state="green"} 12500e-2
params: apache == 125
- value_type: state
+ request: label
+ output: state
out:
result: FAIL
---
@@ -1667,7 +1808,8 @@ in:
apache{state="yellow"} 0
apache{state="green"} +1
params: apache == 1
- value_type: state
+ request: label
+ output: state
out:
result: SUCCEED
output: green
@@ -1679,7 +1821,8 @@ in:
apache{state="yellow"} 0
apache{state="green"} +1
params: apache == +1
- value_type: state
+ request: label
+ output: state
out:
result: SUCCEED
output: green
@@ -1691,7 +1834,8 @@ in:
apache{state="yellow"} 0
apache{state="green"} 1
params: apache == +1
- value_type: state
+ request: label
+ output: state
out:
result: SUCCEED
output: green
@@ -1703,7 +1847,8 @@ in:
apache{state="yellow"} 0
apache{state="green"} -1
params: apache == +1
- value_type: state
+ request: label
+ output: state
out:
result: FAIL
---
@@ -1714,7 +1859,8 @@ in:
apache{state="yellow"} 0
apache{state="green"} +1
params: apache == -1
- value_type: state
+ request: label
+ output: state
out:
result: FAIL
---
@@ -1725,7 +1871,8 @@ in:
cpu_usage_system{cpu="cpu0",state="10",host="host2"} nan
cpu_usage_system{cpu="cpu1",state="88",host="host3"} 3.5180249088e+11
params: cpu_usage_system==3.5180249088e+11
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 3.5180249088e+11
@@ -1738,7 +1885,8 @@ in:
cpu_usage_system{cpu="cpu-total",host="host1"} 1.23456
cpu_usage_system{cpu="cpu0",host="host1"} 7.891011
params: cpu_usage_system{cpu!="cpu-total"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 7.891011
@@ -1751,9 +1899,83 @@ in:
cpu_usage_system{cpu="cpu-total",host="host1"} 1.23456
cpu_usage_system{cpu="cpu0",host="host1"} 7.891011
params: cpu_usage_system{cpu!~"total$"}
- value_type: ""
+ request: value
+ output: ""
out:
result: SUCCEED
output: 7.891011
+---
+test case: 'Count the metrics'
+in:
+ data: |
+ apache{state="red"} 0
+ apache{state="yellow"} 0
+ apache{state="green"} 1
+ params: apache
+ request: function
+ output: count
+out:
+ result: SUCCEED
+ output: 3
+---
+test case: 'Sum metric values using params: "cpu_usage_system{cpu=~"cpu-total"}"'
+in:
+ data: |
+ # HELP cpu_usage_system Telegraf collected metric
+ # TYPE cpu_usage_system gauge
+ cpu_usage_system{cpu="cpu-total"} 100.0
+ cpu_usage_system{cpu="cpu0"} 60.0
+ cpu_usage_system{cpu="cpu1"} 40.0
+ params: cpu_usage_system{cpu=~"cpu[0-9]+"}
+ request: function
+ output: sum
+out:
+ result: SUCCEED
+ output: 100
+---
+test case: 'Avg metric values using params: "cpu_usage_system{cpu=~"cpu-total"}"'
+in:
+ data: |
+ # HELP cpu_usage_system Telegraf collected metric
+ # TYPE cpu_usage_system gauge
+ cpu_usage_system{cpu="cpu-total"} 100.0
+ cpu_usage_system{cpu="cpu0"} 60.0
+ cpu_usage_system{cpu="cpu1"} 40.0
+ params: cpu_usage_system{cpu=~"cpu[0-9]+"}
+ request: function
+ output: avg
+out:
+ result: SUCCEED
+ output: 50
+---
+test case: 'Min metric values using params: "cpu_usage_system{cpu=~"cpu-total"}"'
+in:
+ data: |
+ # HELP cpu_usage_system Telegraf collected metric
+ # TYPE cpu_usage_system gauge
+ cpu_usage_system{cpu="cpu-total"} 100.0
+ cpu_usage_system{cpu="cpu0"} 60.0
+ cpu_usage_system{cpu="cpu1"} 40.0
+ params: cpu_usage_system{cpu=~"cpu[0-9]+"}
+ request: function
+ output: min
+out:
+ result: SUCCEED
+ output: 40
+---
+test case: 'Max metric values using params: "cpu_usage_system{cpu=~"cpu-total"}"'
+in:
+ data: |
+ # HELP cpu_usage_system Telegraf collected metric
+ # TYPE cpu_usage_system gauge
+ cpu_usage_system{cpu="cpu-total"} 100.0
+ cpu_usage_system{cpu="cpu0"} 60.0
+ cpu_usage_system{cpu="cpu1"} 40.0
+ params: cpu_usage_system{cpu=~"cpu[0-9]+"}
+ request: function
+ output: max
+out:
+ result: SUCCEED
+ output: 60
...
diff --git a/tests/zabbix_server/preprocessor/Makefile.am b/tests/zabbix_server/preprocessor/Makefile.am
index 420e50c19fc..a238bcdc0af 100644
--- a/tests/zabbix_server/preprocessor/Makefile.am
+++ b/tests/zabbix_server/preprocessor/Makefile.am
@@ -31,6 +31,7 @@ JSON_LIBS = \
$(top_srcdir)/src/libs/zbxsys/libzbxsys.a \
$(top_srcdir)/src/libs/zbxconf/libzbxconf.a \
$(top_srcdir)/src/libs/zbxprometheus/libzbxprometheus.a \
+ $(top_srcdir)/src/libs/zbxeval/libzbxeval.a \
$(top_srcdir)/src/libs/zbxalgo/libzbxalgo.a \
$(top_srcdir)/src/libs/zbxhttp/libzbxhttp.a \
$(top_srcdir)/tests/libzbxmockdata.a
diff --git a/tests/zabbix_server/preprocessor/zbx_item_preproc.c b/tests/zabbix_server/preprocessor/zbx_item_preproc.c
index f740c48ec1b..f0308e71393 100644
--- a/tests/zabbix_server/preprocessor/zbx_item_preproc.c
+++ b/tests/zabbix_server/preprocessor/zbx_item_preproc.c
@@ -201,8 +201,12 @@ void zbx_mock_test_entry(void **state)
history_ts.ns = 0;
}
- if (FAIL == (returned_ret = zbx_item_preproc(value_type, &value, &ts, &op, &history_value, &history_ts, &error)))
+ if (FAIL == (returned_ret = zbx_item_preproc(NULL, value_type, &value, &ts, &op, &history_value, &history_ts,
+ &error)))
+ {
returned_ret = zbx_item_preproc_handle_error(&value, &op, &error);
+ }
+
if (SUCCEED != returned_ret)
zabbix_log(LOG_LEVEL_DEBUG, "Preprocessing error: %s", error);
diff --git a/tests/zabbix_server/preprocessor/zbx_item_preproc.yaml b/tests/zabbix_server/preprocessor/zbx_item_preproc.yaml
index 362ee0c5b0f..ef12178fa0a 100644
--- a/tests/zabbix_server/preprocessor/zbx_item_preproc.yaml
+++ b/tests/zabbix_server/preprocessor/zbx_item_preproc.yaml
@@ -1657,7 +1657,7 @@ in:
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
step:
type: ZBX_PREPROC_PROMETHEUS_PATTERN
- params: "cpu_usage_system{cpu=\"cpu-total\",host=~\".*\"}\n"
+ params: "cpu_usage_system{cpu=\"cpu-total\",host=~\".*\"}\nvalue\n"
out:
return: SUCCEED
value: 1.1940298507220641
@@ -1670,7 +1670,7 @@ in:
data: metric_without_timestamp_and_labels 12.47
step:
type: ZBX_PREPROC_PROMETHEUS_PATTERN
- params: "metric_without_timestamp_and_labels\n"
+ params: "metric_without_timestamp_and_labels\nvalue\n"
out:
return: SUCCEED
value: 12.47
@@ -1688,7 +1688,7 @@ in:
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
step:
type: ZBX_PREPROC_PROMETHEUS_PATTERN
- params: "{cpu=\"cpu0\",__name__=\"cpu_usage_system\"}\n"
+ params: "{cpu=\"cpu0\",__name__=\"cpu_usage_system\"}\nvalue\n"
out:
return: SUCCEED
value: 1.1940298507220641
@@ -1705,7 +1705,7 @@ in:
http_requests_total{method="post",code="400"} 3 1395066363000
step:
type: ZBX_PREPROC_PROMETHEUS_PATTERN
- params: "http_requests_total{code=\"200\"}\n"
+ params: "http_requests_total{code=\"200\"}\nvalue\n"
out:
return: SUCCEED
value: 1027
@@ -1721,7 +1721,7 @@ in:
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
step:
type: ZBX_PREPROC_PROMETHEUS_PATTERN
- params: "\n"
+ params: "\nvalue\n"
out:
return: SUCCEED
value: 1.1340298507220641
@@ -1737,7 +1737,7 @@ in:
cpu_usage_system{cpu="cpu1",host="host1"} 1.1340298507220641
step:
type: ZBX_PREPROC_PROMETHEUS_PATTERN
- params: "cpu_usage_system\n"
+ params: "cpu_usage_system\nvalue\n"
out:
return: SUCCEED
value: 1.1340298507220641
@@ -1755,7 +1755,7 @@ in:
cpu_usage_system{cpu="cpu1",host="host3"} 1.1340298507220641
step:
type: ZBX_PREPROC_PROMETHEUS_PATTERN
- params: "cpu_usage_system{cpu=\"cpu0\"} == 1.1940298507220641\nhost"
+ params: "cpu_usage_system{cpu=\"cpu0\"} == 1.1940298507220641\nlabel\nhost"
out:
return: SUCCEED
value: host2
@@ -1772,6 +1772,7 @@ in:
type: ZBX_PREPROC_PROMETHEUS_PATTERN
params: |-
AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz:_0123456789 == 123123123
+ label
AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz_0123456789
out:
return: SUCCEED
@@ -1792,6 +1793,7 @@ in:
type: ZBX_PREPROC_PROMETHEUS_PATTERN
params: |-
cpu_usage_system{cpu="cpu0"} == 1.1940298507220641
+ label
host
out:
return: SUCCEED
@@ -1812,6 +1814,7 @@ in:
type: ZBX_PREPROC_PROMETHEUS_PATTERN
params: |-
cpu_usage_system{cpu="cpu1"}
+ label
host
out:
return: SUCCEED
diff --git a/tests/zabbix_server/trapper/Makefile.am b/tests/zabbix_server/trapper/Makefile.am
index 5b57b9ca0ef..45c1b509c58 100644
--- a/tests/zabbix_server/trapper/Makefile.am
+++ b/tests/zabbix_server/trapper/Makefile.am
@@ -30,6 +30,7 @@ TRAPPER_LIBS = \
$(top_srcdir)/src/libs/zbxconf/libzbxconf.a \
$(top_srcdir)/src/libs/zbxembed/libzbxembed.a \
$(top_srcdir)/src/libs/zbxprometheus/libzbxprometheus.a \
+ $(top_srcdir)/src/libs/zbxeval/libzbxeval.a \
$(top_srcdir)/src/libs/zbxalgo/libzbxalgo.a \
$(top_srcdir)/src/libs/zbxhttp/libzbxhttp.a \
$(top_srcdir)/tests/libzbxmockdata.a
@@ -47,7 +48,9 @@ zbx_trapper_preproc_test_run_LDFLAGS = @SERVER_LDFLAGS@ \
-Wl,--wrap=DBget_user_by_active_session \
-Wl,--wrap=DBget_user_by_auth_token \
-Wl,--wrap=zbx_user_init \
- -Wl,--wrap=zbx_user_free
+ -Wl,--wrap=zbx_user_free \
+ -Wl,--wrap=init_result \
+ -Wl,--wrap=free_result
zbx_trapper_preproc_test_run_CFLAGS = \
-I@top_srcdir@/tests @LIBXML2_CFLAGS@
diff --git a/tests/zabbix_server/trapper/zbx_trapper_preproc_test_run.c b/tests/zabbix_server/trapper/zbx_trapper_preproc_test_run.c
index d0f698861f7..c7ea2dac668 100644
--- a/tests/zabbix_server/trapper/zbx_trapper_preproc_test_run.c
+++ b/tests/zabbix_server/trapper/zbx_trapper_preproc_test_run.c
@@ -116,6 +116,17 @@ void __wrap_zbx_user_free(zbx_user_t *user)
zbx_free(user->username);
}
+void __wrap_init_result(AGENT_RESULT *result)
+{
+ ZBX_UNUSED(result);
+}
+
+void __wrap_free_result(AGENT_RESULT *result)
+{
+ ZBX_UNUSED(result);
+}
+
+
void zbx_mock_test_entry(void **state)
{
const char *request;