-
Notifications
You must be signed in to change notification settings - Fork 0
/
pgall
152 lines (126 loc) · 4.83 KB
/
pgall
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/sh
set -e
here="$(dirname "${BASH_SOURCE[0]}")"
start="$(date +%s)"
pgoptions="-c shared_buffers=16384"
locale=uk_UA.UTF-8
encoding=unicode
wordlist=/usr/share/dict/ukrainian
export LC_ALL=$locale
export LC_COLLATE=$LC_ALL
export LC_CTYPE=$LC_ALL
export LC_NUMERIC=C # c.f. REL7_3~975
export LC_TIME=C
export LC_MESSAGES=C
RELS="$(for v in /usr/local/oldpgsql/*/bin/initdb ; do echo "$v" | sed 's,.*/[0-9]*-[0-9]*-[0-9]*-\([^/]*\)/bin/initdb,\1,' ; done | sort -R)"
NRELS="$(for v in $RELS; do echo "$v" ; done | wc -l)"
N=0
for ver in $RELS ; do
d="$(echo /usr/local/oldpgsql/*-$ver)"
rel="$(basename $d)"
now="$(date +%s)"
if [[ $N > 0 ]]; then
elapsed=$(( ( $now - $start ) / $N ))
remaining=$(( ( $NRELS - $N ) * $elapsed ))
eta=$(( $now + $remaining ))
remaining_str="$( LC_ALL=C date +%Hh%MM -d @$remaining )"
eta_str="$( LC_ALL=C date -d @$eta )"
fi
N=$(( N + 1 ))
if [[ ! -f $d/bin/initdb ]] ; then
echo
echo "========================================================================"
echo "Skipping $rel ($N/$NRELS)"
echo "========================================================================"
continue
fi
TESTDIR="/var/tmp/oldpgsql"
if [[ ! -d $TESTDIR ]] ; then
mkdir $TESTDIR
fi
bin="$d/bin"
lib="$d/lib"
binfallback="$(echo "$d/../*-REL7_3_21/bin")"
db="$TESTDIR/d-$rel"
log="$TESTDIR/l-$rel.log"
out="$TESTDIR/o-$rel.out"
echo
echo "========================================================================"
echo "Testing $rel ($N/$NRELS)"
echo "Logs in: $log"
echo "Output in: $out"
echo "Remaining: $remaining_str"
echo "ETA: $eta_str"
echo "========================================================================"
if [ ! -d $db ] ; then
echo "Running initdb for $rel in $db"
initdbargs=""
if PATH=$bin:$PATH LD_LIBRARY_PATH=$lib $bin/initdb --help | grep -e --encoding >/dev/null ; then
initdbargs="$initdbargs --encoding $encoding"
fi
if PATH=$bin:$PATH LD_LIBRARY_PATH=$lib $bin/initdb --help | grep -e --locale >/dev/null ; then
initdbargs="$initdbargs --locale $LC_ALL"
fi
if PATH=$bin:$PATH LD_LIBRARY_PATH=$lib $bin/initdb --help | grep -e --lc-numeric >/dev/null ; then
initdbargs="$initdbargs --lc-numeric C"
fi
if PATH=$bin:$PATH LD_LIBRARY_PATH=$lib $bin/initdb --help | grep -e --lc-time >/dev/null ; then
initdbargs="$initdbargs --lc-time C"
fi
if PATH=$bin:$PATH LD_LIBRARY_PATH=$lib $bin/initdb --help | grep -e --lc-messages >/dev/null ; then
initdbargs="$initdbargs --lc-messages C"
fi
PATH=$bin:$PATH LD_LIBRARY_PATH=$lib $bin/initdb -D $db $initdbargs || continue
fi
if [[ -e /tmp/.s.PGSQL.5432 ]] ; then
echo /tmp/.s.PGSQL.5432 already exists
fi
trap "$bin/pg_ctl -D $db stop" EXIT
$bin/pg_ctl -D $db -l $log -o "$pgoptions" start || PATH=$bin:$PATH LD_LIBRARY_PATH=$lib $bin/postmaster -D $db $pgoptions > $log 2>&1 &
echo -n "Waiting for $rel to start up..."
for i in `seq 1 30` ; do
sleep 1
PATH=$bin:$PATH LD_LIBRARY_PATH=$lib $bin/psql -o /dev/null -X template1 -c 'select 1' 2>/dev/null && break
echo -n .
done
if PATH=$bin:$PATH LD_LIBRARY_PATH=$lib $bin/psql -o /dev/null -X template1 -c 'select 1' ; then
echo done
else
$bin/pg_ctl -D $db stop -m fast || echo pg_ctl exited with status $?
trap - EXIT
continue
fi
if ! PATH=$bin:$PATH LD_LIBRARY_PATH=$lib $bin/psql -o /dev/null -X -c 'select 1'; then
createdbargs=""
if PATH=$bin:$PATH LD_LIBRARY_PATH=$lib $bin/createdb --help | grep -e '--encoding' >/dev/null; then
createdbargs="$createdbargs --encoding unicode"
fi
if PATH=$bin:$PATH LD_LIBRARY_PATH=$lib $bin/createdb --help | grep -e '--locale' >/dev/null; then
createdbargs="$createdbargs --locale $locale"
fi
if PATH=$bin:$PATH LD_LIBRARY_PATH=$lib $bin/createdb --help | grep -e '--lc_collate' >/dev/null; then
createdbargs="$createdbargs --lc_collate $locale"
fi
if PATH=$bin:$PATH LD_LIBRARY_PATH=$lib $bin/createdb --help | grep -e '--lc_ctype' >/dev/null; then
createdbargs="$createdbargs --lc_ctype $locale"
fi
echo "Creating and initializing db for $rel"
PATH=$bin:$PATH LD_LIBRARY_PATH=$lib $bin/createdb $createdbargs
PATH=$bin:$PATH LD_LIBRARY_PATH=$lib $bin/psql -X --set wordlist="'$wordlist'" -f $here/benchmark-setup.sql
fi
#PATH=$bin:$PATH LD_LIBRARY_PATH=$lib $bin/psql -X -f $here/benchmark-fix.sql
if [[ "2003" < "$rel" ]] ; then
psql="$bin/psql"
else
# We need this version for \timing
psql="$binfallback/psql"
fi
sync
sleep 1
echo -n "Running Benchmark on $rel..."
TIMEFORMAT=%0lR
time ( ( $psql -X -f $here/benchmark-run-x8.sql; $psql -X -f $here/benchmark-run-x8.sql ) >>$out 2>&1 || echo psql exited with status $?)
unset TIMEFORMAT
trap - EXIT
$bin/pg_ctl -D $db stop -m fast || echo pg_ctl exited with status $?
done