forked from basho/yokozuna
/
run-bench.sh
executable file
·91 lines (79 loc) · 2.01 KB
/
run-bench.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
#
#> Usage:
#>
#> ./run-bench.sh <hosts file> <key> <script dir> <bench root> <bench config> <bench results dir> <bench name>
usage() {
grep '#>' $0 | sed 's/#>//' | sed '$d'
}
error() {
echo $1
exit 1
}
if [ ! $# -eq 7 ]; then
echo "incorrect number of arguments"
usage
exit 1
fi
HOSTS_FILE=$1; shift
KEY=$1; shift
SCRIPT_DIR=$1; shift
BENCH_ROOT=$1; shift
BENCH_CFG=$1; shift
BENCH_RESULTS_DIR=$1; shift
BENCH_NAME=$1; shift
RUN_DIR=$BENCH_RESULTS_DIR/$BENCH_NAME
verify_hosts() {
while read user_host; do
if ssh -fi $KEY $user_host 'exit'; then
echo "verified login $user_host"
else
error "failed to login $user_host"
fi
done < $HOSTS_FILE
}
copy_collect_scripts() {
while read user_host; do
if ! scp -i $KEY -r $SCRIPT_DIR/*collect.sh $user_host:~/; then
error "failed to copy collection scripts to $user_host"
fi
done < $HOSTS_FILE
}
start_collecting() {
while read user_host; do
for script in $SCRIPT_DIR/*collect.sh; do
script=$(basename $script)
ssh -fi $KEY $user_host "chmod a+x $script && ./$script start"
done
done < $HOSTS_FILE
}
stop_collecting() {
while read user_host; do
for script in $SCRIPT_DIR/*collect.sh; do
script=$(basename $script)
ssh -fi $KEY $user_host "./$script stop"
done
done < $HOSTS_FILE
}
copy_output() {
while read user_host; do
for script in $SCRIPT_DIR/*collect.sh; do
output_path=$($script output)
output_file=$(basename $output_path)
src=$user_host:$output_path
dest=$RUN_DIR/${user_host}-${output_file}
echo "copying output from $src to $dest"
scp -qi $KEY $src $dest
done
done < $HOSTS_FILE
}
run_bench() {
$BENCH_ROOT/basho_bench -d $BENCH_RESULTS_DIR -n $BENCH_NAME $BENCH_CFG
}
verify_hosts
copy_collect_scripts
start_collecting
run_bench
sleep 10s
stop_collecting
copy_output