diff options
Diffstat (limited to 'tests/libs')
-rw-r--r-- | tests/libs/zbxcommon/Makefile.am | 2 | ||||
-rw-r--r-- | tests/libs/zbxdbcache/Makefile.am | 2 | ||||
-rw-r--r-- | tests/libs/zbxdbhigh/Makefile.am | 6 | ||||
-rw-r--r-- | tests/libs/zbxeval/zbx_eval_execute.yaml | 74 | ||||
-rwxr-xr-x | tests/libs/zbxserver/Makefile.am | 9 | ||||
-rw-r--r-- | tests/libs/zbxserver/evaluate_function.yaml | 230 | ||||
-rw-r--r-- | tests/libs/zbxsysinfo/Makefile.am | 31 | ||||
-rw-r--r-- | tests/libs/zbxsysinfo/common/Makefile.am | 2 | ||||
-rw-r--r-- | tests/libs/zbxsysinfo/linux/Makefile.am | 2 | ||||
-rw-r--r-- | tests/libs/zbxsysinfo/process.c | 33 | ||||
-rw-r--r-- | tests/libs/zbxsysinfo/process.yaml | 15 | ||||
-rw-r--r-- | tests/libs/zbxsysinfo/process_http.c | 99 | ||||
-rw-r--r-- | tests/libs/zbxsysinfo/process_http.yaml | 16 |
13 files changed, 469 insertions, 52 deletions
diff --git a/tests/libs/zbxcommon/Makefile.am b/tests/libs/zbxcommon/Makefile.am index 38383a6dea9..e2c3585d578 100644 --- a/tests/libs/zbxcommon/Makefile.am +++ b/tests/libs/zbxcommon/Makefile.am @@ -66,6 +66,8 @@ COMMON_LIB_FILES = \ $(top_srcdir)/src/libs/zbxserver/libzbxserver.a \ $(top_srcdir)/src/libs/zbxsysinfo/libzbxserversysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_httpmetrics.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_http.a \ $(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \ $(top_srcdir)/src/libs/zbxdbcache/libzbxdbcache.a \ $(top_srcdir)/src/libs/zbxmemory/libzbxmemory.a \ diff --git a/tests/libs/zbxdbcache/Makefile.am b/tests/libs/zbxdbcache/Makefile.am index 4cecca22612..422a9299a0f 100644 --- a/tests/libs/zbxdbcache/Makefile.am +++ b/tests/libs/zbxdbcache/Makefile.am @@ -51,6 +51,8 @@ CACHE_LIBS = \ $(top_srcdir)/src/libs/zbxsysinfo/libzbxserversysinfo.a \ $(top_srcdir)/src/libs/zbxxml/libzbxxml.a \ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_httpmetrics.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_http.a \ $(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \ $(top_srcdir)/src/libs/zbxhistory/libzbxhistory.a \ $(top_srcdir)/src/libs/zbxmodules/libzbxmodules.a \ diff --git a/tests/libs/zbxdbhigh/Makefile.am b/tests/libs/zbxdbhigh/Makefile.am index 5cd66d01ee6..17e6c42c3c9 100644 --- a/tests/libs/zbxdbhigh/Makefile.am +++ b/tests/libs/zbxdbhigh/Makefile.am @@ -76,10 +76,14 @@ SERVER_COMMON_LIB = \ $(top_srcdir)/src/zabbix_server/preprocessor/libpreprocessor.a \ $(top_srcdir)/src/libs/zbxsysinfo/libzbxserversysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_httpmetrics.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_http.a \ $(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \ $(top_srcdir)/src/libs/zbxserver/libzbxserver.a \ $(top_srcdir)/src/libs/zbxsysinfo/libzbxserversysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_httpmetrics.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_http.a \ $(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \ $(top_srcdir)/src/libs/zbxdbcache/libzbxdbcache.a \ $(top_srcdir)/src/libs/zbxeval/libzbxeval.a \ @@ -130,6 +134,8 @@ PROXY_COMMON_LIB = \ $(top_srcdir)/src/zabbix_proxy/libzbxproxy.a \ $(top_srcdir)/src/libs/zbxsysinfo/libzbxproxysysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_httpmetrics.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_http.a \ $(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/linux/libspechostnamesysinfo.a \ $(COMMON_LIB) diff --git a/tests/libs/zbxeval/zbx_eval_execute.yaml b/tests/libs/zbxeval/zbx_eval_execute.yaml index ca7f2307959..d24a1779ef3 100644 --- a/tests/libs/zbxeval/zbx_eval_execute.yaml +++ b/tests/libs/zbxeval/zbx_eval_execute.yaml @@ -2147,4 +2147,78 @@ in: expression: 'power(10,300)*power(10,300)' out: result: FAIL +--- +test case: Expression 'histogram_quantile(0.8, 0.1, 1, 0.2, 2, +Inf, 3)' +in: + rules: [ZBX_EVAL_PARSE_FUNCTION,ZBX_EVAL_PARSE_VAR] + expression: 'histogram_quantile(0.8, 0.1, 1, 0.2, 2, "+Inf", 3)' +out: + result: SUCCEED + value: '0.2' +--- +test case: Expression 'histogram_quantile(0.8, 0.2, 10, 0.4, 20, 1.0, 60, 1.2, 70, +Inf, 80)' +in: + rules: [ZBX_EVAL_PARSE_FUNCTION,ZBX_EVAL_PARSE_VAR] + expression: 'histogram_quantile(0.8, 0.2, 10, 0.4, 20, 1.0, 60, 1.2, 70, "+Inf", 80)' +out: + result: SUCCEED + value: '1.08' +--- +test case: Expression 'histogram_quantile(0.8, 0.2, 10, 0.4, 20, 1.0, 25, 1.0, 35, 1.2, 70, +Inf, 80)' +in: + rules: [ZBX_EVAL_PARSE_FUNCTION,ZBX_EVAL_PARSE_VAR] + expression: 'histogram_quantile(0.8, 0.2, 10, 0.4, 20, 1.0, 25, 1.0, 35, 1.2, 70, "+Inf", 80)' +out: + result: SUCCEED + value: '1.08' +--- +test case: Expression 'histogram_quantile(0.8, 0.2, 10, 1.0, 60, 0.4, 20, 1.2, 70, +Inf, 80)' +in: + rules: [ZBX_EVAL_PARSE_FUNCTION,ZBX_EVAL_PARSE_VAR] + expression: 'histogram_quantile(0.8, 0.2, 10, 1.0, 60, 0.4, 20, 1.2, 70, "+Inf", 80)' +out: + result: SUCCEED + value: '1.08' +--- +test case: Expression 'histogram_quantile(0.8, 0.1, 1)' +in: + rules: [ZBX_EVAL_PARSE_FUNCTION,ZBX_EVAL_PARSE_VAR] + expression: 'histogram_quantile(0.8, 0.1, 1)' +out: + result: FAIL +--- +test case: Expression 'histogram_quantile(0.8, 0.1, 1, 0.2, 2, 0.3, 3)' +in: + rules: [ZBX_EVAL_PARSE_FUNCTION,ZBX_EVAL_PARSE_VAR] + expression: 'histogram_quantile(0.8, 0.1, 1, 0.2, 2, 0.3, 3)' +out: + result: FAIL +--- +test case: Expression 'histogram_quantile(0.8, 0.2, 2, 0.1, "+Inf", 3)' +in: + rules: [ZBX_EVAL_PARSE_FUNCTION,ZBX_EVAL_PARSE_VAR] + expression: 'histogram_quantile(0.8, 0.2, 2, 0.1, "+Inf", 3)' +out: + result: FAIL +--- +test case: Expression 'histogram_quantile(0.8, 0.1, 1, 0.2, 2, +Inf, 0)' +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 +--- +test case: Expression 'histogram_quantile(-0.1, 0.2, 10, 0.4, 20, 1.0, 60, 1.2, 70, +Inf, 80)' +in: + rules: [ZBX_EVAL_PARSE_FUNCTION,ZBX_EVAL_PARSE_VAR] + expression: 'histogram_quantile(-0.1, 0.2, 10, 0.4, 20, 1.0, 60, 1.2, 70, "+Inf", 80)' +out: + result: FAIL +--- +test case: Expression 'histogram_quantile(1.1, 0.2, 10, 0.4, 20, 1.0, 60, 1.2, 70, +Inf, 80)' +in: + rules: [ZBX_EVAL_PARSE_FUNCTION,ZBX_EVAL_PARSE_VAR] + expression: 'histogram_quantile(1.1, 0.2, 10, 0.4, 20, 1.0, 60, 1.2, 70, "+Inf", 80)' +out: + result: FAIL ... diff --git a/tests/libs/zbxserver/Makefile.am b/tests/libs/zbxserver/Makefile.am index 9149eedfcca..48bcd7a0228 100755 --- a/tests/libs/zbxserver/Makefile.am +++ b/tests/libs/zbxserver/Makefile.am @@ -33,6 +33,15 @@ COMMON_LIB_FILES = \ $(top_srcdir)/src/zabbix_server/odbc/libzbxodbc.a \ $(top_srcdir)/src/zabbix_server/scripts/libzbxscripts.a \ $(top_srcdir)/src/zabbix_server/preprocessor/libpreprocessor.a \ + $(top_srcdir)/src/libs/zbxserver/libzbxserver.a \ + $(top_srcdir)/src/libs/zbxdbcache/libzbxdbcache.a \ + $(top_srcdir)/src/libs/zbxtrends/libzbxtrends.a \ + $(top_srcdir)/src/libs/zbxsysinfo/libzbxserversysinfo.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_httpmetrics.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_http.a \ + $(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \ + $(top_srcdir)/src/libs/zbxmemory/libzbxmemory.a \ $(top_srcdir)/src/libs/zbxself/libzbxself.a \ $(top_srcdir)/src/libs/zbxalgo/libzbxalgo.a \ $(top_srcdir)/src/libs/zbxsys/libzbxsys.a \ diff --git a/tests/libs/zbxserver/evaluate_function.yaml b/tests/libs/zbxserver/evaluate_function.yaml index 7a7c2955a68..bb8ac8013be 100644 --- a/tests/libs/zbxserver/evaluate_function.yaml +++ b/tests/libs/zbxserver/evaluate_function.yaml @@ -3466,4 +3466,234 @@ in: out: return: FAIL value: +--- +test case: Evaluate rate(), with DOUBLE data +in: + history: + - itemid: 1 + value type: ITEM_VALUE_TYPE_FLOAT + data: + - value: 1 + ts: 2021-03-27 10:01:00.000000001 +00:00 + - value: 2 + ts: 2021-03-27 10:01:01.000000000 +00:00 + - value: 3 + ts: 2021-03-27 10:01:02.000000000 +00:00 + time: 2021-03-27 10:01:02.000000000 +00:00 + function: rate + params: '2' +out: + return: SUCCEED + value: 1 +--- +test case: Evaluate rate(), with UINT64 data +in: + history: + - itemid: 1 + value type: ITEM_VALUE_TYPE_UINT64 + data: + - value: 1 + ts: 2021-03-27 10:01:00.000000001 +00:00 + - value: 2 + ts: 2021-03-27 10:01:01.000000000 +00:00 + - value: 3 + ts: 2021-03-27 10:01:02.000000000 +00:00 + time: 2021-03-27 10:01:02.000000000 +00:00 + function: rate + params: '2' +out: + return: SUCCEED + value: 1 +--- +test case: Evaluate rate() extrapolation, with DOUBLE data +in: + history: + - itemid: 1 + value type: ITEM_VALUE_TYPE_FLOAT + data: + - value: 1 + ts: 2021-03-27 10:01:00.000000001 +00:00 + - value: 2 + ts: 2021-03-27 10:01:01.000000000 +00:00 + - value: 3 + ts: 2021-03-27 10:01:02.000000000 +00:00 + time: 2021-03-27 10:01:02.500000000 +00:00 + function: rate + params: '3' +out: + return: SUCCEED + value: 1 +--- +test case: Evaluate rate() extrapolation, with UINT64 data +in: + history: + - itemid: 1 + value type: ITEM_VALUE_TYPE_UINT64 + data: + - value: 1 + ts: 2021-03-27 10:01:00.000000001 +00:00 + - value: 2 + ts: 2021-03-27 10:01:01.000000000 +00:00 + - value: 3 + ts: 2021-03-27 10:01:02.000000000 +00:00 + time: 2021-03-27 10:01:02.500000000 +00:00 + function: rate + params: '3' +out: + return: SUCCEED + value: 1 +--- +test case: Evaluate rate() with reset and DOUBLE data +in: + history: + - itemid: 1 + value type: ITEM_VALUE_TYPE_FLOAT + data: + - value: 1 + ts: 2021-03-27 10:01:00.000000001 +00:00 + - value: 2 + ts: 2021-03-27 10:01:01.000000000 +00:00 + - value: 1 + ts: 2021-03-27 10:01:02.000000000 +00:00 + - value: 2 + ts: 2021-03-27 10:01:03.000000000 +00:00 + - value: 3 + ts: 2021-03-27 10:01:04.000000000 +00:00 + time: 2021-03-27 10:01:04.000000000 +00:00 + function: rate + params: '4' +out: + return: SUCCEED + value: 1 + +--- +test case: Evaluate rate() with reset and UINT64 data +in: + history: + - itemid: 1 + value type: ITEM_VALUE_TYPE_UINT64 + data: + - value: 1 + ts: 2021-03-27 10:01:00.000000001 +00:00 + - value: 2 + ts: 2021-03-27 10:01:01.000000000 +00:00 + - value: 1 + ts: 2021-03-27 10:01:02.000000000 +00:00 + - value: 2 + ts: 2021-03-27 10:01:03.000000000 +00:00 + - value: 3 + ts: 2021-03-27 10:01:04.000000000 +00:00 + time: 2021-03-27 10:01:04.000000000 +00:00 + function: rate + params: '4' +out: + return: SUCCEED + value: 1 +--- +test case: Evaluate rate() extrapolation without change UINT64 data +in: + history: + - itemid: 1 + value type: ITEM_VALUE_TYPE_UINT64 + data: + - value: 1 + ts: 2021-03-27 10:01:00.000000001 +00:00 + - value: 1 + ts: 2021-03-27 10:01:01.000000000 +00:00 + - value: 1 + ts: 2021-03-27 10:01:02.000000000 +00:00 + time: 2021-03-27 10:01:02.500000000 +00:00 + function: rate + params: '3' +out: + return: SUCCEED + value: 0 +--- +test case: Evaluate rate() extrapolation without change DOUBLE data +in: + history: + - itemid: 1 + value type: ITEM_VALUE_TYPE_FLOAT + data: + - value: 1 + ts: 2021-03-27 10:01:00.000000001 +00:00 + - value: 1 + ts: 2021-03-27 10:01:01.000000000 +00:00 + - value: 1 + ts: 2021-03-27 10:01:02.000000000 +00:00 + time: 2021-03-27 10:01:02.500000000 +00:00 + function: rate + params: '3' +out: + return: SUCCEED + value: 0 +--- +test case: Evaluate rate() without DOUBLE data +in: + history: + - itemid: 1 + value type: ITEM_VALUE_TYPE_FLOAT + data: + - value: 1 + ts: 2021-03-27 10:01:00.000000001 +00:00 + - value: 2 + ts: 2021-03-27 10:01:01.000000000 +00:00 + time: 2021-03-27 10:01:04.500000000 +00:00 + function: rate + params: '1' +out: + return: FAIL + value: 0 +--- +test case: Evaluate rate() without 2 DOUBLE backet +in: + history: + - itemid: 1 + value type: ITEM_VALUE_TYPE_FLOAT + data: + - value: 1 + ts: 2021-03-27 10:01:00.000000001 +00:00 + - value: 2 + ts: 2021-03-27 10:01:02.000000000 +00:00 + time: 2021-03-27 10:01:02.500000000 +00:00 + function: rate + params: '1' +out: + return: FAIL + value: 0 +--- +test case: Evaluate rate() with STR data +in: + history: + - itemid: 1 + value type: ITEM_VALUE_TYPE_STR + data: + - value: 1 + ts: 2021-03-27 10:01:00.000000001 +00:00 + - value: 2 + ts: 2021-03-27 10:01:02.000000000 +00:00 + time: 2021-03-27 10:01:02.000000000 +00:00 + function: rate + params: '2' +out: + return: FAIL + value: 0 +--- +test case: Evaluate rate() with negative reset +in: + history: + - itemid: 1 + value type: ITEM_VALUE_TYPE_FLOAT + data: + - value: 11 + ts: 2021-03-27 10:01:00.000000001 +00:00 + - value: 1 + ts: 2021-03-27 10:01:01.000000000 +00:00 + time: 2021-03-27 10:01:01.000000000 +00:00 + function: rate + params: '1' +out: + return: SUCCEED + value: 1 + ... diff --git a/tests/libs/zbxsysinfo/Makefile.am b/tests/libs/zbxsysinfo/Makefile.am index a721aa4bbcb..17de2bbc969 100644 --- a/tests/libs/zbxsysinfo/Makefile.am +++ b/tests/libs/zbxsysinfo/Makefile.am @@ -9,6 +9,7 @@ endif if AGENT AGENT_tests = \ process \ + process_http \ check_key_access_rules endif @@ -49,6 +50,8 @@ parse_item_key_LDADD = \ $(top_srcdir)/src/libs/zbxserver/libzbxserver.a \ $(top_srcdir)/src/libs/zbxsysinfo/libzbxserversysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_httpmetrics.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_http.a \ $(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \ $(top_srcdir)/src/libs/zbxdbcache/libzbxdbcache.a \ $(top_srcdir)/src/libs/zbxhistory/libzbxhistory.a \ @@ -96,6 +99,7 @@ COMMON_LIB_FILES = \ $(top_srcdir)/src/libs/zbxsysinfo/agent/libagentsysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_httpmetrics.a \ $(top_srcdir)/src/libs/zbxlog/libzbxlog.a \ $(top_srcdir)/src/libs/zbxregexp/libzbxregexp.a \ $(top_srcdir)/src/libs/zbxalgo/libzbxalgo.a \ @@ -118,13 +122,12 @@ process_SOURCES = \ process.c \ ../../zbxmocktest.h -process_LDADD = $(COMMON_LIB_FILES) +process_LDADD = $(COMMON_LIB_FILES) \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_http.a \ + $(top_srcdir)/src/libs/zbxhttp/libzbxhttp.a process_WRAP_FUNCS = \ -Wl,--wrap=SYSTEM_LOCALTIME \ - -Wl,--wrap=WEB_PAGE_GET \ - -Wl,--wrap=WEB_PAGE_PERF \ - -Wl,--wrap=WEB_PAGE_REGEXP \ -Wl,--wrap=VFS_FILE_SIZE \ -Wl,--wrap=VFS_FILE_TIME \ -Wl,--wrap=VFS_FILE_EXISTS \ @@ -144,6 +147,25 @@ process_LDFLAGS = @AGENT_LDFLAGS@ $(process_WRAP_FUNCS) process_CFLAGS = -DZABBIX_DAEMON -I@top_srcdir@/tests +# process_http + +process_http_SOURCES = \ + process_http.c \ + ../../zbxmocktest.h + +process_http_LDADD = $(COMMON_LIB_FILES) + +process_http_WRAP_FUNCS = \ + -Wl,--wrap=WEB_PAGE_GET \ + -Wl,--wrap=WEB_PAGE_PERF \ + -Wl,--wrap=WEB_PAGE_REGEXP + +process_http_LDADD += @AGENT_LIBS@ + +process_http_LDFLAGS = @AGENT_LDFLAGS@ + +process_http_CFLAGS = $(process_http_WRAP_FUNCS) -I@top_srcdir@/tests + # check_key_access_rules check_key_access_rules_SOURCES = \ @@ -152,6 +174,7 @@ check_key_access_rules_SOURCES = \ check_key_access_rules_LDADD = $(COMMON_LIB_FILES) \ $(top_srcdir)/src/libs/zbxjson/libzbxjson.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_http.a \ $(top_srcdir)/src/libs/zbxhttp/libzbxhttp.a check_key_access_rules_LDADD += @AGENT_LIBS@ diff --git a/tests/libs/zbxsysinfo/common/Makefile.am b/tests/libs/zbxsysinfo/common/Makefile.am index d6f7fa874be..b66785e1c36 100644 --- a/tests/libs/zbxsysinfo/common/Makefile.am +++ b/tests/libs/zbxsysinfo/common/Makefile.am @@ -18,6 +18,8 @@ COMMON_LIB_FILES = \ $(top_srcdir)/src/libs/zbxsysinfo/agent/libagentsysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_httpmetrics.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_http.a \ $(top_srcdir)/src/libs/zbxlog/libzbxlog.a \ $(top_srcdir)/src/libs/zbxregexp/libzbxregexp.a \ $(top_srcdir)/src/libs/zbxalgo/libzbxalgo.a \ diff --git a/tests/libs/zbxsysinfo/linux/Makefile.am b/tests/libs/zbxsysinfo/linux/Makefile.am index 93ad477029f..38112ac4c52 100644 --- a/tests/libs/zbxsysinfo/linux/Makefile.am +++ b/tests/libs/zbxsysinfo/linux/Makefile.am @@ -26,6 +26,8 @@ COMMON_LIB_FILES = \ $(top_srcdir)/src/libs/zbxsysinfo/agent/libagentsysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_httpmetrics.a \ + $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_http.a \ $(top_srcdir)/src/libs/zbxlog/libzbxlog.a \ $(top_srcdir)/src/libs/zbxregexp/libzbxregexp.a \ $(top_srcdir)/src/libs/zbxalgo/libzbxalgo.a \ diff --git a/tests/libs/zbxsysinfo/process.c b/tests/libs/zbxsysinfo/process.c index c208b82ed56..048bd9dbc4e 100644 --- a/tests/libs/zbxsysinfo/process.c +++ b/tests/libs/zbxsysinfo/process.c @@ -29,9 +29,6 @@ static char *called_key = NULL; int __wrap_SYSTEM_LOCALTIME(const char *command, AGENT_RESULT *result); -int __wrap_WEB_PAGE_GET(const char *command, AGENT_RESULT *result); -int __wrap_WEB_PAGE_PERF(const char *command, AGENT_RESULT *result); -int __wrap_WEB_PAGE_REGEXP(const char *command, AGENT_RESULT *result); int __wrap_VFS_FILE_SIZE(const char *command, AGENT_RESULT *result); int __wrap_VFS_FILE_TIME(const char *command, AGENT_RESULT *result); int __wrap_VFS_FILE_EXISTS(const char *command, AGENT_RESULT *result); @@ -95,36 +92,6 @@ int __wrap_SYSTEM_LOCALTIME(const char *command, AGENT_RESULT *result) return SUCCEED; } -int __wrap_WEB_PAGE_GET(const char *command, AGENT_RESULT *result) -{ - ZBX_UNUSED(command); - ZBX_UNUSED(result); - - called_key = "web.page.get"; - - return SUCCEED; -} - -int __wrap_WEB_PAGE_PERF(const char *command, AGENT_RESULT *result) -{ - ZBX_UNUSED(command); - ZBX_UNUSED(result); - - called_key = "web.page.perf"; - - return SUCCEED; -} - -int __wrap_WEB_PAGE_REGEXP(const char *command, AGENT_RESULT *result) -{ - ZBX_UNUSED(command); - ZBX_UNUSED(result); - - called_key = "web.page.regexp"; - - return SUCCEED; -} - int __wrap_VFS_FILE_SIZE(const char *command, AGENT_RESULT *result) { ZBX_UNUSED(command); diff --git a/tests/libs/zbxsysinfo/process.yaml b/tests/libs/zbxsysinfo/process.yaml index 25181ebb6b8..49655beebed 100644 --- a/tests/libs/zbxsysinfo/process.yaml +++ b/tests/libs/zbxsysinfo/process.yaml @@ -4,21 +4,6 @@ in: in_command: system.localtime[utc] flags: 4 --- -test case: successfully called WEB_PAGE_GET function -in: - in_command: web.page.get[localhost,,80] - flags: 4 ---- -test case: successfully called WEB_PAGE_PERF function -in: - in_command: web.page.perf[localhost,,80] - flags: 4 ---- -test case: successfully called WEB_PAGE_REGEXP function -in: - in_command: web.page.regexp[localhost,,80,OK] - flags: 4 ---- test case: successfully called VFS_FILE_SIZE function in: in_command: vfs.file.size[/etc/passwd] diff --git a/tests/libs/zbxsysinfo/process_http.c b/tests/libs/zbxsysinfo/process_http.c new file mode 100644 index 00000000000..f29e35544af --- /dev/null +++ b/tests/libs/zbxsysinfo/process_http.c @@ -0,0 +1,99 @@ +/* +** Zabbix +** Copyright (C) 2001-2021 Zabbix SIA +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +**/ + +#include "zbxmocktest.h" +#include "zbxmockdata.h" + +#include "db.h" +#include "sysinfo.h" + +static char *called_key = NULL; + +int __wrap_WEB_PAGE_GET(const char *command, AGENT_RESULT *result); +int __wrap_WEB_PAGE_PERF(const char *command, AGENT_RESULT *result); +int __wrap_WEB_PAGE_REGEXP(const char *command, AGENT_RESULT *result); + +void zbx_mock_test_entry(void **state) +{ + zbx_mock_error_t error; + zbx_mock_handle_t in_command, in_flags; + const char *in_command_string, *flags_string, *p; + char key[ITEM_KEY_LEN]; + unsigned flags_uint32; + AGENT_RESULT result; + + ZBX_UNUSED(state); + + if (ZBX_MOCK_SUCCESS != (error = zbx_mock_in_parameter("in_command", &in_command)) || + ZBX_MOCK_SUCCESS != (error = zbx_mock_string(in_command, &in_command_string))) + { + fail_msg("Cannot get in_command from test case data: %s", zbx_mock_error_string(error)); + } + + if (ZBX_MOCK_SUCCESS != (error = zbx_mock_in_parameter("flags", &in_flags)) || + ZBX_MOCK_SUCCESS != (error = zbx_mock_string(in_flags, &flags_string))) + { + fail_msg("Cannot get flags from test case data: %s", zbx_mock_error_string(error)); + } + if (SUCCEED != is_uint32(flags_string, &flags_uint32)) + fail_msg("Cannot convert flags to unsigned 32 bit integer."); + + init_metrics(); + + process(in_command_string, flags_uint32, &result); + + if (NULL != (p = strchr(in_command_string, '['))) + zbx_strlcpy(key, in_command_string, p - in_command_string + 1); + + if (called_key == NULL || 0 != strcmp((NULL == p ? in_command_string : key), called_key)) + { + fail_msg("Unexpected called item '%s' instead of '%s' as a key.", + ZBX_NULL2STR(called_key), in_command_string); + } +} + +int __wrap_WEB_PAGE_GET(const char *command, AGENT_RESULT *result) +{ + ZBX_UNUSED(command); + ZBX_UNUSED(result); + + called_key = "web.page.get"; + + return SUCCEED; +} + +int __wrap_WEB_PAGE_PERF(const char *command, AGENT_RESULT *result) +{ + ZBX_UNUSED(command); + ZBX_UNUSED(result); + + called_key = "web.page.perf"; + + return SUCCEED; +} + +int __wrap_WEB_PAGE_REGEXP(const char *command, AGENT_RESULT *result) +{ + ZBX_UNUSED(command); + ZBX_UNUSED(result); + + called_key = "web.page.regexp"; + + return SUCCEED; +} diff --git a/tests/libs/zbxsysinfo/process_http.yaml b/tests/libs/zbxsysinfo/process_http.yaml new file mode 100644 index 00000000000..b2fd1b62caf --- /dev/null +++ b/tests/libs/zbxsysinfo/process_http.yaml @@ -0,0 +1,16 @@ +--- +test case: successfully called WEB_PAGE_GET function +in: + in_command: web.page.get[localhost,,80] + flags: 4 +--- +test case: successfully called WEB_PAGE_PERF function +in: + in_command: web.page.perf[localhost,,80] + flags: 4 +--- +test case: successfully called WEB_PAGE_REGEXP function +in: + in_command: web.page.regexp[localhost,,80,OK] + flags: 4 +... |