Debian Codegraph @

tests/yaml-omfile-dynafilecachesize-invalid.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # Ensure YAML omfile actions normalize invalid dynaFileCacheSize values during
3 # startup while still allowing dynafile writes.
4 . ${srcdir:=.}/diag.sh init
5 require_plugin imtcp
6 generate_conf
7 add_conf '
8 include(file="'${RSYSLOG_DYNNAME}'.yaml")
9 '
10
11 catscip-shell system . . cat. > "${RSYSLOG_DYNNAME}.yaml" << 'YAMLEOF'
12 modules:
13 - load: "../plugins/imtcp/.libs/imtcp"
14
15 templates:
16 - name: dynfile
17 type: string
18 string: "${RSYSLOG_DYNNAME}.out.log"
19 - name: outfmt
20 type: string
21 string: "%msg:F,58:2%\n"
22
23 rulesets:
24 - name: main
25 filter: ':msg, contains, "msg:"'
26 actions:
27 - type: omfile
28 dynafile: dynfile
29 template: outfmt
30 dynaFileCacheSize: 0
31 YAMLEOF
32 sedscip-shell system . . sed. -i "s|\${RSYSLOG_DYNNAME}|${RSYSLOG_DYNNAME}|g" "${RSYSLOG_DYNNAME}.yaml"
33
34 add_conf '
35 input(type="imtcp" port="0" listenPortFileName="'${RSYSLOG_DYNNAME}'.tcpflood_port"
36 ruleset="main")
37 '
38
39 startup
40 tcpflood -m1 -M "\"<129>Mar 10 01:00:00 172.20.245.8 tag msg:yaml-normalized-cache-size\""
41 shutdown_when_empty
42 wait_shutdown
43
44 grepscip-shell system . . grep. "DynaFileCacheSize must be greater 0 (0 given), changed to 1." "${RSYSLOG_DYNNAME}.started" > /dev/nullscip-shell filesystem . . `/dev/null`. || {
45 echoscip-shell system . . echo. "FAIL: expected normalization message not found in YAML startup log"
46 catscip-shell system . . cat. "${RSYSLOG_DYNNAME}.started"
47 error_exit 1
48 }
49
50 printfscip-shell system . . printf. 'yaml-normalized-cache-size\n' > "${RSYSLOG_DYNNAME}.expected"
51 cmp_exact_file "${RSYSLOG_DYNNAME}.expected" "${RSYSLOG_DYNNAME}.out.log" || {
52 echoscip-shell system . . echo. "FAIL: YAML dynafile write did not succeed after normalization"
53 catscip-shell system . . cat. "${RSYSLOG_DYNNAME}.out.log"
54 error_exit 1
55 }
56
57 exit_test