ControlScripts: update run_scenario script to new configuration file and infrastructure
authorRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tue, 3 Aug 2010 17:11:19 +0000 (20:11 +0300)
committerRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tue, 3 Aug 2010 17:11:19 +0000 (20:11 +0300)
ControlScripts/run_scenario.sh

index 37b236f..541da5f 100755 (executable)
@@ -2,6 +2,9 @@
 #
 # Copyright: George Milescu 2010 - george.milescu@gmail.com
 #
+# 2010, Razvan Deaconescu, razvan.deaconescu@cs.pub.ro:
+#    * update script to use new configuration file and run scripts
+#
 # Bash script used to run a test scenario
 # The script
 #  * Reads the scenario setup file
@@ -84,11 +87,10 @@ cat $CONFIG_FILES_REL_PATH/$SCENARIO_FILE | grep -v ^# | grep -v ^$ | tr -s '\t'
 > $ERR_LOG
 
 
-
 # Setup the nodes
 scenario_setup() {
        echo "---------------------- scenario_setup_" >> $ERR_LOG
-       while IFS=$'\t' read SERVER PORT USER REMOTE_PATH REMOTE_IF DL_BW DL_BURST UL_BW UL_BURST START_DELAY START_CMD DETECT_STOP_CMD STOP_CMD TC_SCRIPT LOG_PARSER; do
+       while IFS=$'\t' read SERVER PORT USER REMOTE_PATH REMOTE_IF DL_BW DL_BURST UL_BW UL_BURST TC_SCRIPT CLIENT_TYPE TORRENT_FILE PERIODS; do
                echo " ** Setting-up $SERVER:$PORT"
                
                # Clean-up the host by using rsync
@@ -108,38 +110,32 @@ scenario_setup() {
        echo "---------------------- _scenario_setup" >> $ERR_LOG
 }
 
-
-
-# Start the clients
-# The setup stage is separated to decrease the time required to start the clients
-scenario_start() {
-       echo "---------------------- scenario_start_" >> $ERR_LOG
-       while IFS=$'\t' read SERVER PORT USER REMOTE_PATH REMOTE_IF DL_BW DL_BURST UL_BW UL_BURST START_DELAY START_CMD DETECT_STOP_CMD STOP_CMD TC_SCRIPT LOG_PARSER; do
-               echo " ** Starting client on $SERVER:$PORT"
-               
-               # Start the scripts on the remote clients
-               # -f is used to put ssh in background after the connection is set and to redirect the ssh stdin from /dev/null
-               if ! ssh -f -p $PORT ${USER}@${SERVER} "cd $REMOTE_PATH/P2P-Testing-Infrastructure/ControlScripts; sleep $START_DELAY; ./$START_CMD &> $REMOTE_PATH/P2P-Testing-Infrastructure/ClientWorkingFolders/TmpLogs/\$(hostname).log" &>> $ERR_LOG; then
-                       echo "Error: error running $START_CMD on $SERVER"
+# Schedule start/stop
+scenario_schedule()
+{
+       echo "---------------------- scenario_schedule" >> $ERR_LOG
+       while IFS=$'\t' read SERVER PORT USER REMOTE_PATH REMOTE_IF DL_BW DL_BURST UL_BW UL_BURST TC_SCRIPT CLIENT_TYPE TORRENT_FILE PERIODS; do
+               echo " ** Scheduling $SERVER:$PORT"
+               if ! ssh -f -p $PORT ${USER}@${SERVER} "cd $REMOTE_PATH/P2P-Testing-Infrastructure/ControlScripts; ./client_schedule.sh ${CLIENT_TYPE} ${TORRENT_FILE} ${PERIODS}" &>> $ERR_LOG; then
+                       echo "Error: error running client_schedule.sh on $SERVER"
                        break
                fi
        done < $TMP_FILE
        unset IFS
-       echo "---------------------- _scenario_start" >> $ERR_LOG
+       echo "---------------------- _scenario_schedule" >> $ERR_LOG
 }
 
 
-
 # Wait until all the clients are finished
 scenario_wait() {
        echo "---------------------- scenario_wait_" >> $ERR_LOG
-       while IFS=$'\t' read SERVER PORT USER REMOTE_PATH REMOTE_IF DL_BW DL_BURST UL_BW UL_BURST START_DELAY START_CMD DETECT_STOP_CMD STOP_CMD TC_SCRIPT LOG_PARSER; do
+       while IFS=$'\t' read SERVER PORT USER REMOTE_PATH REMOTE_IF DL_BW DL_BURST UL_BW UL_BURST TC_SCRIPT CLIENT_TYPE TORRENT_FILE PERIODS; do
                echo " ** Waiting for client on $SERVER:$PORT to finish"
                
                # Start the scripts on the remote clients
                # -n is used to redirect the ssh stdin from /dev/null, in order to keep the stdin in place for the read command
                # The ssh call is blocking
-               if ! ssh -n -p $PORT ${USER}@${SERVER} "cd $REMOTE_PATH/P2P-Testing-Infrastructure/ControlScripts; ./$DETECT_STOP_CMD $REMOTE_PATH/P2P-Testing-Infrastructure/ClientWorkingFolders/TmpLogs/\$(hostname).log" &>> $ERR_LOG; then
+               if ! ssh -n -p $PORT ${USER}@${SERVER} "cd $REMOTE_PATH/P2P-Testing-Infrastructure/ControlScripts; ./detect_complete_client.sh ${CLIENT_TYPE} $REMOTE_PATH/P2P-Testing-Infrastructure/ClientWorkingFolders/TmpLogs/\$(hostname).log" &>> $ERR_LOG; then
                        echo "Error: error while waiting for client on $SERVER to finish"
                        break
                fi
@@ -149,30 +145,15 @@ scenario_wait() {
 }
 
 
-# Schedule start/stop
-scenario_schedule()
-{
-       echo "---------------------- scenario_schedule" >> $ERR_LOG
-       while IFS=$'\t' read SERVER PORT USER REMOTE_PATH REMOTE_IF DL_BW DL_BURST UL_BW UL_BURST START_DELAY START_CMD DETECT_STOP_CMD STOP_CMD TC_SCRIPT LOG_PARSER PERIODS; do
-               echo " ** Scheduling $SERVER:$PORT"
-               if ! ssh -f -p $PORT ${USER}@${SERVER} "cd $REMOTE_PATH/P2P-Testing-Infrastructure/ControlScripts; ./client_schedule.sh ${CLIENT_TYPE} ${TORRENT_FILE} ${PERIODS}" &>> $ERR_LOG; then
-                       echo "Error: error running client_schedule.sh on $SERVER"
-                       break
-               fi
-       done < $TMP_FILE
-       unset IFS
-       echo "---------------------- _scenario_schedule" >> $ERR_LOG
-}
-
 # Clean the nodes and retrieve the log files
 scenario_clean() {
        echo "---------------------- scenario_clean_" >> $ERR_LOG
-       while IFS=$'\t' read SERVER PORT USER REMOTE_PATH REMOTE_IF DL_BW DL_BURST UL_BW UL_BURST START_DELAY START_CMD DETECT_STOP_CMD STOP_CMD TC_SCRIPT LOG_PARSER; do
+       while IFS=$'\t' read SERVER PORT USER REMOTE_PATH REMOTE_IF DL_BW DL_BURST UL_BW UL_BURST TC_SCRIPT CLIENT_TYPE TORRENT_FILE PERIODS; do
                echo " ** Cleaning-up $SERVER:$PORT"
                
                # stopping the client on the server
                # -n is used to redirect the ssh stdin from /dev/null, in order to keep the stdin in place for the read command
-               if ! ssh -n -p $PORT ${USER}@${SERVER} "cd $REMOTE_PATH/P2P-Testing-Infrastructure/ControlScripts; ./$STOP_CMD" &>> $ERR_LOG; then
+               if ! ssh -n -p $PORT ${USER}@${SERVER} "cd $REMOTE_PATH/P2P-Testing-Infrastructure/ControlScripts; ./stop_client.sh ${CLIENT_TYPE}" &>> $ERR_LOG; then
                        echo "Error: error stopping client on $SERVER"
                fi
                # wait for the remote client to finish completly
@@ -197,18 +178,17 @@ scenario_clean() {
 }
 
 
-
 # Parse the log files
 scenario_parse() {
        echo "---------------------- scenario_parse_" >> $ERR_LOG
-       while IFS=$'\t' read SERVER PORT USER REMOTE_PATH REMOTE_IF DL_BW DL_BURST UL_BW UL_BURST START_DELAY START_CMD DETECT_STOP_CMD STOP_CMD TC_SCRIPT LOG_PARSER; do
+       while IFS=$'\t' read SERVER PORT USER REMOTE_PATH REMOTE_IF DL_BW DL_BURST UL_BW UL_BURST TC_SCRIPT CLIENT_TYPE TORRENT_FILE PERIODS; do
                echo -n " ** Parsing log files from $SERVER:$PORT"
                
                REMOTE_HOSTNAME=$(ssh -n -p $PORT ${USER}@${SERVER} "hostname")
                
                echo " with hostname $REMOTE_HOSTNAME"
                
-               if ! ./$LOG_PARSER $SCENARIO_RESULTS_FOLDER ${REMOTE_HOSTNAME}.log; then
+               if ! ./parse_log.sh ${CLIENT_TYPE} $SCENARIO_RESULTS_FOLDER ${REMOTE_HOSTNAME}.log; then
                        echo "Error parsing file $SCENARIO_RESULTS_FOLDER/${REMOTE_HOSTNAME}.log"
                        exit 1
                fi
@@ -225,7 +205,7 @@ case "$ACTION" in
        ;;
        
        "start")
-       scenario_start
+       scenario_schedule
        ;;
        
        "wait")
@@ -242,7 +222,7 @@ case "$ACTION" in
        
        "run")
        scenario_setup
-       scenario_start
+       scenario_schedule
        scenario_wait
        scenario_clean
        scenario_parse