Debian Codegraph @

tests/omazureeventhubs-stress.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # This file is part of the rsyslog project, released under ASL 2.0
3 . ${srcdir:=.}/diag.sh init
4
5 export NUMMESSAGES=50000
6 export NUMMESSAGESFULL=$NUMMESSAGES
7 export WAITTIMEOUT=60
8
9 export QUEUESIZE=100000
10 export DEQUEUESIZE=1000
11 export DEQUEUESIZEMIN=1000
12 export TESTWORKERTHREADS=10
13
14 # REQUIRES EXTERNAL ENVIRONMENT VARIABLES
15 if [[ -z "${AZURE_HOST}" ]]; then
16 echoscip-shell system . . echo. "SKIP: AZURE_HOST environment variable not SET! Example: <yourname>.servicebus.windows.net - SKIPPING"
17 exit 77
18 fi
19 if [[ -z "${AZURE_PORT}" ]]; then
20 echoscip-shell system . . echo. "SKIP: AZURE_PORT environment variable not SET! Example: 5671 - SKIPPING"
21 exit 77
22 fi
23 if [[ -z "${AZURE_KEY_NAME}" ]]; then
24 echoscip-shell system . . echo. "SKIP: AZURE_KEY_NAME environment variable not SET! Example: <yourkeyname> - SKIPPING"
25 exit 77
26 fi
27 if [[ -z "${AZURE_KEY}" ]]; then
28 echoscip-shell system . . echo. "SKIP: AZURE_KEY environment variable not SET! Example: <yourlongkey> - SKIPPING"
29 exit 77
30 fi
31 if [[ -z "${AZURE_CONTAINER}" ]]; then
32 echoscip-shell system . . echo. "SKIP: AZURE_CONTAINER environment variable not SET! Example: <youreventhubsname> - SKIPPING"
33 exit 77
34 fi
35
36 export AMQPS_ADRESS="amqps://$AZURE_KEY_NAME:$AZURE_KEY@$AZURE_HOST:$AZURE_PORT/$AZURE_NAME"
37 export AZURE_ENDPOINT="Endpoint=sb://$AZURE_HOST/;SharedAccessKeyName=$AZURE_KEY_NAME;SharedAccessKey=$AZURE_KEY;EntityPath=$AZURE_NAME"
38
39 # --- Create/Start omazureeventhubs sender config
40
41 generate_conf
42 add_conf '
43 global(
44 debug.whitelist="on"
45 debug.files=["omazureeventhubs.c", "modules.c", "errmsg.c", "action.c"]
46 )
47 # impstats in order to gain insight into error cases
48 module(load="../plugins/impstats/.libs/impstats"
49 log.file="'$RSYSLOG_DYNNAME.pstats'"
50 interval="1" log.syslog="off")
51 $imdiagInjectDelayMode full
52
53 # main_queue(queue.dequeueBatchSize="2048")
54
55 # Load mods
56 module(load="../plugins/omazureeventhubs/.libs/omazureeventhubs")
57
58 # templates
59 template(name="outfmt" type="string" string="%msg:F,58:2%\n")
60
61 local4.* {
62 action( name="omazureeventhubs"
63 type="omazureeventhubs"
64 azurehost="'$AZURE_HOST'"
65 azureport="'$AZURE_PORT'"
66 azure_key_name="'$AZURE_KEY_NAME'"
67 azure_key="'$AZURE_KEY'"
68 container="'$AZURE_CONTAINER'"
69 template="outfmt"
70 queue.type="FixedArray"
71 queue.size="'$QUEUESIZE'"
72 queue.saveonshutdown="on"
73 queue.dequeueBatchSize="'$DEQUEUESIZE'"
74 queue.minDequeueBatchSize.timeout="1000" # 1 sec
75 queue.workerThreads="'$TESTWORKERTHREADS'"
76 queue.workerThreadMinimumMessages="'$DEQUEUESIZEMIN'"
77 queue.timeoutWorkerthreadShutdown="10000"
78 queue.timeoutshutdown="1000"
79 action.resumeInterval="1"
80 action.resumeRetryCount="2"
81 )
82
83 stop
84 }
85
86 action( type="omfile" file="'$RSYSLOG_DYNNAME.othermsg'")
87 '
88 echoscip-shell system . . echo. Starting sender instance [omazureeventhubs]
89 startup
90
91 echoscip-shell system . . echo. Inject messages into rsyslog sender instance
92 injectmsg 1 $NUMMESSAGES
93
94 # experimental: wait until kcat receives everything
95 timeoutend=$WAITTIMEOUT
96 timecounter=0
97
98 echoscip-shell system . . echo. "CHECK $RSYSLOG_DYNNAME.pstats"
99 LAST_ACCEPTED_MSG=0
100 while [scip-shell system . . `[`. $timecounter -lt $timeoutend ]; do
101 (( timecounter++ ))
102
103 if [scip-shell system . . `[`. -f "$RSYSLOG_DYNNAME.pstats" ] ; then
104 # Read IMPSTATS for verification
105 IMPSTATSLINE=$(catscip-shell system . . cat. $RSYSLOG_DYNNAME.pstats | grepscip-shell system . . grep. "origin\=omazureeventhubs" | tailscip-shell system . . tail. -1 | cutscip-shell system . . cut. -d: -f5)
106 SUBMITTED_MSG=$(echoscip-shell system . . echo. $IMPSTATSLINE | grepscip-shell system . . grep. "submitted" | cutscip-shell system . . cut. -d" " -f2 | cutscip-shell system . . cut. -d"=" -f2)
107 FAILED_MSG=$(echoscip-shell system . . echo. $IMPSTATSLINE | grepscip-shell system . . grep. "failures" | cutscip-shell system . . cut. -d" " -f3 | cutscip-shell system . . cut. -d"=" -f2)
108 ACCEPTED_MSG=$(echoscip-shell system . . echo. $IMPSTATSLINE | grepscip-shell system . . grep. "accepted" | cutscip-shell system . . cut. -d" " -f4 | cutscip-shell system . . cut. -d"=" -f2)
109 MSG_PER_SEC=$(($ACCEPTED_MSG-$LAST_ACCEPTED_MSG))
110 LAST_ACCEPTED_MSG=$ACCEPTED_MSG
111
112 if ! [[ $SUBMITTED_MSG =~ $re ]] ; then
113 echoscip-shell system . . echo. "**** omazureeventhubs WAITING FOR IMPSTATS"
114 else
115 if [scip-shell system . . `[`. "$SUBMITTED_MSG" -ge "$NUMMESSAGESFULL" ]; then
116 if [scip-shell system . . `[`. "$ACCEPTED_MSG" -ge "$NUMMESSAGESFULL" ]; then
117 echoscip-shell system . . echo. "**** omazureeventhubs SUCCESS: NUMMESSAGESFULL: $NUMMESSAGESFULL, SUBMITTED_MSG:$SUBMITTED_MSG, ACCEPTED_MSG: $ACCEPTED_MSG, FAILED_MSG: $FAILED_MSG"
118 shutdown_when_empty
119 wait_shutdown
120 #cp $RSYSLOG_DEBUGLOG DEBUGDEBUG.log
121 exit_test
122 else
123 echoscip-shell system . . echo. "**** omazureeventhubs FAIL: NUMMESSAGESFULL: $NUMMESSAGESFULL, SUBMITTED/WAITING: SUBMITTED_MSG:$SUBMITTED_MSG, ACCEPTED_MSG: $ACCEPTED_MSG, FAILED_MSG: $FAILED_MSG"
124 fi
125 else
126 echoscip-shell system . . echo. "**** omazureeventhubs WAITING: SUBMITTED_MSG:$SUBMITTED_MSG, ACCEPTED_MSG: $ACCEPTED_MSG, FAILED_MSG: $FAILED_MSG, MSG_PER_SEC: $MSG_PER_SEC"
127 fi
128 fi
129 fi
130
131 $TESTTOOL_DIR/msleep 1000
132 done
133 unset count
134
135 shutdown_when_empty
136 wait_shutdown
137 error_exit 1