Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit08da2d2

Browse files
committed
Add pg_upgrade test suite
It runs the regression tests, runs pg_upgrade on the populateddatabase, and compares the before and after dumps. While not actuallya cross-version upgrade, this does detect omissions and bugs in theinvolved tools from time to time. It's also possible to do across-version upgrade by manually supplying parameters.
1 parent8722a1a commit08da2d2

File tree

6 files changed

+156
-2
lines changed

6 files changed

+156
-2
lines changed

‎contrib/pg_upgrade/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
/pg_upgrade
2+
# Generated by test suite
3+
delete_old_cluster.sh
4+
/log/
5+
/tmp_check/

‎contrib/pg_upgrade/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,11 @@ top_builddir = ../..
2121
include$(top_builddir)/src/Makefile.global
2222
include$(top_srcdir)/contrib/contrib-global.mk
2323
endif
24+
25+
check: test.sh
26+
MAKE=$(MAKE) bindir=$(bindir) libdir=$(libdir)$(SHELL)$< --install
27+
28+
installcheck: test.sh
29+
MAKE=$(MAKE) bindir=$(bindir) libdir=$(libdir)$(SHELL)$<
30+
31+
EXTRA_CLEAN = delete_old_cluster.sh log/ tmp_check/

‎contrib/pg_upgrade/TESTING

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,22 @@ steps:
6262

6363
7) Diff the regression database dump file with the regression dump
6464
file loaded into the old server.
65+
66+
The shell script test.sh in this directory performs more or less this
67+
procedure. You can invoke it by running
68+
69+
gmake check
70+
71+
or by running
72+
73+
gmake installcheck
74+
75+
if "gmake install" (or "gmake install-world") were done beforehand.
76+
When invoked without arguments, it will run an upgrade from the
77+
version in this source tree to a new instance of the same version. To
78+
test an upgrade from a different version, invoke it like this:
79+
80+
gmake installcheck oldbindir=...otherversion/bin oldsrc=...somewhere/postgresql
81+
82+
In this case, you will have to manually eyeball the resulting dump
83+
diff for version-specific differences, as explained above.

‎contrib/pg_upgrade/test.sh

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#!/bin/sh
2+
3+
# contrib/pg_upgrade/test.sh
4+
#
5+
# Test driver for pg_upgrade. Initializes a new database cluster,
6+
# runs the regression tests (to put in some data), runs pg_dumpall,
7+
# runs pg_upgrade, runs pg_dumpall again, compares the dumps.
8+
#
9+
# Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
10+
# Portions Copyright (c) 1994, Regents of the University of California
11+
12+
set -e
13+
14+
:${MAKE=make}
15+
:${PGPORT=50432}
16+
export PGPORT
17+
18+
temp_root=$PWD/tmp_check
19+
20+
if ["$1"='--install' ];then
21+
temp_install=$temp_root/install
22+
bindir=$temp_install/$bindir
23+
libdir=$temp_install/$libdir
24+
25+
"$MAKE" -s -C ../.. install DESTDIR="$temp_install"
26+
"$MAKE" -s -C ../pg_upgrade_support install DESTDIR="$temp_install"
27+
"$MAKE" -s -C. install DESTDIR="$temp_install"
28+
29+
# platform-specific magic to find the shared libraries; see pg_regress.c
30+
LD_LIBRARY_PATH=$libdir:$LD_LIBRARY_PATH
31+
export LD_LIBRARY_PATH
32+
DYLD_LIBRARY_PATH=$libdir:$DYLD_LIBRARY_PATH
33+
export DYLD_LIBRARY_PATH
34+
LIBPATH=$libdir:$LIBPATH
35+
export LIBPATH
36+
PATH=$libdir:$PATH
37+
38+
# We need to make it use psql from our temporary installation,
39+
# because otherwise the installcheck run below would try to
40+
# use psql from the proper installation directory, which might
41+
# be outdated or missing.
42+
EXTRA_REGRESS_OPTS=--psqldir=$bindir
43+
export EXTRA_REGRESS_OPTS
44+
fi
45+
46+
:${oldbindir=$bindir}
47+
48+
:${oldsrc=../..}
49+
oldsrc=`cd"$oldsrc"&& pwd`
50+
newsrc=`cd ../..&& pwd`
51+
52+
PATH=$bindir:$PATH
53+
export PATH
54+
55+
PGDATA=$temp_root/data
56+
export PGDATA
57+
rm -rf"$PGDATA""$PGDATA".old
58+
59+
logdir=$PWD/log
60+
rm -rf"$logdir"
61+
mkdir"$logdir"
62+
63+
set -x
64+
65+
$oldbindir/initdb
66+
$oldbindir/pg_ctl start -l"$logdir/postmaster1.log" -w
67+
if"$MAKE" -C"$oldsrc" installcheck;then
68+
pg_dumpall>"$temp_root"/dump1.sql|| pg_dumpall1_status=$?
69+
if ["$newsrc"!="$oldsrc" ];then
70+
oldpgversion=`psql -A -t -d regression -c"SHOW server_version_num"`
71+
fix_sql=""
72+
case$oldpgversionin
73+
804??)
74+
fix_sql="UPDATE pg_proc SET probin = replace(probin::text, '$oldsrc', '$newsrc')::bytea WHERE probin LIKE '$oldsrc%'; DROP FUNCTION public.myfunc(integer);"
75+
;;
76+
900??)
77+
fix_sql="SET bytea_output TO escape; UPDATE pg_proc SET probin = replace(probin::text, '$oldsrc', '$newsrc')::bytea WHERE probin LIKE '$oldsrc%';"
78+
;;
79+
901??)
80+
fix_sql="UPDATE pg_proc SET probin = replace(probin, '$oldsrc', '$newsrc') WHERE probin LIKE '$oldsrc%';"
81+
;;
82+
esac
83+
psql -d regression -c"$fix_sql;"|| psql_fix_sql_status=$?
84+
85+
mv"$temp_root"/dump1.sql"$temp_root"/dump1.sql.orig
86+
sed"s;$oldsrc;$newsrc;g""$temp_root"/dump1.sql.orig>"$temp_root"/dump1.sql
87+
fi
88+
else
89+
make_installcheck_status=$?
90+
fi
91+
$oldbindir/pg_ctl -m fast stop
92+
if [-n"$make_installcheck_status" ];then
93+
exit 1
94+
fi
95+
if [-n"$psql_fix_sql_status" ];then
96+
exit 1
97+
fi
98+
if [-n"$pg_dumpall1_status" ];then
99+
echo"pg_dumpall of pre-upgrade database cluster failed"
100+
exit 1
101+
fi
102+
103+
mv"${PGDATA}""${PGDATA}.old"
104+
105+
initdb
106+
107+
pg_upgrade -d"${PGDATA}.old" -D"${PGDATA}" -b"$oldbindir" -B"$bindir"
108+
109+
pg_ctl start -l"$logdir/postmaster2.log" -w
110+
pg_dumpall>"$temp_root"/dump2.sql|| pg_dumpall2_status=$?
111+
pg_ctl -m fast stop
112+
if [-n"$pg_dumpall2_status" ];then
113+
echo"pg_dumpall of post-upgrade database cluster failed"
114+
exit 1
115+
fi
116+
117+
if diff -q"$temp_root"/dump1.sql"$temp_root"/dump2.sql;then
118+
echo PASSED
119+
exit 0
120+
else
121+
echo"dumps were not identical"
122+
exit 1
123+
fi

‎src/makefiles/pgxs.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ ifdef OBJS
207207
rm -f $(OBJS)
208208
endif
209209
ifdefEXTRA_CLEAN
210-
rm -f $(EXTRA_CLEAN)
210+
rm -rf $(EXTRA_CLEAN)
211211
endif
212212
ifdefREGRESS
213213
# things created by various check targets

‎src/test/regress/GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ tablespace-setup:
132132
## Run tests
133133
##
134134

135-
REGRESS_OPTS = --dlpath=.
135+
REGRESS_OPTS = --dlpath=.$(EXTRA_REGRESS_OPTS)
136136

137137
check: all tablespace-setup
138138
$(pg_regress_check)$(REGRESS_OPTS) --schedule=$(srcdir)/parallel_schedule$(MAXCONNOPT)$(TEMP_CONF)$(EXTRA_TESTS)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp