Debian Codegraph @

tests/dynstats_prevent_premature_eviction-vg.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # added 2016-04-13 by singh.janmejay
3 # This file is part of the rsyslog project, released under ASL 2.0
4 echoscip-shell system . . echo. ===============================================================================
5 echoscip-shell system . . echo. \[dynstats_prevent_premature_eviction-vg.sh\]: test for ensuring metrics are not evicted before unused-ttl with valgrind
6 . ${srcdir:=.}/diag.sh init
7 generate_conf
8 add_conf '
9 ruleset(name="stats") {
10 action(type="omfile" file="'${RSYSLOG_DYNNAME}'.out.stats.log")
11 }
12
13 module(load="../plugins/impstats/.libs/impstats" interval="4" severity="7" resetCounters="on" Ruleset="stats" bracketing="on")
14
15 template(name="outfmt" type="string" string="%msg% %$.increment_successful%\n")
16
17 dyn_stats(name="msg_stats" unusedMetricLife="1" resettable="off")
18
19 set $.msg_prefix = field($msg, 32, 1);
20
21 if (re_match($.msg_prefix, "foo|bar|baz|quux|corge|grault")) then {
22 set $.increment_successful = dyn_inc("msg_stats", $.msg_prefix);
23 } else {
24 set $.increment_successful = -1;
25 }
26
27 action(type="omfile" file=`echo $RSYSLOG_OUT_LOG` template="outfmt")
28 '
29 startup_vg
30 wait_for_stats_flush ${RSYSLOG_DYNNAME}.out.stats.log
31 . $srcdir/diag.sh block-stats-flush
32 injectmsg_file $srcdir/testsuites/dynstats_input_1
33 . $srcdir/diag.sh allow-single-stats-flush-after-block-and-wait-for-it
34 injectmsg_file $srcdir/testsuites/dynstats_input_2
35 . $srcdir/diag.sh allow-single-stats-flush-after-block-and-wait-for-it
36 injectmsg_file $srcdir/testsuites/dynstats_input_3
37 . $srcdir/diag.sh await-stats-flush-after-block
38 wait_queueempty
39 wait_for_stats_flush ${RSYSLOG_DYNNAME}.out.stats.log
40 content_check "foo 001 0"
41 content_check "foo 006 0"
42 echoscip-shell system . . echo. doing shutdown
43 shutdown_when_empty
44 echoscip-shell system . . echo. wait on shutdown
45 wait_shutdown_vg
46 check_exit_vg
47 # because dyn-accumulators for existing metrics were posted-to under a second, they should not have been evicted
48 custom_content_check 'baz=2' "${RSYSLOG_DYNNAME}.out.stats.log"
49 custom_content_check 'bar=1' "${RSYSLOG_DYNNAME}.out.stats.log"
50 custom_content_check 'foo=3' "${RSYSLOG_DYNNAME}.out.stats.log"
51 # sum is high because accumulators were never reset, and we expect them to last specific number of cycles(when we posted before ttl expiry)
52 first_column_sum_check 's/.*foo=\([0-9]*\)/\1/g' 'foo=' "${RSYSLOG_DYNNAME}.out.stats.log" 6
53 first_column_sum_check 's/.*bar=\([0-9]*\)/\1/g' 'bar=' "${RSYSLOG_DYNNAME}.out.stats.log" 1
54 first_column_sum_check 's/.*baz=\([0-9]*\)/\1/g' 'baz=' "${RSYSLOG_DYNNAME}.out.stats.log" 3
55 first_column_sum_check 's/.*new_metric_add=\([0-9]*\)/\1/g' 'new_metric_add=' "${RSYSLOG_DYNNAME}.out.stats.log" 3
56 first_column_sum_check 's/.*ops_overflow=\([0-9]*\)/\1/g' 'ops_overflow=' "${RSYSLOG_DYNNAME}.out.stats.log" 0
57 first_column_sum_check 's/.*no_metric=\([0-9]*\)/\1/g' 'no_metric=' "${RSYSLOG_DYNNAME}.out.stats.log" 0
58 exit_test