11 calc () { echo "$1" | bc -l ; }
14 limpio=$(calc "scale=0;${1}/1")
15 [[ $limpio != $1 ]] && salir "Invalid value '$1'. Must be integer"
20 echo "Load tests configuration script"
22 echo "Use: $0 <action: clear | load | start | push | pop | stop | resume | repeat | send | goto | look> [action parameters]"
25 echo " Clears all loaded burst messages."
27 echo " load <amount> <traffic type: mms | sms | voice | data | content>:"
28 echo " Loads 'amount' messages for the provided traffic type. For example:"
29 echo " $0 load 2000 sms"
31 echo " start [initial launch: default $burstMargin__dflt]:"
32 echo " Starts the message sending from the begining of the burst list loaded,"
33 echo " with a certain initial load. For example:"
36 echo " push [amount: default $burstMargin__dflt]:"
37 echo " Launch 'amount' messages as initial load does (non-asynchronous mode)."
38 echo " It works even if burst launch is stopped. Useful to achieve congestion"
39 echo " conditions. For example:"
42 echo " pop [amount: default $burstMargin__dflt]:"
43 echo " Skip send burst messages in order to reduce over-the-air requests."
46 echo " Stops the burst cycle at the current position. It could affect sessions"
47 echo " on the air (i.e. data contexts). Totally safe for IEC scenaries as SMS."
50 echo " Resume an stopped burst launch from the same point (start will reset"
51 echo " the work pointer to the first burst list position). This is equivalent"
52 echo " to one-message-push operation."
54 echo " repeat [[yes] | no]:"
55 echo " Restarts the burst launch cycle when finished."
57 echo " send [amount: default 1]:"
58 echo " send messages from burst list. The main difference with start/push operations"
59 echo " is that burst won't be awaken. Externally we could control sending time (no"
60 echo " request will be sent for answers). When reach the last position, starts again."
62 echo " sendXS <requests per second> [amount: default -1 (no limit)]:"
63 echo " send messages from burst list with the TPS provided. User could hot change"
64 echo " speed by mean 'echo <TPS> > .tps' at another shell. You can stop the load"
65 echo " removing that hidden file or using CTRL+C from the shell where you launched"
66 echo " the burst command. Real tps is dumped on '.real_tps' file during testing."
67 echo " You could limit the amount of messages sent by mean the second parameter."
68 echo " No limit is established by default (-1 or negative value)."
71 echo " Updates current burst pointer position."
74 echo " Show programmed burst message for order provided."
82 [[ "$1" = "" ]] && uso
84 clear) ./operation.sh "burst|clear"
86 load) [[ "$3" = "" ]] && uso
87 [[ ! -f "${3}.sh" ]] && salir "Burst generation file '${3}.sh' not found!"
93 [[ "$RESTO" != "0" ]] && salir "Data context should load a multiple of 4 (messages generated by data.sh)"
96 while test "$count" -le "$2"
98 ${3}.sh $count > .${3}.xml
99 echo -n "Loading message ${count}; "
100 ./operation.sh "burst|load|.${3}.xml"
104 start) load=$burstMargin__dflt
105 [[ "$2" != "" ]] && load=$2
107 ./operation.sh "burst|start|$load"
109 pop) release=$burstMargin__dflt
110 [[ "$2" != "" ]] && release=$2
112 ./operation.sh "burst|pop|$release"
114 push) [[ "$2" = "" ]] && uso
116 ./operation.sh "burst|push|$2"
118 stop) ./operation.sh "burst|stop"
120 resume) ./operation.sh "burst|push|1"
123 [[ "$2" != "" ]] && repeat=$2
124 ./operation.sh "burst|repeat|$repeat"
127 [[ "$2" != "" ]] && amount=$2
129 ./operation.sh "burst|send|$amount"
131 sendXS) [[ "$2" = "" ]] && uso
133 [[ "$limit" = "" ]] && limit=-1
142 [[ "$count" = "$limit" ]] && break
143 BEFORE_ns=`date +%s%N`
145 # Hot change could make .tps still unavailable:
146 [[ "$READ_TPS" = "" ]] && READ_TPS=$TPS
147 # Volvemos a calcular medias (REAL_TPS) cada 10 segundos o cuando cambia el TPS en caliente:
148 [[ "$READ_TPS" != "$TPS" ]] && { BEGIN_ns=$BEFORE_ns ; count=0 ; }
149 [[ $count = $((10*TPS)) ]] && { BEGIN_ns=$BEFORE_ns ; count=0 ; }
151 [[ "$TPS" = "0" ]] && salir "Test stopped due to 0-tps value read"
153 ./operation.sh "burst|send|$amount" &
154 count=$((count+amount))
155 AFTER_ns=`date +%s%N`
157 REAL_TPS=$(calc "1000000000 * $count / ($AFTER_ns - $BEGIN_ns)")
158 echo $REAL_TPS > .real_tps
161 [[ $(calc "$TPS > $REAL_TPS") = "1" ]] && COEF=$(calc "$REAL_TPS / $TPS")
162 K=$(calc "$COEF ^ 10")
163 amount=$(calc "scale=0;1/$K")
164 usleep $(calc "$K * 1000000/$TPS")
167 goto) [[ "$2" = "" ]] && uso
169 ./operation.sh "burst|goto|$2"
171 look) [[ "$2" = "" ]] && uso
173 ./operation.sh "burst|look|$2"