-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
88 lines (76 loc) · 2.59 KB
/
test.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
#!/bin/sh
# init.sh
echo "Testing Script"
echo "Run one (a) or multiple (b) tests?"
read MODE
HOST=localhost
PORT=5432
case $MODE in
a)
echo "Enter scaling factor: "
read SCALINGFACTOR
echo "Enter number of clients: "
read CLIENTS
echo "Enter number of threads: "
read THREADS
echo "install pgMemento? (y/n)"
read PGMEMENTO
psql -h $HOST -p $PORT -U root -d postgres -c "DROP DATABASE IF EXISTS pgbench_db;"
psql -h $HOST -p $PORT -U root -d postgres -c "CREATE DATABASE pgbench_db;"
pgbench -i -s $SCALINGFACTOR pgbench_db
if [[ "$PGMEMENTO" == "y" ]]
then
cd pgMemento
psql -h $HOST -p $PORT -d pgbench_db -f INSTALL_PGMEMENTO.sql
psql -h $HOST -p $PORT -d pgbench_db -f INIT_PGMEMENTO.sql
cd ..
fi
pgbench -S -c $CLIENTS -j $THREADS -M prepared -T30 pgbench_db
;;
b)
echo "install pgMemento? (y/n)"
read PGMEMENTO
echo "Enter scaling factors (finish with Ctrl+D): "
while read factor; do
SCALINGFACTORS=("${SCALINGFACTORS[@]}" $factor)
done
echo "Factors: "
echo ${SCALINGFACTORS[@]}
echo "Enter number of clients (finish with Ctrl+D): "
while read client; do
CLIENTS=("${CLIENTS[@]}" $client)
done
echo "Clients: "
echo ${CLIENTS[@]}
echo "Enter number of threads (finish with Ctrl+D): "
while read thread; do
THREADS=("${THREADS[@]}" $thread)
done
echo "Threads: "
echo ${THREADS[@]}
EXEC_TIME=$(date +"%Y_%m_%d_%H_%M")
mkdir -p results
for s in ${SCALINGFACTORS[@]}; do
for c in ${CLIENTS[@]}; do
for j in ${THREADS[@]}; do
psql -h $HOST -p $PORT -U root -d postgres -c "DROP DATABASE IF EXISTS multi_pgbench_db;"
psql -h $HOST -p $PORT -U root -d postgres -c "CREATE DATABASE multi_pgbench_db;"
pgbench -i -s $s multi_pgbench_db
if [[ "$PGMEMENTO" == "y" ]]
then
cd pgMemento
psql -h $HOST -p $PORT -d multi_pgbench_db -f INSTALL_PGMEMENTO.sql
psql -h $HOST -p $PORT -d multi_pgbench_db -f INIT_PGMEMENTO.sql
cd ..
echo "pgMemento installed">>results/pgbench_results_$EXEC_TIME.log
fi
echo "------------------------------------------------------------------------------">>results/pgbench_results_$EXEC_TIME.log
pgbench -S -c $c -j $j -M prepared -T30 multi_pgbench_db >>results/pgbench_results_$EXEC_TIME.log
done
done
done
;;
*)
echo "Incorrect input! Please restart script"
;;
esac