Skip to content

Commit

Permalink
OMHIREDIS::ADDED:: new tests for existing functionalities
Browse files Browse the repository at this point in the history
  • Loading branch information
frikilax committed May 23, 2023
1 parent d59ba56 commit 4fa2967
Show file tree
Hide file tree
Showing 19 changed files with 630 additions and 1 deletion.
30 changes: 29 additions & 1 deletion tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ endif # HAVE_VALGRIND
endif # ENABLE_OMRABBITMQ

if ENABLE_REDIS_TESTS

if ENABLE_IMHIREDIS
TESTS += \
imhiredis-queue.sh \
imhiredis-queue-lpop.sh \
Expand All @@ -1065,6 +1065,34 @@ TESTS += \
imhiredis-stream-consumerGroup-noack-vg.sh \
imhiredis-stream-consumerGroup-reclaim-vg.sh
endif # HAVE_VALGRIND
endif # ENABLE_IMHIREDIS

if ENABLE_OMHIREDIS
TESTS += \
mmdb-reload.sh \
omhiredis-dynakey.sh \
omhiredis-publish.sh \
omhiredis-queue-rpush.sh \
omhiredis-queue.sh \
omhiredis-set.sh \
omhiredis-setex.sh \
omhiredis-template.sh \
omhiredis-withpass.sh \
omhiredis-wrongpass.sh \
if HAVE_VALGRIND
TESTS += \
mmdb-reload-vg.sh \
omhiredis-dynakey-vg.sh \
omhiredis-publish-vg.sh \
omhiredis-queue-rpush-vg.sh \
omhiredis-queue-vg.sh \
omhiredis-set-vg.sh \
omhiredis-setex-vg.sh \
omhiredis-template-vg.sh \
omhiredis-withpass-vg.sh \
omhiredis-wrongpass-vg.sh \
endif # HAVE_VALGRIND
endif # ENABLE_OMHIREDIS
endif # ENABLE_REDIS_TESTS

if ENABLE_IMPSTATS
Expand Down
7 changes: 7 additions & 0 deletions tests/omhiredis-dynakey-vg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# added 2023-04-20 by Théo Bertin, released under ASL 2.0
## Uncomment for debugging
#export RS_REDIR=-d

export USE_VALGRIND="YES"
source ${srcdir:=.}/omhiredis-dynakey.sh
59 changes: 59 additions & 0 deletions tests/omhiredis-dynakey.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
# added 2023-04-20 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%")
template(name="dynakey" type="string" string="%$!dynaKey%")
local4.* {
set $!dynaKey = "myDynaKey";
action(type="omhiredis"
server="127.0.0.1"
serverport="'$REDIS_RANDOM_PORT'"
mode="set"
dynakey="on"
key="dynakey"
template="outfmt")
stop
}
action(type="omfile" file="'$RSYSLOG_DYNNAME.othermsg'" template="outfmt")
'

# Should get nothing
redis_command "GET myDynaKey" > $RSYSLOG_OUT_LOG

startup

# Inject 1 message
injectmsg 1 1

shutdown_when_empty
wait_shutdown

# Should get ' msgnum:00000001:'
redis_command "GET myDynaKey" >> $RSYSLOG_OUT_LOG

# The first get is before inserting, the second is after
export EXPECTED="/usr/bin/redis-cli
/usr/bin/redis-cli
msgnum:00000001:"

cmp_exact $RSYSLOG_OUT_LOG

stop_redis

# Removes generated configuration file, log and pid files
cleanup_redis

exit_test
7 changes: 7 additions & 0 deletions tests/omhiredis-publish-vg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# added 2023-04-20 by Théo Bertin, released under ASL 2.0
## Uncomment for debugging
#export RS_REDIR=-d

export USE_VALGRIND="YES"
source ${srcdir:=.}/omhiredis-publish.sh
60 changes: 60 additions & 0 deletions tests/omhiredis-publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
# added 2023-04-20 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="publish"
key="myChannel"
template="outfmt")
stop
}
action(type="omfile" file="'$RSYSLOG_DYNNAME.othermsg'" template="outfmt")
'
(redis_command "SUBSCRIBE myChannel" > $RSYSLOG_OUT_LOG) &

startup

# Inject 3 messages
injectmsg 1 3

shutdown_when_empty
wait_shutdown

# The SUBSCRIBE command gets the result of the subscribing and the 3 subsequent messages published by omhiredis
export EXPECTED="/usr/bin/redis-cli
subscribe
myChannel
1
message
myChannel
msgnum:00000001:
message
myChannel
msgnum:00000002:
message
myChannel
msgnum:00000003:"

cmp_exact $RSYSLOG_OUT_LOG

stop_redis

# Removes generated configuration file, log and pid files
cleanup_redis

exit_test
7 changes: 7 additions & 0 deletions tests/omhiredis-queue-rpush-vg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# added 2023-04-20 by Théo Bertin, released under ASL 2.0
## Uncomment for debugging
#export RS_REDIR=-d

export USE_VALGRIND="YES"
source ${srcdir:=.}/omhiredis-queue-rpush.sh
58 changes: 58 additions & 0 deletions tests/omhiredis-queue-rpush.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env bash
# added 2023-04-20 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"
userpush="on"
key="myKey"
template="outfmt")
stop
}
action(type="omfile" file="'$RSYSLOG_DYNNAME.othermsg'" template="outfmt")
'
startup

# Inject 5 messages
injectmsg 1 5

shutdown_when_empty
wait_shutdown

redis_command "LLEN myKey" > $RSYSLOG_OUT_LOG
# try to get 6 (should get only 5)
redis_command "LPOP myKey 6" >> $RSYSLOG_OUT_LOG

# Messages should be retrieved in order (as they were inserted using RPUSH)
export EXPECTED="/usr/bin/redis-cli
5
/usr/bin/redis-cli
msgnum:00000001:
msgnum:00000002:
msgnum:00000003:
msgnum:00000004:
msgnum:00000005:"

cmp_exact $RSYSLOG_OUT_LOG

stop_redis

# Removes generated configuration file, log and pid files
cleanup_redis

exit_test
7 changes: 7 additions & 0 deletions tests/omhiredis-queue-vg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# added 2023-04-20 by Théo Bertin, released under ASL 2.0
## Uncomment for debugging
#export RS_REDIR=-d

export USE_VALGRIND="YES"
source ${srcdir:=.}/omhiredis-queue.sh
62 changes: 62 additions & 0 deletions tests/omhiredis-queue.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
# added 2023-04-20 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
}
action(type="omfile" file="'$RSYSLOG_DYNNAME.othermsg'" template="outfmt")
'
startup

# Inject 10 messages
injectmsg 1 10

shutdown_when_empty
wait_shutdown

redis_command "LLEN myKey" > $RSYSLOG_OUT_LOG
# try to get 11 (should get only 10)
redis_command "LPOP myKey 11" >> $RSYSLOG_OUT_LOG

# Messages should be retrieved in reverse order (as they were inserted using LPUSH)
export EXPECTED="/usr/bin/redis-cli
10
/usr/bin/redis-cli
msgnum:00000010:
msgnum:00000009:
msgnum:00000008:
msgnum:00000007:
msgnum:00000006:
msgnum:00000005:
msgnum:00000004:
msgnum:00000003:
msgnum:00000002:
msgnum:00000001:"

cmp_exact $RSYSLOG_OUT_LOG

stop_redis

# Removes generated configuration file, log and pid files
cleanup_redis

exit_test
7 changes: 7 additions & 0 deletions tests/omhiredis-set-vg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# added 2023-04-20 by Théo Bertin, released under ASL 2.0
## Uncomment for debugging
#export RS_REDIR=-d

export USE_VALGRIND="YES"
source ${srcdir:=.}/omhiredis-set.sh
56 changes: 56 additions & 0 deletions tests/omhiredis-set.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash
# added 2023-04-20 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="set"
key="outKey"
template="outfmt")
stop
}
action(type="omfile" file="'$RSYSLOG_DYNNAME.othermsg'" template="outfmt")
'

# Should get nothing
redis_command "GET outKey" > $RSYSLOG_OUT_LOG

startup

# Inject 1 message
injectmsg 1 1

shutdown_when_empty
wait_shutdown

# Should get ' msgnum:00000001:'
redis_command "GET outKey" >> $RSYSLOG_OUT_LOG

# The first get is before inserting, the second is after
export EXPECTED="/usr/bin/redis-cli
/usr/bin/redis-cli
msgnum:00000001:"

cmp_exact $RSYSLOG_OUT_LOG

stop_redis

# Removes generated configuration file, log and pid files
cleanup_redis

exit_test
7 changes: 7 additions & 0 deletions tests/omhiredis-setex-vg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# added 2023-04-20 by Théo Bertin, released under ASL 2.0
## Uncomment for debugging
#export RS_REDIR=-d

export USE_VALGRIND="YES"
source ${srcdir:=.}/omhiredis-setex.sh

0 comments on commit 4fa2967

Please sign in to comment.