3 TRACE="--trace-ascii curl_log.txt"
4 SERVER=`cat .httpServer`
14 calc () { echo "$1" | bc -l ; }
17 limpio=$(calc "scale=0;${1}/1")
18 [[ $limpio != $1 ]] && salir "Invalid value '$1'. Must be integer"
23 echo "Load tests configuration script"
25 echo "Use: $0 <action: clear | load | start | push | pop | stop | resume | repeat | send | goto | look> [action parameters]"
28 echo " Clears all loaded burst messages."
30 echo " load <amount> <traffic type: mms | sms | voice | data | content>:"
31 echo " Loads 'amount' messages for the provided traffic type. For example:"
32 echo " $0 load 2000 sms"
34 echo " start [initial launch: default $burstMargin__dflt]:"
35 echo " Starts the message sending from the begining of the burst list loaded,"
36 echo " with a certain initial load. For example:"
39 echo " push [amount: default $burstMargin__dflt]:"
40 echo " Launch 'amount' messages as initial load does (non-asynchronous mode)."
41 echo " It works even if burst launch is stopped. Useful to achieve congestion"
42 echo " conditions. For example:"
45 echo " pop [amount: default $burstMargin__dflt]:"
46 echo " Skip send burst messages in order to reduce over-the-air requests."
49 echo " Stops the burst cycle at the current position. It could affect sessions"
50 echo " on the air (i.e. data contexts). Totally safe for IEC scenaries as SMS."
53 echo " Resume an stopped burst launch from the same point (start will reset"
54 echo " the work pointer to the first burst list position). This is equivalent"
55 echo " to one-message-push operation."
57 echo " repeat [[yes] | no]:"
58 echo " Restarts the burst launch cycle when finished."
60 echo " send [amount: default 1]:"
61 echo " send messages from burst list. The main difference with start/push operations"
62 echo " is that burst won't be awaken. Externally we could control sending time (no"
63 echo " request will be sent for answers). When reach the last position, starts again."
65 echo " sendXS <requests per second> [amount: default -1 (no limit)]:"
66 echo " send messages from burst list with the TPS provided. User could hot change"
67 echo " speed by mean 'echo <TPS> > .tps' at another shell. You can stop the load"
68 echo " removing that hidden file or using CTRL+C from the shell where you launched"
69 echo " the burst command. Real tps is dumped on '.real_tps' file during testing."
70 echo " You could limit the amount of messages sent by mean the second parameter."
71 echo " No limit is established by default (-1 or negative value)."
74 echo " Updates current burst pointer position."
77 echo " Show programmed burst message for order provided."
84 curl -m 5 --data "$1" $TRACE ${SERVER}
89 [[ "$1" = "" ]] && uso
91 clear) _curl "burst|clear"
93 load) [[ "$3" = "" ]] && uso
94 [[ ! -f "${3}.sh" ]] && salir "Burst generation file '${3}.sh' not found!"
100 [[ "$RESTO" != "0" ]] && salir "Data context should load a multiple of 4 (messages generated by data.sh)"
103 while test "$count" -le "$2"
105 ${3}.sh $count > .${3}.xml
106 echo -n "Loading message ${count}; "
107 _curl "burst|load|.${3}.xml"
111 start) load=$burstMargin__dflt
112 [[ "$2" != "" ]] && load=$2
114 _curl "burst|start|$load"
116 pop) release=$burstMargin__dflt
117 [[ "$2" != "" ]] && release=$2
119 _curl "burst|pop|$release"
121 push) [[ "$2" = "" ]] && uso
123 _curl "burst|push|$2"
125 stop) _curl "burst|stop"
127 resume) _curl "burst|push|1"
130 [[ "$2" != "" ]] && repeat=$2
131 _curl "burst|repeat|$repeat"
134 [[ "$2" != "" ]] && amount=$2
136 _curl "burst|send|$amount"
138 sendXS) [[ "$2" = "" ]] && uso
140 [[ "$limit" = "" ]] && limit=-1
149 [[ "$count" = "$limit" ]] && break
150 BEFORE_ns=`date +%s%N`
152 # Hot change could make .tps still unavailable:
153 [[ "$READ_TPS" = "" ]] && READ_TPS=$TPS
154 # Volvemos a calcular medias (REAL_TPS) cada 10 segundos o cuando cambia el TPS en caliente:
155 [[ "$READ_TPS" != "$TPS" ]] && { BEGIN_ns=$BEFORE_ns ; count=0 ; }
156 [[ $count = $((10*TPS)) ]] && { BEGIN_ns=$BEFORE_ns ; count=0 ; }
158 [[ "$TPS" = "0" ]] && salir "Test stopped due to 0-tps value read"
160 _curl "burst|send|$amount" &
161 count=$((count+amount))
162 AFTER_ns=`date +%s%N`
164 REAL_TPS=$(calc "1000000000 * $count / ($AFTER_ns - $BEGIN_ns)")
165 echo $REAL_TPS > .real_tps
168 [[ $(calc "$TPS > $REAL_TPS") = "1" ]] && COEF=$(calc "$REAL_TPS / $TPS")
169 K=$(calc "$COEF ^ 10")
170 amount=$(calc "scale=0;1/$K")
171 usleep $(calc "$K * 1000000/$TPS")
174 goto) [[ "$2" = "" ]] && uso
176 _curl "burst|goto|$2"
178 look) [[ "$2" = "" ]] && uso
180 _curl "burst|look|$2"