Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / ACE / apps / JAWS / clients / WebSTONE / bin / runbench
blob409351f8f5566edeb69890538bd40a01313b36ad
1 #!/bin/sh
2 # $Header$
3 # set -x
4 set +x
5 [ -n "$WEBSTONEROOT" ] || WEBSTONEROOT=`pwd`/../
7 case $# in
8 1)
9 FILELIST=$1
12 FILELIST=$WEBSTONEROOT/conf/filelist
14 esac
16 # load configurations
17 . $WEBSTONEROOT/conf/testbed
19 [ -n "$DEBUG" ] && set +x
21 # check variables
22 [ -n "$ITERATIONS" ] || ITERATIONS="1"
23 [ -n "$MINCLIENTS" ] || MINCLIENTS="1"
24 [ -n "$MAXCLIENTS" ] || MAXCLIENTS="1"
25 [ -n "$CLIENTINCR" ] || CLIENTINCR="1"
26 [ -n "$TIMEPERRUN" ] || TIMEPERRUN="1"
27 # don't care about PROXYSERVER
28 [ -n "$SERVER" ] || SERVER="www"
29 [ -n "$PORTNO" ] || PORTNO="80"
30 # [ -n "$SERVERINFO" ] || SERVERINFO="uname -a"
31 # OSTUNINGFILES
32 # WEBSERVERDIR
33 # WEBDOCDIR
34 # WEBSERVERTUNINGFILES
35 [ -n "$CLIENTS" ] || CLIENTS="localhost"
36 [ -n "$CLIENTACCOUNT" ] || CLIENTACCOUNT=$USER
37 [ -n "$CLIENTPASSWORD" ] || CLIENTPASSWORD=$CLIENTACCOUNT
38 # [ -n "$CLIENTINFO" ] || CLIENTINFO="uname -a"
39 [ -n "$TMPDIR" ] || TMPDIR="/tmp"
40 [ -n "$RCP" ] || RCP="rcp"
41 [ -n "$RSH" ] || RSH="rsh"
43 export ITERATIONS MINCLIENTS MAXCLIENTS CLIENTINCR TIMEPERRUN
44 export SERVER PORTNO SERVERINFO
45 export CLIENTS CLIENTACCOUNT CLIENTPASSWORD CLIENTINFO
46 export TMPDIR RCP RSH
48 echo "Clients: " $CLIENTS
51 # Estimate run time
53 NUMCLIENTHOSTS=`echo $CLIENTS | wc -w`
54 TRIALS=`expr 1 + \( $MAXCLIENTS - $MINCLIENTS \) / $CLIENTINCR`
55 RUNTIME=`expr 60 \* $ITERATIONS \* $TRIALS \* $TIMEPERRUN`
56 RUNTIME=`expr $RUNTIME + $TRIALS \* \( $MAXCLIENTS + $MINCLIENTS \) \
57 / \( 2 \* $NUMCLIENTHOSTS \)`
59 echo "Estimated run time:" `expr $RUNTIME / 3600` "hours" \
60 `expr $RUNTIME % 3600 / 60` "minutes"
63 # Checking for valid set of benchmark files to retrieve
65 #if [ -z "$PROXYSERVER" ]
66 #then
67 # echo "Checking for a valid set of benchmark files"
68 # CHECKLISTTMP=$TMPDIR/webstone-checkfilelist.$$
69 # rm -f $CHECKFILELISTTMP
70 # $WEBSTONEROOT/bin/checkfilelist $SERVER $PORTNO $FILELIST > $CHECKLISTTMP 2>&1
71 # if [ `grep -c ' 4[0-9][0-9] '< $CHECKLISTTMP` -gt 0 ]
72 # then
73 # echo "ERROR: not all files in filelist are on server:"
74 # echo "----- checkfilelist results -----"
75 # cat $CHECKLISTTMP
76 # echo "----- checkfilelist results -----"
77 # rm -f $CHECKLISTTMP
78 # exit 1
79 # else
80 # echo "OK: All files found"
81 # fi
82 # rm -f $CHECKLISTTMP
83 #fi
84 # end if $PROXYSERVER
87 # distribute webclient binary
89 for i in $CLIENTS
91 $RCP $WEBSTONEROOT/bin/webclient $i:$TMPDIR #/usr/local/bin
92 done
94 # BEGIN iterations
95 J=1
96 while [ $J -le $ITERATIONS ]
98 NUMCLIENTS=$MINCLIENTS
99 while [ $NUMCLIENTS -le $MAXCLIENTS ]
101 echo "***** Iteration $J, Total clients "`expr $NUMCLIENTS`" **********"
102 date
103 TIMESTAMP=`date +"%y%m%d_%H%M"`
104 LOGDIR=$WEBSTONEROOT/bin/runs/$TIMESTAMP
107 # nuke debug files
109 for client in $CLIENTS
111 $RSH $client "rm /tmp/webstone-debug*" > /dev/null 2>&1
112 done
114 mkdir -p $LOGDIR
115 rm -f $LOGDIR/config
116 touch $LOGDIR/config
117 CLIENTSPERHOST=`expr $NUMCLIENTS / $NUMCLIENTHOSTS`
118 EXTRACLIENTS=`expr $NUMCLIENTS % $NUMCLIENTHOSTS`
120 for i in $CLIENTS
122 if [ $EXTRACLIENTS -gt 0 ]
123 then
124 echo "$i $CLIENTACCOUNT $CLIENTPASSWORD `expr $CLIENTSPERHOST + 1`" \
125 >> $LOGDIR/config
126 EXTRACLIENTS=`expr $EXTRACLIENTS - 1`
127 else
128 echo "$i $CLIENTACCOUNT $CLIENTPASSWORD $CLIENTSPERHOST" \
129 >> $LOGDIR/config
131 done
132 cp $FILELIST $LOGDIR/`basename $FILELIST`
135 # Put test configuration files on clients
137 for i in $CLIENTS localhost
139 $RSH $i "rm -f $TMPDIR/config $TMPDIR/`basename $FILELIST`"
140 $RCP $LOGDIR/config $i:$TMPDIR/config
141 $RCP $LOGDIR/`basename $FILELIST` $i:$TMPDIR/filelist
142 done
145 # Get starting configuration and stats from each participant
147 $RSH $SERVER "$SERVERINFO" > $LOGDIR/hardware.$SERVER 2>&1
148 for i in $CLIENTS
150 $RSH $i "$CLIENTINFO" > $LOGDIR/hardware.$i 2>&1
151 done
153 # set -x
154 for i in $OSTUNINGFILES $WEBSERVERTUNINGFILES
156 $RCP $SERVER:$i $LOGDIR
157 done
158 set +x
161 # Run benchmark
163 date
164 CMD="$WEBSTONEROOT/bin/webmaster -v -u $TMPDIR/filelist"
165 CMD=$CMD" -f $TMPDIR/config -l $TIMEPERRUN"
166 [ -n "$SERVER" ] && CMD=$CMD" -w $SERVER"
167 [ -n "$PORTNO" ] && CMD=$CMD" -p $PORTNO"
168 [ -n "$PROXYSERVER" ] && CMD=$CMD" -P $PROXYSERVER"
169 [ -n "$DEBUG" ] && CMD=$CMD" -d"
170 echo $CMD
172 # dump environment into $LOGDIR
173 rm -rf $LOGDIR/controller.env
174 env > $LOGDIR/controller.env
176 $CMD | tee $LOGDIR/run
179 # Get ending configuration and stats from each participant
181 date
182 #for i in $SERVER $CLIENTS
184 #$WEBSTONEROOT/bin/getstats $i > $LOGDIR/end.$i 2>&1
185 #done
186 #date
187 NUMCLIENTS=`expr $NUMCLIENTS + $CLIENTINCR`
188 done
189 # while NUMCLIENTS
190 J=`expr $J + 1`
191 done
192 # while J
193 # end