test-signal-socket: new version of eurocon scripts
[p2p-testing-infrastructure.git] / Utils / test-socket-signal / test / eurocon / remote_run_suspend
index 6eaf8fb..5bda131 100755 (executable)
@@ -1,6 +1,60 @@
 #!/bin/bash
 
-if test $# -ne 4; then
-       echo "Usage: $0 host1 port1 host2 port2" 1>&2
+if test $# -ne 6; then
+       echo "Usage: $0 host1 port1 host2 port2 timeout id" 1>&2
        exit 1
 fi
+
+host1=$1
+port1=$2
+host2=$3
+port2=$4
+timeout=$5
+_id=$6
+
+# cleanup
+ssh -n -f -p $port1 -l root $host1 "/home/p2p/eurocon/local_clean"
+ssh -n -f -p $port2 -l root $host2 "/home/p2p/eurocon/local_clean"
+
+ip=$(ssh -n -f -p $port1 -l root $host1 "/home/p2p/eurocon/local_get_ip")
+
+# make torrent file
+ssh -n -f -p $port1 -l p2p $host1 "/home/p2p/eurocon/local_create_torrent $ip"
+ssh -n -f -p $port2 -l p2p $host2 "/home/p2p/eurocon/local_create_torrent $ip"
+
+# start tracker
+ssh -n -f -p $port1 -l p2p $host1 "/home/p2p/eurocon/local_run_tracker"
+
+sleep 5
+
+# start seeder
+ssh -n -f -p $port1 -l p2p $host1 "/home/p2p/eurocon/local_start_seeder"
+
+# start leecher
+ssh -n -f -p $port2 -l p2p $host2 "/home/p2p/eurocon/local_start_leecher"
+
+# wait for it
+sleep 15
+
+# suspend leecher
+ssh -n -f -p $port2 -l root $host2 "/home/p2p/eurocon/local_suspend_client"
+
+# sleep as planned
+sleep $timeout
+
+# resume leecher
+ssh -n -f -p $port2 -l root $host2 "/home/p2p/eurocon/local_cont_client"
+
+sleep 45
+
+# cleanup
+ssh -n -f -p $port1 -l root $host1 "/home/p2p/eurocon/local_clean"
+ssh -n -f -p $port2 -l root $host2 "/home/p2p/eurocon/local_clean"
+
+# sync back
+rsync -avz -e "ssh -p $port1" p2p@$host1:/home/p2p/eurocon/hrk.log ../eurocon-log/$host1-$port1-$id-$timeout-seeder.log
+rsync -avz -e "ssh -p $port2" p2p@$host2:/home/p2p/eurocon/hrk.log ../eurocon-log/$host2-$port2-$id-$timeout-leecher.log
+
+# backup logs
+ssh -n -f -p $port1 -l p2p $host1 "mv /home/p2p/eurocon/hrk.log hrk-$(date +%s).log"
+ssh -n -f -p $port2 -l p2p $host2 "mv /home/p2p/eurocon/hrk.log hrk-$(date +%s).log"