test-socket-signal: add suspend/resume local run script
authorRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Sun, 24 Oct 2010 15:45:33 +0000 (18:45 +0300)
committerRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Sun, 24 Oct 2010 15:45:33 +0000 (18:45 +0300)
Utils/test-socket-signal/test/local_run_suspend [new file with mode: 0755]

diff --git a/Utils/test-socket-signal/test/local_run_suspend b/Utils/test-socket-signal/test/local_run_suspend
new file mode 100755 (executable)
index 0000000..78a5149
--- /dev/null
@@ -0,0 +1,78 @@
+#!/bin/bash
+
+if test $# -ne 7; then
+       echo "Usage: $0 client_type listen_port buffer_size frequency remote_ip remote_port remote_buffer_size" 1>&2
+       exit 1
+fi
+
+source ./config
+
+client_type=$1
+listen_port=$2
+buffer_size=$3
+frequency=$4
+remote_ip=$5
+remote_port=$6
+remote_buffer_size=$7
+
+log_file_leader=$BASE_LOG_PATH/socket-signal-suspend-leader.log
+log_file_follower=$BASE_LOG_PATH/socket-signal-suspend-follower.log
+
+client_pid=0
+
+run_client()
+{
+       if test "$client_type" == "leader"; then
+               $PEER_EXEC_PATH -l -p $listen_port -b $buffer_size -f $frequency -e $remote_buffer_size $remote_ip $remote_port >> $log_file_leader 2>&1 &
+               client_pid=$!
+       else
+               $PEER_EXEC_PATH -p $listen_port -b $buffer_size -f $frequency -e $remote_buffer_size $remote_ip $remote_port >> $log_file_follower 2>&1 &
+               client_pid=$!
+       fi
+}
+
+do_action_phase1()
+{
+       timeout="$1"
+       if test "$client_type" == "leader"; then
+               kill -STOP "$client_pid"
+               sleep "$timeout"
+               kill -CONT "$client_pid"
+       else
+               sleep "$(($timeout+5))"
+       fi
+}
+
+do_action_phase2()
+{
+       timeout="$1"
+       if test "$client_type" == "leader"; then
+               sleep "$(($timeout+5))"
+       else
+               kill -STOP "$client_pid"
+               sleep "$timeout"
+               kill -CONT "$client_pid"
+       fi
+}
+
+# clean log files
+> $log_file_leader
+> $log_file_follower
+
+run_client
+
+timeout=10
+for i in {1..10}; do
+       sleep 60
+       do_action_phase1 $timeout
+       # geometric growth
+       timeout=$(($timeout * 2))
+done
+
+timeout=10
+for i in {1..10}; do
+       sleep 60
+       do_action_phase2 $timeout
+       # geometric growth
+       timeout=$(($timeout * 2))
+done