mirror of
https://github.com/rsyslog/rsyslog.git
synced 2026-04-23 14:58:14 +02:00
Modernize the manon / mmnormalize test suite to remove legacy backtick-based expansion and align with current shell best practices. This reduces overhead and improves maintainability, especially in CI and containerized environments. Impact: test behavior may change in edge quoting cases. BEFORE: tests used `echo $VAR` via backticks, spawning shells. AFTER: tests use direct '$VAR' expansion without subshells. The update replaces command substitution patterns used to populate file paths and parameters with direct variable expansion. This avoids per-expansion process forks and keeps evaluation within the shell, improving performance and readability. Care is taken to preserve quoting semantics where variables are passed to rsyslog configs. No rsyslog runtime behavior is changed; only test execution mechanics are affected. Refs: https://github.com/rsyslog/rsyslog/issues/6523
30 lines
1.1 KiB
Bash
Executable File
30 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# added 2014-11-17 by singh.janmejay
|
|
# This file is part of the rsyslog project, released under ASL 2.0
|
|
echo ===============================================================================
|
|
echo \[mmdb.sh\]: test for mmdb
|
|
# uncomment for debugging support:
|
|
#export RSYSLOG_DEBUG="debug nostdout"
|
|
#export RSYSLOG_DEBUGLOG="log"
|
|
. ${srcdir:=.}/diag.sh init
|
|
generate_conf
|
|
add_conf '
|
|
template(name="outfmt" type="string" string="%$!iplocation%\n")
|
|
|
|
module(load="../plugins/mmdblookup/.libs/mmdblookup")
|
|
module(load="../plugins/mmnormalize/.libs/mmnormalize")
|
|
module(load="../plugins/imptcp/.libs/imptcp")
|
|
input(type="imptcp" port="0" listenPortFileName="'$RSYSLOG_DYNNAME'.tcpflood_port" ruleset="testing")
|
|
|
|
ruleset(name="testing") {
|
|
action(type="mmnormalize" rulebase="'$srcdir/mmdb.rb'")
|
|
action(type="mmdblookup" mmdbfile="'$srcdir/test.mmdb'" key="$!ip" fields="city" )
|
|
action(type="omfile" file="'$RSYSLOG_OUT_LOG'" template="outfmt")
|
|
}'
|
|
startup
|
|
tcpflood -m 1 -j "202.106.0.20\ "
|
|
shutdown_when_empty
|
|
wait_shutdown
|
|
content_check '{ "city": "Beijing" }'
|
|
exit_test
|