-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OMHIREDIS::ADDED:: new tests for existing functionalities
- Loading branch information
Showing
19 changed files
with
630 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.