Skip to content

Commit e7d0cf4

Browse files
committed
Allow TAP tests to force checksums off when calling init()
TAP tests can write $node->init(no_data_checksums => 1); to initialize a cluster explicitly without checksums. Currently, this is the default, but this change allows running all tests with checksums enabled, like PG_TEST_INITDB_EXTRA_OPTS=--data-checksums meson test ... And this also prepares the tests for when we switch the default to checksums enabled. The pg_checksums tests need to disable checksums so it can test its own functionality of enabling checksums. The amcheck/pg_amcheck tests need to disable checksums because they manually introduce corruption that they want to detect, but with checksums enabled, the checksum verification will fail before they even get to their work. Author: Greg Sabino Mullane <[email protected]> Reviewed-by: Nathan Bossart <[email protected]> Reviewed-by: Peter Eisentraut <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/CAKAnmmKwiMHik5AHmBEdf5vqzbOBbcwEPHo4-PioWeAbzwcTOQ@mail.gmail.com
1 parent 199ad00 commit e7d0cf4

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

contrib/amcheck/t/001_verify_heapam.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Test set-up
1616
#
1717
$node = PostgreSQL::Test::Cluster->new('test');
18-
$node->init;
18+
$node->init(no_data_checksums => 1);
1919
$node->append_conf('postgresql.conf', 'autovacuum=off');
2020
$node->start;
2121
$node->safe_psql('postgres', q(CREATE EXTENSION amcheck));

src/bin/pg_amcheck/t/003_check.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ ()
120120

121121
# Test set-up
122122
$node = PostgreSQL::Test::Cluster->new('test');
123-
$node->init;
123+
$node->init(no_data_checksums => 1);
124124
$node->append_conf('postgresql.conf', 'autovacuum=off');
125125
$node->start;
126126
$port = $node->port;

src/bin/pg_amcheck/t/004_verify_heapam.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ sub write_tuple
181181
# autovacuum workers visiting the table could crash the backend.
182182
# Disable autovacuum so that won't happen.
183183
my $node = PostgreSQL::Test::Cluster->new('test');
184-
$node->init;
184+
$node->init(no_data_checksums => 1);
185185
$node->append_conf('postgresql.conf', 'autovacuum=off');
186186
$node->append_conf('postgresql.conf', 'max_prepared_transactions=10');
187187

src/bin/pg_checksums/t/002_actions.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ sub check_relation_corruption
8888

8989
# Initialize node with checksums disabled.
9090
my $node = PostgreSQL::Test::Cluster->new('node_checksum');
91-
$node->init();
91+
$node->init(no_data_checksums => 1);
9292
my $pgdata = $node->data_dir;
9393

9494
# Control file should know that checksums are disabled.

src/test/perl/PostgreSQL/Test/Cluster.pm

+8
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,8 @@ On Windows, we use SSPI authentication to ensure the same (by pg_regress
586586
WAL archiving can be enabled on this node by passing the keyword parameter
587587
has_archiving => 1. This is disabled by default.
588588
589+
Data checksums can be forced off by passing no_data_checksums => 1.
590+
589591
postgresql.conf can be set up for replication by passing the keyword
590592
parameter allows_streaming => 'logical' or 'physical' (passing 1 will also
591593
suffice for physical replication) depending on type of replication that
@@ -618,6 +620,12 @@ sub init
618620
push @{ $params{extra} }, shellwords($initdb_extra_opts_env);
619621
}
620622

623+
# This should override user-supplied initdb options.
624+
if ($params{no_data_checksums})
625+
{
626+
push @{ $params{extra} }, '--no-data-checksums';
627+
}
628+
621629
mkdir $self->backup_dir;
622630
mkdir $self->archive_dir;
623631

0 commit comments

Comments
 (0)