forked from c4dt/d-voting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autotest.sh
executable file
·63 lines (55 loc) · 1.83 KB
/
autotest.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#! /bin/sh
# This script uses runNode.sh, setupnNode.sh, kill_test.sh to launch multiple
# times of scenario test with user defined number of nodes. The results of log are kept in directory named logkill$i
POSITIONAL_ARGS=()
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
echo "This script uses runNode.sh, setupnNode.sh, kill_test.sh to launch multiple times of scenario test with user defined number of nodes. The results of log are kept in directory named logkill "
echo ""
echo "Options:"
echo "-h | --help program help (this file)"
echo "-n | --node number of d-voting nodes"
echo "-r | --run_time set how many times we want to run the test"
exit 0
;;
-n|--node)
N_NODE="$2"
shift # past argument
shift # past value
;;
-r|--run_time)
RUN_TIMES="$2"
shift # past argument
shift # past value
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done
set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters
vals=($(seq 1 1 $RUN_TIMES))
for i in "${vals[@]}"
do
echo "Test $i with $N_NODE nodes"
# Launch nodes
./runNode.sh -n $N_NODE -a false -d true
sleep 3
# Setup block chain
./setupnNode.sh -n $N_NODE -d true
sleep 3
# Start scenario test and keep logs
NNODES=$N_NODE go test -v -run ^TestScenario$ github.com/c4dt/d-voting/integration -count=1 | tee ./log/log/gotest.log
sleep 3
# Stop the test
./kill_test.sh
# move log to a new directory named logkill
mv log/log log/logkill$i
done
echo "Test $RUN_TIMES times test and succeeded $(grep -c ok ./log/log*/gotest.log| awk 'BEGIN{FS=":"}{x+=$2}END{print x}') times"