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

Commit9814ff5

Browse files
committed
Add custom filtering rules to the TAP tests of pg_upgrade
002_pg_upgrade.pl gains support for a new environment variable called"filter_rules", that can be used to point to a file that includes aset of custom regular expressions that would be applied to the dumps ofthe origin and target clusters when doing a cross-version test (aka whendefining olddump and oldinstall), to give the possibility to reshapedynamically the dumps in the same way as the internals of the buildfarmcode so as the tests are able to pass in scenarios where one expectsthem to even if pg_dump generates slightly-different outputs dependingon the versions involved.This option is not used when pg_upgrade runs with the same version forthe origin and target clusters, and it is the last piece I see asrequired to be able to plug-in more efficiently the TAP tests ofpg_upgrade with the buildfarm or just a CI.Author: Anton A. MelnikovDiscussion:https://postgr.es/m/49f389ba-95ce-8a9b-09ae-f60650c0e7c7@inbox.ru
1 parent2259c66 commit9814ff5

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

‎src/bin/pg_upgrade/TESTING

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@ the creation of the dump):
1717
export olddump=...somewhere/dump.sql(old version's dump)
1818
export oldinstall=...otherversion/(old version's install base path)
1919

20+
"filter_rules" is a variable that can be used to specify a file with custom
21+
filtering rules applied before comparing the dumps of the PostgreSQL
22+
instances near the end of the tests, in the shape of regular expressions
23+
valid for perl. This is useful to enforce certain validation cases where
24+
pg_dump could create inconsistent outputs across major versions.
25+
For example:
26+
27+
# Remove all CREATE POLICY statements
28+
s/^CREATE\sPOLICY.*//mgx
29+
# Replace REFRESH with DROP for materialized views
30+
s/^REFRESH\s(MATERIALIZED\sVIEW)/DROP $1/mgx
31+
32+
Lines beginning with '#' and empty lines are ignored. One rule can be
33+
defined per line.
34+
2035
Finally, the tests can be done by running
2136

2237
make check

‎src/bin/pg_upgrade/t/002_pg_upgrade.pl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,31 @@ sub filter_dump
4545
# Remove empty lines.
4646
$dump_contents =~s/^\n//mgx;
4747

48+
# Apply custom filtering rules, if any.
49+
if (defined($ENV{filter_rules}))
50+
{
51+
my$filter_file =$ENV{filter_rules};
52+
die"no file with custom filter rules found!"unless-e$filter_file;
53+
54+
openmy$filter_handle,'<',$filter_file
55+
ordie"could not open$filter_file";
56+
while (<$filter_handle>)
57+
{
58+
my$filter_line =$_;
59+
60+
# Skip comments and empty lines
61+
nextif ($filter_line =~/^#/);
62+
nextif ($filter_line =~/^\s*$/);
63+
64+
# Apply lines with filters.
65+
note"Applying custom rule$filter_line to$dump_file";
66+
my$filter ="\$dump_contents =~$filter_line";
67+
## no critic (ProhibitStringyEval)
68+
eval$filter;
69+
}
70+
close$filter_handle;
71+
}
72+
4873
my$dump_file_filtered ="${dump_file}_filtered";
4974
open(my$dh,'>',$dump_file_filtered)
5075
||die"opening$dump_file_filtered";

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp