summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas2021-03-23 18:57:45 +0000
committerRobert Haas2021-03-23 18:57:45 +0000
commit87d90ac61fa113ffc886efcdb391c522c1982991 (patch)
tree2013c9a340b03b0145d3990727502619d4d218c8
parentea80138545043c0cfcff8405b15626796f2695fe (diff)
Improve pg_amcheck's TAP test 003_check.pl.
Disable autovacuum, because we don't want it to run against intentionally corrupted tables. Also, before corrupting the tables, run pg_amcheck and ensure that it passes. Otherwise, if something unexpected happens when we check the corrupted tables, it's not so clear whether it would have also happened before we corrupted them. Mark Dilger Discussion: http://postgr.es/m/AA5506CE-7D2A-42E4-A51D-358635E3722D@enterprisedb.com
-rw-r--r--src/bin/pg_amcheck/t/003_check.pl24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/bin/pg_amcheck/t/003_check.pl b/src/bin/pg_amcheck/t/003_check.pl
index 54b2b86a49b..66dd14e498b 100644
--- a/src/bin/pg_amcheck/t/003_check.pl
+++ b/src/bin/pg_amcheck/t/003_check.pl
@@ -3,7 +3,7 @@ use warnings;
use PostgresNode;
use TestLib;
-use Test::More tests => 60;
+use Test::More tests => 63;
my ($node, $port, %corrupt_page, %remove_relation);
@@ -117,6 +117,7 @@ sub perform_all_corruptions()
# Test set-up
$node = get_new_node('test');
$node->init;
+$node->append_conf('postgresql.conf', 'autovacuum=off');
$node->start;
$port = $node->port;
@@ -308,11 +309,6 @@ plan_to_remove_relation_file('db2', 's1.t1_btree');
# Leave 'db3' uncorrupted
#
-# Perform the corruptions we planned above using only a single database restart.
-#
-perform_all_corruptions();
-
-
# Standard first arguments to TestLib functions
my @cmd = ('pg_amcheck', '--quiet', '-p', $port);
@@ -322,6 +318,22 @@ my $line_pointer_corruption_re = qr/line pointer/;
my $missing_file_re = qr/could not open file ".*": No such file or directory/;
my $index_missing_relation_fork_re = qr/index ".*" lacks a main relation fork/;
+# We have created test databases with tables populated with data, but have not
+# yet corrupted anything. As such, we expect no corruption and verify that
+# none is reported
+#
+$node->command_checks_all(
+ [ @cmd, '-d', 'db1', '-d', 'db2', '-d', 'db3' ],
+ 0,
+ [ $no_output_re ],
+ [ $no_output_re ],
+ 'pg_amcheck prior to corruption');
+
+# Perform the corruptions we planned above using only a single database restart.
+#
+perform_all_corruptions();
+
+
# Checking databases with amcheck installed and corrupt relations, pg_amcheck
# command itself should return exit status = 2, because tables and indexes are
# corrupt, not exit status = 1, which would mean the pg_amcheck command itself