Skip to content

Commit a1d021e

Browse files
committed
Add vcregress.pl target for checking pg_upgrade.
This follows recent addition of Windows/Mingw testing. Backpatch to Release 9.2 so we can get some buildfarm testing going.
1 parent 59f23fe commit a1d021e

File tree

2 files changed

+87
-8
lines changed

2 files changed

+87
-8
lines changed

src/tools/msvc/Install.pm

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,16 @@ sub Install
3737
$| = 1;
3838

3939
my $target = shift;
40-
our $config;
41-
require "config_default.pl";
42-
require "config.pl" if (-f "config.pl");
40+
# if called from vcregress, the config will be passed to us
41+
# so no need to re-include these
42+
our $config = shift;
43+
unless ($config)
44+
{
45+
# suppress warning about harmless redeclaration of $config
46+
no warnings 'misc';
47+
require "config_default.pl";
48+
require "config.pl" if (-f "config.pl");
49+
}
4350

4451
chdir("../../..") if (-f "../../../configure");
4552
chdir("../../../..") if (-f "../../../../configure");

src/tools/msvc/vcregress.pl

Lines changed: 77 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@
99
use Cwd;
1010
use File::Copy;
1111

12+
use Install qw(Install);
13+
1214
my $startdir = getcwd();
1315

1416
chdir "../../.." if (-d "../../../src/tools/msvc");
1517

18+
my $topdir = getcwd();
19+
1620
require 'src/tools/msvc/config_default.pl';
1721
require 'src/tools/msvc/config.pl' if (-f 'src/tools/msvc/config.pl');
1822

1923
# buildenv.pl is for specifying the build environment settings
20-
# it should contian lines like:
24+
# it should contain lines like:
2125
# $ENV{PATH} = "c:/path/to/bison/bin;$ENV{PATH}";
2226

2327
if (-e "src/tools/msvc/buildenv.pl")
@@ -27,7 +31,7 @@
2731

2832
my $what = shift || "";
2933
if ($what =~
30-
/^(check|installcheck|plcheck|contribcheck|ecpgcheck|isolationcheck)$/i)
34+
/^(check|installcheck|plcheck|contribcheck|ecpgcheck|isolationcheck|upgradecheck)$/i)
3135
{
3236
$what = uc $what;
3337
}
@@ -53,8 +57,6 @@
5357
$schedule = "parallel" if ($what eq 'CHECK' || $what =~ /PARALLEL/);
5458
}
5559

56-
my $topdir = getcwd();
57-
5860
$ENV{PERL5LIB} = "$topdir/src/tools/msvc";
5961

6062
my $maxconn = "";
@@ -73,7 +75,8 @@
7375
INSTALLCHECK => \&installcheck,
7476
ECPGCHECK => \&ecpgcheck,
7577
CONTRIBCHECK => \&contribcheck,
76-
ISOLATIONCHECK => \&isolationcheck,);
78+
ISOLATIONCHECK => \&isolationcheck,
79+
UPGRADECHECK => \&upgradecheck,);
7780

7881
my $proc = $command{$what};
7982

@@ -231,6 +234,75 @@ sub contribcheck
231234
exit $mstat if $mstat;
232235
}
233236

237+
sub upgradecheck
238+
{
239+
my $status;
240+
my $cwd = getcwd();
241+
242+
# Much of this comes from the pg_upgrade test.sh script,
243+
# but it only covers the --install case, and not the case
244+
# where the old and new source or bin dirs are different.
245+
# i.e. only the this version to this version check. That's
246+
# what pg_upgrade's "make check" does.
247+
248+
$ENV{PGPORT} ||= 50432;
249+
my $tmp_root = "$topdir/contrib/pg_upgrade/tmp_check";
250+
(mkdir $tmp_root || die $!) unless -d $tmp_root;
251+
my $tmp_install = "$tmp_root/install";
252+
print "Setting up temp install\n\n";
253+
Install($tmp_install, $config);
254+
# Install does a chdir, so change back after that
255+
chdir $cwd;
256+
my ($bindir,$libdir,$oldsrc,$newsrc) =
257+
("$tmp_install/bin", "$tmp_install/lib", $topdir, $topdir);
258+
$ENV{PATH} = "$bindir;$ENV{PATH}";
259+
my $data = "$tmp_root/data";
260+
$ENV{PGDATA} = $data;
261+
my $logdir = "$topdir/contrib/pg_upgrade/log";
262+
(mkdir $logdir || die $!) unless -d $logdir;
263+
print "\nRunning initdb on old cluster\n\n";
264+
system("initdb") == 0 or exit 1;
265+
print "\nStarting old cluster\n\n";
266+
system("pg_ctl start -l $logdir/postmaster1.log -w") == 0 or exit 1;
267+
print "\nSetting up data for upgrading\n\n";
268+
installcheck();
269+
# now we can chdir into the source dir
270+
chdir "$topdir/contrib/pg_upgrade";
271+
print "\nDuming old cluster\n\n";
272+
system("pg_dumpall -f $tmp_root/dump1.sql") == 0 or exit 1;
273+
print "\nStopping old cluster\n\n";
274+
system("pg_ctl -m fast stop") == 0 or exit 1;
275+
rename $data, "$data.old";
276+
print "\nSetting up new cluster\n\n";
277+
system("initdb") == 0 or exit 1;
278+
print "\nRunning pg_upgrade\n\n";
279+
system("pg_upgrade -d $data.old -D $data -b $bindir -B $bindir") == 0
280+
or exit 1;
281+
print "\nStarting new cluster\n\n";
282+
system("pg_ctl -l $logdir/postmaster2.log -w start") == 0 or exit 1;
283+
print "\nSetting up stats on new cluster\n\n";
284+
system(".\\analyze_new_cluster.bat") == 0 or exit 1;
285+
print "\nDumping new cluster\n\n";
286+
system("pg_dumpall -f $tmp_root/dump2.sql") == 0 or exit 1;
287+
print "\nStopping new cluster\n\n";
288+
system("pg_ctl -m fast stop") == 0 or exit 1;
289+
print "\nDeleting old cluster\n\n";
290+
system(".\\delete_old_cluster.bat") == 0 or exit 1;
291+
print "\nComparing old and new cluster dumps\n\n";
292+
293+
system("diff -q $tmp_root/dump1.sql $tmp_root/dump2.sql");
294+
$status = $?;
295+
if (!$status)
296+
{
297+
print "PASSED\n";
298+
}
299+
else
300+
{
301+
print "dumps not identical!\n";
302+
exit(1);
303+
}
304+
}
305+
234306
sub fetchRegressOpts
235307
{
236308
my $handle;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy