Debian Codegraph @

tests/omhiredis-publish.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2 # added 2023-04-20 by Théo Bertin, released under ASL 2.0
3 ## Uncomment for debugging
4 # export RS_REDIR=-d
5
6 . ${srcdir:=.}/diag.sh init
7
8 start_redis
9
10 generate_conf
11 add_conf '
12 global(localhostname="server")
13 module(load="../contrib/omhiredis/.libs/omhiredis")
14 template(name="outfmt" type="string" string="%msg%")
15
16 local4.* {
17 action(type="omhiredis"
18 name="omhiredis-publish"
19 server="127.0.0.1"
20 serverport="'$REDIS_RANDOM_PORT'"
21 mode="publish"
22 key="myChannel"
23 template="outfmt")
24 stop
25 }
26
27 action(type="omfile" file="'$RSYSLOG_DYNNAME.othermsg'" template="outfmt")
28 '
29 (redis_command "SUBSCRIBE myChannel" > $RSYSLOG_OUT_LOG) &
30
31 startup
32
33 # Inject 3 messages
34 injectmsg 1 3
35
36 shutdown_when_empty
37 wait_shutdown
38
39 # The SUBSCRIBE command gets the result of the subscribing and the 3 subsequent messages published by omhiredis
40 export EXPECTED="subscribe
41 myChannel
42 1
43 message
44 myChannel
45 msgnum:00000001:
46 message
47 myChannel
48 msgnum:00000002:
49 message
50 myChannel
51 msgnum:00000003:"
52
53 cmp_exact $RSYSLOG_OUT_LOG
54
55 content_check "omhiredis[omhiredis-publish]: trying connect to '127.0.0.1'" ${RSYSLOG_DYNNAME}.started
56
57 stop_redis
58
59 # Removes generated configuration file, log and pid files
60 cleanup_redis
61
62 exit_test