make cross-check-tcp more robust : we need to wait for network presence on both ends...
[tests.git] / system / iterate-ping-node
1 #!/bin/bash
2
3 # to be run on testmaster in a buildname/
4
5 if [ "$1" == "-o" ] ; then
6     shift
7     logdir="$1"
8     shift
9     mkdir -p $logdir
10     extra_message="logdir=$logdir"
11 fi
12
13 [[ -n "$@" ]] && iterations=$1 || iterations=10
14
15 buildname=$(basename $(pwd))
16
17 echo "buildname=$buildname, $iterations iterations" $extra_message
18
19 for attempt in $(seq $iterations); do
20
21     attempt=$(printf "%02d" $attempt)
22     
23     echo ======================================== attempt $attempt
24
25     run qemu-kill-mine >& /dev/null
26     echo KILLED
27     ssh boxtops rm /vservers/$buildname/\*/log.txt
28     echo CLEANED
29 #    run qemu-list-mine
30     sleep 5
31     run qemu-start >& /dev/null
32     echo RESTARTED
33 #    run qemu-list-mine
34     sleep 40
35     run ping-node >& /dev/null && msg=OK || msg=KO
36
37     log=$buildname-$attempt-$msg.log.txt
38     rsync boxtops:/vservers/$buildname/\*/log.txt $log
39
40     if [ -n "$logdir" ] ; then
41         mv $log $logdir
42         log=$logdir/$log
43     fi
44
45     echo ==================== attempt $attempt $msg - see $log
46
47 done