#
# 2010, Razvan Deaconescu, razvan.deaconescu@cs.pub.ro:
# * update script to use new configuration file and run scripts
+# * update script for newer configuration file (pre-run and
+# post-run scripts)
#
# Bash script used to run a test scenario
# The script
# 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 TC_SCRIPT CLIENT_TYPE TORRENT_FILE PERIODS; do
+ while IFS=$'\t' read SERVER PORT USER REMOTE_PATH REMOTE_IF DL_BW DL_BURST UL_BW UL_BURST PRE_RUN_SCRIPT POST_RUN_SCRIPT CLIENT_TYPE TORRENT_FILE PERIODS; do
echo " ** Setting-up $SERVER:$PORT"
-
+
# Clean-up the host by using rsync
if ! rsync -avP --del --exclude 'Results' --rsh='ssh -p'$PORT $TEST_INFRASTRUCTURE_REL_PATH ${USER}@${SERVER}:${REMOTE_PATH} &>> $ERR_LOG; then
echo "Error: rsync error on $SERVER"
exit 1
fi
-
- # run tc script to set the bandwidth limitations
+
+ # Create node config file
+ if ! ssh -n p ${PORT} ${USER}@${SERVER} "cat > $REMOTE_PATH/P2P-Testing-Infrastructure/ClientWorkingFolders/TmpLogs/scenario_config" &>> ${ERR_LOG} <<END
+IFACE="${REMOTE_IF}"
+DL_BW="${DL_BW}"
+DL_BURST="${DL_BURST}"
+UL_BW="${UL_BW}"
+UL_BURST="${UL_BURST}"
+PRE_RUN_SCRIPT="${PRE_RUN_SCRIPT}"
+POST_RUN_SCRIPT="${POST_RUN_SCRIPT}"
+CLIENT_TYPE="${CLIENT_TYPE}"
+TORRENT_FILE="${TORRENT_FILE}"
+PERIODS="${PERIODS}"
+END
+ then
+ echo "Error: cannot create scenario config file"
+ exit 1
+ fi
+
+ # run pre-run script
# -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; ./$TC_SCRIPT set $REMOTE_IF $DL_BW $DL_BURST $UL_BW $UL_BURST" &>> $ERR_LOG; then
+ if ! ssh -n -p $PORT ${USER}@${SERVER} "cd $REMOTE_PATH/P2P-Testing-Infrastructure/ControlScripts; ./${PRE_RUN_SCRIPT}" &>> $ERR_LOG; then
echo "Error: tc error setting limitations on $SERVER"
exit 1
fi
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
+ while IFS=$'\t' read SERVER PORT USER REMOTE_PATH REMOTE_IF DL_BW DL_BURST UL_BW UL_BURST PRE_RUN_SCRIPT POST_RUN_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; ./schedule_client.sh ${CLIENT_TYPE} ${TORRENT_FILE} \"${PERIODS}\" &> $REMOTE_PATH/P2P-Testing-Infrastructure/ClientWorkingFolders/TmpLogs/\$(hostname).log" &>> $ERR_LOG; then
echo "Error: error running client_schedule.sh on $SERVER"
# 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 TC_SCRIPT CLIENT_TYPE TORRENT_FILE PERIODS; do
+ while IFS=$'\t' read SERVER PORT USER REMOTE_PATH REMOTE_IF DL_BW DL_BURST UL_BW UL_BURST PRE_RUN_SCRIPT POST_RUN_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
# 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 TC_SCRIPT CLIENT_TYPE TORRENT_FILE PERIODS; do
+ while IFS=$'\t' read SERVER PORT USER REMOTE_PATH REMOTE_IF DL_BW DL_BURST UL_BW UL_BURST PRE_RUN_SCRIPT POST_RUN_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_client.sh ${CLIENT_TYPE}" &>> $ERR_LOG; then
fi
# wait for the remote client to finish completly
sleep 2
-
- # run tc script to delete the bandwidth limitations
+
+ # run post-run script
# -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; ./$TC_SCRIPT del $REMOTE_IF" &>> $ERR_LOG; then
+ if ! ssh -n -p $PORT ${USER}@${SERVER} "cd $REMOTE_PATH/P2P-Testing-Infrastructure/ControlScripts; ./${POST_RUN_SCRIPT}" &>> $ERR_LOG; then
echo "Error: tc error deleting limitations on $SERVER"
fi
-
+
+ # Remove node config file
+ if ! ssh -n p ${PORT} ${USER}@${SERVER} "rm $REMOTE_PATH/P2P-Testing-Infrastructure/ClientWorkingFolders/TmpLogs/scenario_config" &>> ${ERR_LOG}; then
+ echo "Error: cannot remove scenario_config file"
+ fi
+
# Retrieve log files
scp -P $PORT ${USER}@${SERVER}:${REMOTE_PATH}/P2P-Testing-Infrastructure/ClientWorkingFolders/TmpLogs/* $SCENARIO_RESULTS_FOLDER &>> $ERR_LOG
-
+
# Clean-up the host by using rsync
if ! rsync -avP --del --exclude 'Results' --rsh='ssh -p'$PORT $TEST_INFRASTRUCTURE_REL_PATH ${USER}@${SERVER}:${REMOTE_PATH} &>> $ERR_LOG; then
echo "Error: rsync error on $SERVER"
# 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 TC_SCRIPT CLIENT_TYPE TORRENT_FILE PERIODS; do
+ while IFS=$'\t' read SERVER PORT USER REMOTE_PATH REMOTE_IF DL_BW DL_BURST UL_BW UL_BURST PRE_RUN_SCRIPT POST_RUN_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 ! ./parse_client_log.sh ${CLIENT_TYPE} $SCENARIO_RESULTS_FOLDER ${REMOTE_HOSTNAME}.log; then
echo "Error parsing file $SCENARIO_RESULTS_FOLDER/${REMOTE_HOSTNAME}.log"
exit 1
#setup, start, wait, clean, parse
case "$ACTION" in
"setup")
- scenario_setup
- ;;
-
+ scenario_setup
+ ;;
+
"start")
- scenario_schedule
- ;;
-
+ scenario_schedule
+ ;;
+
"wait")
- scenario_wait
- ;;
-
+ scenario_wait
+ ;;
+
"clean")
- scenario_clean
- ;;
-
+ scenario_clean
+ ;;
+
"parse")
- scenario_parse
- ;;
-
+ scenario_parse
+ ;;
+
"run")
- scenario_setup
- scenario_schedule
- scenario_wait
- scenario_clean
- scenario_parse
- ;;
+ scenario_setup
+ scenario_schedule
+ scenario_wait
+ scenario_clean
+ scenario_parse
+ ;;
*)
- usage
- exit 1
- ;;
+ usage
+ exit 1
+ ;;
esac
rm -f $TMP_FILE