Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 112 additions & 58 deletions contrib/omhiredis/omhiredis.c

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions tests/omhiredis-dynakey.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ template(name="dynakey" type="string" string="%$!dynaKey%")
local4.* {
set $!dynaKey = "myDynaKey";
action(type="omhiredis"
name="omhiredis-dynakey"
server="127.0.0.1"
serverport="'$REDIS_RANDOM_PORT'"
mode="set"
Expand Down Expand Up @@ -51,6 +52,8 @@ export EXPECTED="/usr/bin/redis-cli

cmp_exact $RSYSLOG_OUT_LOG

content_check "omhiredis[omhiredis-dynakey]: trying connect to '127.0.0.1'" ${RSYSLOG_DYNNAME}.started

stop_redis

# Removes generated configuration file, log and pid files
Expand Down
42 changes: 42 additions & 0 deletions tests/omhiredis-name-blank.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
# added 2025-12-04 by Théo Bertin, released under ASL 2.0
## Uncomment for debugging
# export RS_REDIR=-d

. ${srcdir:=.}/diag.sh init

start_redis

generate_conf
add_conf '
global(localhostname="server")
module(load="../contrib/omhiredis/.libs/omhiredis")
template(name="outfmt" type="string" string="%msg%")

local4.* {
action(type="omhiredis"
server="127.0.0.1"
serverport="'$REDIS_RANDOM_PORT'"
mode="queue"
key="myKey"
template="outfmt")

stop
}
'

startup

injectmsg 1 1

shutdown_when_empty
wait_shutdown

content_check "omhiredis[(null)]:" ${RSYSLOG_DYNNAME}.started
check_not_present "omhiredis:" ${RSYSLOG_DYNNAME}.started
stop_redis

# Removes generated configuration file, log and pid files
cleanup_redis

exit_test
3 changes: 3 additions & 0 deletions tests/omhiredis-publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ template(name="outfmt" type="string" string="%msg%")

local4.* {
action(type="omhiredis"
name="omhiredis-publish"
server="127.0.0.1"
serverport="'$REDIS_RANDOM_PORT'"
mode="publish"
Expand Down Expand Up @@ -52,6 +53,8 @@ myChannel

cmp_exact $RSYSLOG_OUT_LOG

content_check "omhiredis[omhiredis-publish]: trying connect to '127.0.0.1'" ${RSYSLOG_DYNNAME}.started

stop_redis

# Removes generated configuration file, log and pid files
Expand Down
3 changes: 3 additions & 0 deletions tests/omhiredis-queue-rpush.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ template(name="outfmt" type="string" string="%msg%")

local4.* {
action(type="omhiredis"
name="omhiredis-queue-rpush"
server="127.0.0.1"
serverport="'$REDIS_RANDOM_PORT'"
mode="queue"
Expand Down Expand Up @@ -50,6 +51,8 @@ export EXPECTED="/usr/bin/redis-cli

cmp_exact $RSYSLOG_OUT_LOG

content_check "omhiredis[omhiredis-queue-rpush]: trying connect to '127.0.0.1'" ${RSYSLOG_DYNNAME}.started

stop_redis

# Removes generated configuration file, log and pid files
Expand Down
3 changes: 3 additions & 0 deletions tests/omhiredis-queue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ template(name="outfmt" type="string" string="%msg%")

local4.* {
action(type="omhiredis"
name="omhiredis-queue"
server="127.0.0.1"
serverport="'$REDIS_RANDOM_PORT'"
mode="queue"
Expand Down Expand Up @@ -54,6 +55,8 @@ export EXPECTED="/usr/bin/redis-cli

cmp_exact $RSYSLOG_OUT_LOG

content_check "omhiredis[omhiredis-queue]: trying connect to '127.0.0.1'" ${RSYSLOG_DYNNAME}.started

stop_redis

# Removes generated configuration file, log and pid files
Expand Down
3 changes: 3 additions & 0 deletions tests/omhiredis-set.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ template(name="outfmt" type="string" string="%msg%")

local4.* {
action(type="omhiredis"
name="omhiredis-set"
server="127.0.0.1"
serverport="'$REDIS_RANDOM_PORT'"
mode="set"
Expand Down Expand Up @@ -48,6 +49,8 @@ export EXPECTED="/usr/bin/redis-cli

cmp_exact $RSYSLOG_OUT_LOG

content_check "omhiredis[omhiredis-set]: trying connect to '127.0.0.1'" ${RSYSLOG_DYNNAME}.started

stop_redis

# Removes generated configuration file, log and pid files
Expand Down
3 changes: 3 additions & 0 deletions tests/omhiredis-setex.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ template(name="outfmt" type="string" string="%msg%")

local4.* {
action(type="omhiredis"
name="omhiredis-setex"
server="127.0.0.1"
serverport="'$REDIS_RANDOM_PORT'"
mode="set"
Expand Down Expand Up @@ -67,6 +68,8 @@ export EXPECTED="/usr/bin/redis-cli

cmp_exact $RSYSLOG_OUT_LOG

content_check "omhiredis[omhiredis-setex]: trying connect to '127.0.0.1'" ${RSYSLOG_DYNNAME}.started

stop_redis

# Removes generated configuration file, log and pid files
Expand Down
4 changes: 4 additions & 0 deletions tests/omhiredis-stream-ack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ template(name="outfmt" type="string" string="%msg%")

local4.* {
action(type="omhiredis"
name="omhiredis-stream-ack"
server="127.0.0.1"
serverport="'$REDIS_RANDOM_PORT'"
mode="stream"
Expand Down Expand Up @@ -89,6 +90,9 @@ lag

cmp_exact $RSYSLOG_OUT_LOG

content_check "omhiredis[omhiredis-stream-ack]: no stream.outField set, using 'msg' as default" ${RSYSLOG_DYNNAME}.started
content_check "omhiredis[omhiredis-stream-ack]: trying connect to '127.0.0.1'" ${RSYSLOG_DYNNAME}.started

stop_redis

# Removes generated configuration file, log and pid files
Expand Down
4 changes: 4 additions & 0 deletions tests/omhiredis-stream-capped.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ template(name="outfmt" type="string" string="%msg%")

local4.* {
action(type="omhiredis"
name="omhiredis-stream-capped"
server="127.0.0.1"
serverport="'$REDIS_RANDOM_PORT'"
mode="stream"
Expand Down Expand Up @@ -45,6 +46,9 @@ if [ ! "${count}" -le 500 ]; then
error_exit 1
fi

content_check "omhiredis[omhiredis-stream-capped]: no stream.outField set, using 'msg' as default" ${RSYSLOG_DYNNAME}.started
content_check "omhiredis[omhiredis-stream-capped]: trying connect to '127.0.0.1'" ${RSYSLOG_DYNNAME}.started

stop_redis

# Removes generated configuration file, log and pid files
Expand Down
4 changes: 4 additions & 0 deletions tests/omhiredis-stream-del.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ template(name="outfmt" type="string" string="%msg%")

local4.* {
action(type="omhiredis"
name="omhiredis-stream-del"
server="127.0.0.1"
serverport="'$REDIS_RANDOM_PORT'"
mode="stream"
Expand Down Expand Up @@ -62,6 +63,9 @@ value

cmp_exact $RSYSLOG_OUT_LOG

content_check "omhiredis[omhiredis-stream-del]: no stream.outField set, using 'msg' as default " ${RSYSLOG_DYNNAME}.started
content_check "omhiredis[omhiredis-stream-del]: trying connect to '127.0.0.1'" ${RSYSLOG_DYNNAME}.started

stop_redis

# Removes generated configuration file, log and pid files
Expand Down
4 changes: 4 additions & 0 deletions tests/omhiredis-stream-dynack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ local4.* {
set $.redis!group = "myGroup";
set $.redis!index = "2-0";
action(type="omhiredis"
name="omhiredis-stream-ack"
server="127.0.0.1"
serverport="'$REDIS_RANDOM_PORT'"
mode="stream"
Expand Down Expand Up @@ -99,6 +100,9 @@ lag

cmp_exact $RSYSLOG_OUT_LOG

content_check "omhiredis[omhiredis-stream-ack]: no stream.outField set, using 'msg' as default" ${RSYSLOG_DYNNAME}.started
content_check "omhiredis[omhiredis-stream-ack]: trying connect to '127.0.0.1'" ${RSYSLOG_DYNNAME}.started

stop_redis

# Removes generated configuration file, log and pid files
Expand Down
3 changes: 3 additions & 0 deletions tests/omhiredis-stream-outfield.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ template(name="outfmt" type="string" string="%msg%")

local4.* {
action(type="omhiredis"
name="omhiredis-stream-outfield"
server="127.0.0.1"
serverport="'$REDIS_RANDOM_PORT'"
mode="stream"
Expand Down Expand Up @@ -49,6 +50,8 @@ content_count_check "custom_field" 2 $RSYSLOG_OUT_LOG
content_count_check "msg" 2 $RSYSLOG_OUT_LOG
content_count_check "msgnum" 2 $RSYSLOG_OUT_LOG

content_check "omhiredis[omhiredis-stream-outfield]: trying connect to '127.0.0.1'" ${RSYSLOG_DYNNAME}.started

stop_redis

# Removes generated configuration file, log and pid files
Expand Down
4 changes: 4 additions & 0 deletions tests/omhiredis-stream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ template(name="outfmt" type="string" string="%msg%")

local4.* {
action(type="omhiredis"
name="omhiredis-stream"
server="127.0.0.1"
serverport="'$REDIS_RANDOM_PORT'"
mode="stream"
Expand Down Expand Up @@ -55,6 +56,9 @@ content_count_check " msgnum:00000002:" 1 $RSYSLOG_OUT_LOG
content_count_check "msg" 4 $RSYSLOG_OUT_LOG
content_count_check "msgnum" 2 $RSYSLOG_OUT_LOG

content_check "omhiredis[omhiredis-stream]: no stream.outField set, using 'msg' as default" ${RSYSLOG_DYNNAME}.started
content_check "omhiredis[omhiredis-stream]: trying connect to '127.0.0.1'" ${RSYSLOG_DYNNAME}.started

stop_redis

# Removes generated configuration file, log and pid files
Expand Down
3 changes: 3 additions & 0 deletions tests/omhiredis-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ template(name="redis_command" type="string" string="INCRBY counter 3")

local4.* {
action(type="omhiredis"
name="omhiredis-template"
server="127.0.0.1"
serverport="'$REDIS_RANDOM_PORT'"
mode="template"
Expand Down Expand Up @@ -48,6 +49,8 @@ export EXPECTED="/usr/bin/redis-cli

cmp_exact $RSYSLOG_OUT_LOG

content_check "omhiredis[omhiredis-template]: trying connect to '127.0.0.1'" ${RSYSLOG_DYNNAME}.started

stop_redis

# Removes generated configuration file, log and pid files
Expand Down
3 changes: 3 additions & 0 deletions tests/omhiredis-withpass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ template(name="outfmt" type="string" string="%msg%")

local4.* {
action(type="omhiredis"
name="omhiredis-withpass"
server="127.0.0.1"
serverport="'$REDIS_RANDOM_PORT'"
serverpassword="'${REDIS_PASSWORD}'"
Expand Down Expand Up @@ -55,6 +56,8 @@ OK

cmp_exact $RSYSLOG_OUT_LOG

content_check "omhiredis[omhiredis-withpass]: trying connect to '127.0.0.1'" ${RSYSLOG_DYNNAME}.started

stop_redis

# Removes generated configuration file, log and pid files
Expand Down
7 changes: 4 additions & 3 deletions tests/omhiredis-wrongpass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ template(name="outfmt" type="string" string="%msg%")

local4.* {
action(type="omhiredis"
name="omhiredis-wrongpass"
server="127.0.0.1"
serverport="'$REDIS_RANDOM_PORT'"
serverpassword="ThatsNotMyPassword"
Expand All @@ -27,8 +28,6 @@ local4.* {
template="outfmt")
stop
}

action(type="omfile" file="'$RSYSLOG_OUT_LOG'" template="outfmt")
'

startup
Expand All @@ -39,7 +38,9 @@ injectmsg 1 1
shutdown_when_empty
wait_shutdown

content_check "error while authenticating: WRONGPASS invalid username-password pair or user is disabled." $RSYSLOG_OUT_LOG
content_check "omhiredis[omhiredis-wrongpass]: trying connect to '127.0.0.1'" ${RSYSLOG_DYNNAME}.started
content_check "omhiredis[omhiredis-wrongpass]: error while authenticating: WRONGPASS invalid username-password pair or user is disabled." ${RSYSLOG_DYNNAME}.started


stop_redis

Expand Down
Loading