diff options
Diffstat (limited to 'src/test')
20 files changed, 244 insertions, 168 deletions
diff --git a/src/test/modules/test_aio/t/002_io_workers.pl b/src/test/modules/test_aio/t/002_io_workers.pl index af5fae15ea7..22914385df3 100644 --- a/src/test/modules/test_aio/t/002_io_workers.pl +++ b/src/test/modules/test_aio/t/002_io_workers.pl @@ -67,8 +67,9 @@ sub change_number_of_io_workers if ($expect_failure) { - ok( $stderr =~ - /$worker_count is outside the valid range for parameter "io_workers"/, + like( + $stderr, + qr/$worker_count is outside the valid range for parameter "io_workers"/, "updating number of io_workers to $worker_count failed, as expected" ); diff --git a/src/test/modules/test_misc/t/001_constraint_validation.pl b/src/test/modules/test_misc/t/001_constraint_validation.pl index 1d86936ec69..bdc751724f4 100644 --- a/src/test/modules/test_misc/t/001_constraint_validation.pl +++ b/src/test/modules/test_misc/t/001_constraint_validation.pl @@ -58,8 +58,9 @@ run_sql_command( # normal run will verify table data $output = run_sql_command('alter table atacc1 alter test_a set not null;'); ok(!is_table_verified($output), 'with constraint will not scan table'); -ok( $output =~ - m/existing constraints on column "atacc1.test_a" are sufficient to prove that it does not contain nulls/, +like( + $output, + qr/existing constraints on column "atacc1.test_a" are sufficient to prove that it does not contain nulls/, 'test_a proved by constraints'); run_sql_command('alter table atacc1 alter test_a drop not null;'); @@ -70,9 +71,9 @@ $output = run_sql_command( ); ok(is_table_verified($output), 'table was scanned'); # we may miss debug message for test_a constraint because we need verify table due test_b -ok( !( $output =~ - m/existing constraints on column "atacc1.test_b" are sufficient to prove that it does not contain nulls/ - ), +unlike( + $output, + qr/existing constraints on column "atacc1.test_b" are sufficient to prove that it does not contain nulls/, 'test_b not proved by wrong constraints'); run_sql_command( 'alter table atacc1 alter test_a drop not null, alter test_b drop not null;' @@ -86,11 +87,13 @@ $output = run_sql_command( 'alter table atacc1 alter test_b set not null, alter test_a set not null;' ); ok(!is_table_verified($output), 'table was not scanned for both columns'); -ok( $output =~ - m/existing constraints on column "atacc1.test_a" are sufficient to prove that it does not contain nulls/, +like( + $output, + qr/existing constraints on column "atacc1.test_a" are sufficient to prove that it does not contain nulls/, 'test_a proved by constraints'); -ok( $output =~ - m/existing constraints on column "atacc1.test_b" are sufficient to prove that it does not contain nulls/, +like( + $output, + qr/existing constraints on column "atacc1.test_b" are sufficient to prove that it does not contain nulls/, 'test_b proved by constraints'); run_sql_command('drop table atacc1;'); @@ -119,8 +122,9 @@ $output = run_sql_command( 'ALTER TABLE list_parted2 ATTACH PARTITION part_3_4 FOR VALUES IN (3, 4);' ); ok(!is_table_verified($output), 'table part_3_4 not scanned'); -ok( $output =~ - m/partition constraint for table "part_3_4" is implied by existing constraints/, +like( + $output, + qr/partition constraint for table "part_3_4" is implied by existing constraints/, 'part_3_4 verified by existing constraints'); # test attach default partition @@ -131,16 +135,18 @@ run_sql_command( $output = run_sql_command( 'ALTER TABLE list_parted2 ATTACH PARTITION list_parted2_def default;'); ok(!is_table_verified($output), 'table list_parted2_def not scanned'); -ok( $output =~ - m/partition constraint for table "list_parted2_def" is implied by existing constraints/, +like( + $output, + qr/partition constraint for table "list_parted2_def" is implied by existing constraints/, 'list_parted2_def verified by existing constraints'); $output = run_sql_command( 'CREATE TABLE part_55_66 PARTITION OF list_parted2 FOR VALUES IN (55, 66);' ); ok(!is_table_verified($output), 'table list_parted2_def not scanned'); -ok( $output =~ - m/updated partition constraint for default partition "list_parted2_def" is implied by existing constraints/, +like( + $output, + qr/updated partition constraint for default partition "list_parted2_def" is implied by existing constraints/, 'updated partition constraint for default partition list_parted2_def'); # test attach another partitioned table @@ -153,11 +159,14 @@ run_sql_command( ); $output = run_sql_command( 'ALTER TABLE list_parted2 ATTACH PARTITION part_5 FOR VALUES IN (5);'); -ok(!($output =~ m/verifying table "part_5"/), 'table part_5 not scanned'); -ok($output =~ m/verifying table "list_parted2_def"/, +unlike($output, qr/verifying table "part_5"/, 'table part_5 not scanned'); +like( + $output, + qr/verifying table "list_parted2_def"/, 'list_parted2_def scanned'); -ok( $output =~ - m/partition constraint for table "part_5" is implied by existing constraints/, +like( + $output, + qr/partition constraint for table "part_5" is implied by existing constraints/, 'part_5 verified by existing constraints'); run_sql_command( @@ -171,11 +180,14 @@ run_sql_command( ); $output = run_sql_command( 'ALTER TABLE list_parted2 ATTACH PARTITION part_5 FOR VALUES IN (5);'); -ok(!($output =~ m/verifying table "part_5"/), 'table part_5 not scanned'); -ok($output =~ m/verifying table "list_parted2_def"/, +unlike($output, qr/verifying table "part_5"/, 'table part_5 not scanned'); +like( + $output, + qr/verifying table "list_parted2_def"/, 'list_parted2_def scanned'); -ok( $output =~ - m/partition constraint for table "part_5" is implied by existing constraints/, +like( + $output, + qr/partition constraint for table "part_5" is implied by existing constraints/, 'part_5 verified by existing constraints'); # Check the case where attnos of the partitioning columns in the table being @@ -190,11 +202,14 @@ run_sql_command( ALTER TABLE part_6 DROP c;'); $output = run_sql_command( 'ALTER TABLE list_parted2 ATTACH PARTITION part_6 FOR VALUES IN (6);'); -ok(!($output =~ m/verifying table "part_6"/), 'table part_6 not scanned'); -ok($output =~ m/verifying table "list_parted2_def"/, +unlike($output, qr/verifying table "part_6"/, 'table part_6 not scanned'); +like( + $output, + qr/verifying table "list_parted2_def"/, 'list_parted2_def scanned'); -ok( $output =~ - m/partition constraint for table "part_6" is implied by existing constraints/, +like( + $output, + qr/partition constraint for table "part_6" is implied by existing constraints/, 'part_6 verified by existing constraints'); # Similar to above, but the table being attached is a partitioned table @@ -219,17 +234,20 @@ $output = run_sql_command( 'ALTER TABLE part_7 ATTACH PARTITION part_7_a_null FOR VALUES IN (\'a\', null);' ); ok(!is_table_verified($output), 'table not scanned'); -ok( $output =~ - m/partition constraint for table "part_7_a_null" is implied by existing constraints/, +like( + $output, + qr/partition constraint for table "part_7_a_null" is implied by existing constraints/, 'part_7_a_null verified by existing constraints'); $output = run_sql_command( 'ALTER TABLE list_parted2 ATTACH PARTITION part_7 FOR VALUES IN (7);'); ok(!is_table_verified($output), 'tables not scanned'); -ok( $output =~ - m/partition constraint for table "part_7" is implied by existing constraints/, +like( + $output, + qr/partition constraint for table "part_7" is implied by existing constraints/, 'part_7 verified by existing constraints'); -ok( $output =~ - m/updated partition constraint for default partition "list_parted2_def" is implied by existing constraints/, +like( + $output, + qr/updated partition constraint for default partition "list_parted2_def" is implied by existing constraints/, 'updated partition constraint for default partition list_parted2_def'); run_sql_command( @@ -245,9 +263,9 @@ $output = run_sql_command( 'ALTER TABLE range_parted ATTACH PARTITION range_part1 FOR VALUES FROM (1, 1) TO (1, 10);' ); ok(is_table_verified($output), 'table range_part1 scanned'); -ok( !( $output =~ - m/partition constraint for table "range_part1" is implied by existing constraints/ - ), +unlike( + $output, + qr/partition constraint for table "range_part1" is implied by existing constraints/, 'range_part1 not verified by existing constraints'); run_sql_command( @@ -259,8 +277,9 @@ $output = run_sql_command( 'ALTER TABLE range_parted ATTACH PARTITION range_part2 FOR VALUES FROM (1, 10) TO (1, 20);' ); ok(!is_table_verified($output), 'table range_part2 not scanned'); -ok( $output =~ - m/partition constraint for table "range_part2" is implied by existing constraints/, +like( + $output, + qr/partition constraint for table "range_part2" is implied by existing constraints/, 'range_part2 verified by existing constraints'); # If a partitioned table being created or an existing table being attached @@ -278,19 +297,22 @@ run_sql_command( $output = run_sql_command( 'ALTER TABLE quuux ATTACH PARTITION quuux1 FOR VALUES IN (1);'); ok(is_table_verified($output), 'quuux1 table scanned'); -ok( !( $output =~ - m/partition constraint for table "quuux1" is implied by existing constraints/ - ), +unlike( + $output, + qr/partition constraint for table "quuux1" is implied by existing constraints/, 'quuux1 verified by existing constraints'); run_sql_command('CREATE TABLE quuux2 (a int, b text);'); $output = run_sql_command( 'ALTER TABLE quuux ATTACH PARTITION quuux2 FOR VALUES IN (2);'); -ok(!($output =~ m/verifying table "quuux_default1"/), +unlike( + $output, + qr/verifying table "quuux_default1"/, 'quuux_default1 not scanned'); -ok($output =~ m/verifying table "quuux2"/, 'quuux2 scanned'); -ok( $output =~ - m/updated partition constraint for default partition "quuux_default1" is implied by existing constraints/, +like($output, qr/verifying table "quuux2"/, 'quuux2 scanned'); +like( + $output, + qr/updated partition constraint for default partition "quuux_default1" is implied by existing constraints/, 'updated partition constraint for default partition quuux_default1'); run_sql_command('DROP TABLE quuux1, quuux2;'); @@ -298,15 +320,16 @@ run_sql_command('DROP TABLE quuux1, quuux2;'); $output = run_sql_command( 'CREATE TABLE quuux1 PARTITION OF quuux FOR VALUES IN (1);'); ok(!is_table_verified($output), 'tables not scanned'); -ok( !( $output =~ - m/partition constraint for table "quuux1" is implied by existing constraints/ - ), +unlike( + $output, + qr/partition constraint for table "quuux1" is implied by existing constraints/, 'quuux1 verified by existing constraints'); $output = run_sql_command( 'CREATE TABLE quuux2 PARTITION OF quuux FOR VALUES IN (2);'); ok(!is_table_verified($output), 'tables not scanned'); -ok( $output =~ - m/updated partition constraint for default partition "quuux_default1" is implied by existing constraints/, +like( + $output, + qr/updated partition constraint for default partition "quuux_default1" is implied by existing constraints/, 'updated partition constraint for default partition quuux_default1'); run_sql_command('DROP TABLE quuux;'); diff --git a/src/test/modules/test_misc/t/002_tablespace.pl b/src/test/modules/test_misc/t/002_tablespace.pl index b8a5617c788..972215b76c6 100644 --- a/src/test/modules/test_misc/t/002_tablespace.pl +++ b/src/test/modules/test_misc/t/002_tablespace.pl @@ -29,69 +29,69 @@ my $result; # Create a tablespace with an absolute path $result = $node->psql('postgres', "CREATE TABLESPACE regress_ts1 LOCATION '$TS1_LOCATION'"); -ok($result == 0, 'create tablespace with absolute path'); +is($result, 0, 'create tablespace with absolute path'); # Can't create a tablespace where there is one already $result = $node->psql('postgres', "CREATE TABLESPACE regress_ts1 LOCATION '$TS1_LOCATION'"); -ok($result != 0, 'clobber tablespace with absolute path'); +isnt($result, 0, 'clobber tablespace with absolute path'); # Create table in it $result = $node->psql('postgres', "CREATE TABLE t () TABLESPACE regress_ts1"); -ok($result == 0, 'create table in tablespace with absolute path'); +is($result, 0, 'create table in tablespace with absolute path'); # Can't drop a tablespace that still has a table in it $result = $node->psql('postgres', "DROP TABLESPACE regress_ts1"); -ok($result != 0, 'drop tablespace with absolute path'); +isnt($result, 0, 'drop tablespace with absolute path'); # Drop the table $result = $node->psql('postgres', "DROP TABLE t"); -ok($result == 0, 'drop table in tablespace with absolute path'); +is($result, 0, 'drop table in tablespace with absolute path'); # Drop the tablespace $result = $node->psql('postgres', "DROP TABLESPACE regress_ts1"); -ok($result == 0, 'drop tablespace with absolute path'); +is($result, 0, 'drop tablespace with absolute path'); # Create two absolute tablespaces and two in-place tablespaces, so we can # testing various kinds of tablespace moves. $result = $node->psql('postgres', "CREATE TABLESPACE regress_ts1 LOCATION '$TS1_LOCATION'"); -ok($result == 0, 'create tablespace 1 with absolute path'); +is($result, 0, 'create tablespace 1 with absolute path'); $result = $node->psql('postgres', "CREATE TABLESPACE regress_ts2 LOCATION '$TS2_LOCATION'"); -ok($result == 0, 'create tablespace 2 with absolute path'); +is($result, 0, 'create tablespace 2 with absolute path'); $result = $node->psql('postgres', "SET allow_in_place_tablespaces=on; CREATE TABLESPACE regress_ts3 LOCATION ''" ); -ok($result == 0, 'create tablespace 3 with in-place directory'); +is($result, 0, 'create tablespace 3 with in-place directory'); $result = $node->psql('postgres', "SET allow_in_place_tablespaces=on; CREATE TABLESPACE regress_ts4 LOCATION ''" ); -ok($result == 0, 'create tablespace 4 with in-place directory'); +is($result, 0, 'create tablespace 4 with in-place directory'); # Create a table and test moving between absolute and in-place tablespaces $result = $node->psql('postgres', "CREATE TABLE t () TABLESPACE regress_ts1"); -ok($result == 0, 'create table in tablespace 1'); +is($result, 0, 'create table in tablespace 1'); $result = $node->psql('postgres', "ALTER TABLE t SET tablespace regress_ts2"); -ok($result == 0, 'move table abs->abs'); +is($result, 0, 'move table abs->abs'); $result = $node->psql('postgres', "ALTER TABLE t SET tablespace regress_ts3"); -ok($result == 0, 'move table abs->in-place'); +is($result, 0, 'move table abs->in-place'); $result = $node->psql('postgres', "ALTER TABLE t SET tablespace regress_ts4"); -ok($result == 0, 'move table in-place->in-place'); +is($result, 0, 'move table in-place->in-place'); $result = $node->psql('postgres', "ALTER TABLE t SET tablespace regress_ts1"); -ok($result == 0, 'move table in-place->abs'); +is($result, 0, 'move table in-place->abs'); # Drop everything $result = $node->psql('postgres', "DROP TABLE t"); -ok($result == 0, 'create table in tablespace 1'); +is($result, 0, 'create table in tablespace 1'); $result = $node->psql('postgres', "DROP TABLESPACE regress_ts1"); -ok($result == 0, 'drop tablespace 1'); +is($result, 0, 'drop tablespace 1'); $result = $node->psql('postgres', "DROP TABLESPACE regress_ts2"); -ok($result == 0, 'drop tablespace 2'); +is($result, 0, 'drop tablespace 2'); $result = $node->psql('postgres', "DROP TABLESPACE regress_ts3"); -ok($result == 0, 'drop tablespace 3'); +is($result, 0, 'drop tablespace 3'); $result = $node->psql('postgres', "DROP TABLESPACE regress_ts4"); -ok($result == 0, 'drop tablespace 4'); +is($result, 0, 'drop tablespace 4'); $node->stop; diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl index adcaa419616..1d84b86ad9a 100644 --- a/src/test/modules/test_pg_dump/t/001_base.pl +++ b/src/test/modules/test_pg_dump/t/001_base.pl @@ -981,7 +981,8 @@ foreach my $run (sort keys %pgdump_runs) if ($tests{$test}->{like}->{$test_key} && !defined($tests{$test}->{unlike}->{$test_key})) { - if (!ok($output_file =~ $tests{$test}->{regexp}, + if (!like( + $output_file, $tests{$test}->{regexp}, "$run: should dump $test")) { diag("Review $run results in $tempdir"); @@ -989,7 +990,8 @@ foreach my $run (sort keys %pgdump_runs) } else { - if (!ok($output_file !~ $tests{$test}->{regexp}, + if (!unlike( + $output_file, $tests{$test}->{regexp}, "$run: should not dump $test")) { diag("Review $run results in $tempdir"); diff --git a/src/test/modules/xid_wraparound/t/002_limits.pl b/src/test/modules/xid_wraparound/t/002_limits.pl index aa1d8765d3a..8dd7f89a7d3 100644 --- a/src/test/modules/xid_wraparound/t/002_limits.pl +++ b/src/test/modules/xid_wraparound/t/002_limits.pl @@ -90,7 +90,7 @@ for my $i (1 .. 15) last; } } -ok($warn_limit == 1, "warn-limit reached"); +is($warn_limit, 1, "warn-limit reached"); # We can still INSERT, despite the warnings. $node->safe_psql('postgres', diff --git a/src/test/recovery/t/001_stream_rep.pl b/src/test/recovery/t/001_stream_rep.pl index 2cbcc509d76..c9c213001ee 100644 --- a/src/test/recovery/t/001_stream_rep.pl +++ b/src/test/recovery/t/001_stream_rep.pl @@ -265,26 +265,26 @@ my ($ret, $stdout, $stderr) = $node_primary->psql( 'postgres', 'SHOW ALL;', on_error_die => 1, extra_params => [ '--dbname' => $connstr_rep ]); -ok($ret == 0, "SHOW ALL with replication role and physical replication"); +is($ret, 0, "SHOW ALL with replication role and physical replication"); ($ret, $stdout, $stderr) = $node_primary->psql( 'postgres', 'SHOW ALL;', on_error_die => 1, extra_params => [ '--dbname' => $connstr_db ]); -ok($ret == 0, "SHOW ALL with replication role and logical replication"); +is($ret, 0, "SHOW ALL with replication role and logical replication"); # Test SHOW with a user-settable parameter ($ret, $stdout, $stderr) = $node_primary->psql( 'postgres', 'SHOW work_mem;', on_error_die => 1, extra_params => [ '--dbname' => $connstr_rep ]); -ok( $ret == 0, +is($ret, 0, "SHOW with user-settable parameter, replication role and physical replication" ); ($ret, $stdout, $stderr) = $node_primary->psql( 'postgres', 'SHOW work_mem;', on_error_die => 1, extra_params => [ '--dbname' => $connstr_db ]); -ok( $ret == 0, +is($ret, 0, "SHOW with user-settable parameter, replication role and logical replication" ); @@ -293,14 +293,14 @@ ok( $ret == 0, 'postgres', 'SHOW primary_conninfo;', on_error_die => 1, extra_params => [ '--dbname' => $connstr_rep ]); -ok( $ret == 0, +is($ret, 0, "SHOW with superuser-settable parameter, replication role and physical replication" ); ($ret, $stdout, $stderr) = $node_primary->psql( 'postgres', 'SHOW primary_conninfo;', on_error_die => 1, extra_params => [ '--dbname' => $connstr_db ]); -ok( $ret == 0, +is($ret, 0, "SHOW with superuser-settable parameter, replication role and logical replication" ); @@ -312,7 +312,7 @@ my $slotname = 'test_read_replication_slot_physical'; 'postgres', 'READ_REPLICATION_SLOT non_existent_slot;', extra_params => [ '--dbname' => $connstr_rep ]); -ok($ret == 0, "READ_REPLICATION_SLOT exit code 0 on success"); +is($ret, 0, "READ_REPLICATION_SLOT exit code 0 on success"); like($stdout, qr/^\|\|$/, "READ_REPLICATION_SLOT returns NULL values if slot does not exist"); @@ -325,7 +325,7 @@ $node_primary->psql( 'postgres', "READ_REPLICATION_SLOT $slotname;", extra_params => [ '--dbname' => $connstr_rep ]); -ok($ret == 0, "READ_REPLICATION_SLOT success with existing slot"); +is($ret, 0, "READ_REPLICATION_SLOT success with existing slot"); like($stdout, qr/^physical\|[^|]*\|1$/, "READ_REPLICATION_SLOT returns tuple with slot information"); @@ -577,7 +577,7 @@ my $phys_restart_lsn_post = $node_primary->safe_psql('postgres', "SELECT restart_lsn from pg_replication_slots WHERE slot_name = '$phys_slot';" ); chomp($phys_restart_lsn_post); -ok( ($phys_restart_lsn_pre cmp $phys_restart_lsn_post) == 0, +is($phys_restart_lsn_pre, $phys_restart_lsn_post, "physical slot advance persists across restarts"); # Check if the previous segment gets correctly recycled after the diff --git a/src/test/recovery/t/003_recovery_targets.pl b/src/test/recovery/t/003_recovery_targets.pl index f2109efa9b1..862e74b2ade 100644 --- a/src/test/recovery/t/003_recovery_targets.pl +++ b/src/test/recovery/t/003_recovery_targets.pl @@ -155,7 +155,9 @@ my $res = run_log( ok(!$res, 'invalid recovery startup fails'); my $logfile = slurp_file($node_standby->logfile()); -ok($logfile =~ qr/multiple recovery targets specified/, +like( + $logfile, + qr/multiple recovery targets specified/, 'multiple conflicting settings'); # Check behavior when recovery ends before target is reached @@ -183,8 +185,9 @@ foreach my $i (0 .. 10 * $PostgreSQL::Test::Utils::timeout_default) usleep(100_000); } $logfile = slurp_file($node_standby->logfile()); -ok( $logfile =~ - qr/FATAL: .* recovery ended before configured recovery target was reached/, +like( + $logfile, + qr/FATAL: .* recovery ended before configured recovery target was reached/, 'recovery end before target reached is a fatal error'); # Invalid timeline target diff --git a/src/test/recovery/t/005_replay_delay.pl b/src/test/recovery/t/005_replay_delay.pl index be05fcea8a7..0cb747f030d 100644 --- a/src/test/recovery/t/005_replay_delay.pl +++ b/src/test/recovery/t/005_replay_delay.pl @@ -53,10 +53,8 @@ $node_standby->poll_query_until('postgres', # This test is successful if and only if the LSN has been applied with at least # the configured apply delay. -ok(time() - $primary_insert_time >= $delay, - "standby applies WAL only after replication delay"); - - +cmp_ok(time() - $primary_insert_time, + '>=', $delay, "standby applies WAL only after replication delay"); # Check that recovery can be paused or resumed expectedly. my $node_standby2 = PostgreSQL::Test::Cluster->new('standby2'); $node_standby2->init_from_backup($node_primary, $backup_name, diff --git a/src/test/recovery/t/006_logical_decoding.pl b/src/test/recovery/t/006_logical_decoding.pl index 2137c4e5e30..f6c0a5bf649 100644 --- a/src/test/recovery/t/006_logical_decoding.pl +++ b/src/test/recovery/t/006_logical_decoding.pl @@ -35,8 +35,9 @@ my ($result, $stdout, $stderr) = $node_primary->psql( 'template1', qq[START_REPLICATION SLOT test_slot LOGICAL 0/0], replication => 'database'); -ok( $stderr =~ - m/replication slot "test_slot" was not created in this database/, +like( + $stderr, + qr/replication slot "test_slot" was not created in this database/, "Logical decoding correctly fails to start"); ($result, $stdout, $stderr) = $node_primary->psql( @@ -54,7 +55,9 @@ like( 'template1', qq[START_REPLICATION SLOT s1 LOGICAL 0/1], replication => 'true'); -ok($stderr =~ /ERROR: logical decoding requires a database connection/, +like( + $stderr, + qr/ERROR: logical decoding requires a database connection/, "Logical decoding fails on non-database connection"); $node_primary->safe_psql('postgres', @@ -201,7 +204,7 @@ my $logical_restart_lsn_post = $node_primary->safe_psql('postgres', "SELECT restart_lsn from pg_replication_slots WHERE slot_name = '$logical_slot';" ); chomp($logical_restart_lsn_post); -ok(($logical_restart_lsn_pre cmp $logical_restart_lsn_post) == 0, +is($logical_restart_lsn_pre, $logical_restart_lsn_post, "logical slot advance persists across restarts"); my $stats_test_slot1 = 'test_slot'; diff --git a/src/test/recovery/t/020_archive_status.pl b/src/test/recovery/t/020_archive_status.pl index 5d1fd191243..bd86d9fb583 100644 --- a/src/test/recovery/t/020_archive_status.pl +++ b/src/test/recovery/t/020_archive_status.pl @@ -245,7 +245,9 @@ my $log_location = -s $standby2->logfile; $standby2->stop; my $logfile = slurp_file($standby2->logfile, $log_location); -ok( $logfile =~ qr/archiver process shutting down/, +like( + $logfile, + qr/archiver process shutting down/, 'check shutdown callback of shell archive module'); # Test that we can enter and leave backup mode without crashes diff --git a/src/test/recovery/t/024_archive_recovery.pl b/src/test/recovery/t/024_archive_recovery.pl index b4527ec0843..893d8959cad 100644 --- a/src/test/recovery/t/024_archive_recovery.pl +++ b/src/test/recovery/t/024_archive_recovery.pl @@ -91,8 +91,9 @@ sub test_recovery_wal_level_minimal # Confirm that the archive recovery fails with an expected error my $logfile = slurp_file($recovery_node->logfile()); - ok( $logfile =~ - qr/FATAL: .* WAL was generated with "wal_level=minimal", cannot continue recovering/, + like( + $logfile, + qr/FATAL: .* WAL was generated with "wal_level=minimal", cannot continue recovering/, "$node_text ends with an error because it finds WAL generated with \"wal_level=minimal\"" ); } diff --git a/src/test/recovery/t/035_standby_logical_decoding.pl b/src/test/recovery/t/035_standby_logical_decoding.pl index c9c182892cf..ebe2fae1789 100644 --- a/src/test/recovery/t/035_standby_logical_decoding.pl +++ b/src/test/recovery/t/035_standby_logical_decoding.pl @@ -394,8 +394,9 @@ foreach my $i (0 .. 10 * $PostgreSQL::Test::Utils::timeout_default) # Confirm that the server startup fails with an expected error my $logfile = slurp_file($node_standby->logfile()); -ok( $logfile =~ - qr/FATAL: .* logical replication slot ".*" exists on the standby, but "hot_standby" = "off"/, +like( + $logfile, + qr/FATAL: .* logical replication slot ".*" exists on the standby, but "hot_standby" = "off"/, "the standby ends with an error during startup because hot_standby was disabled" ); $node_standby->adjust_conf('postgresql.conf', 'hot_standby', 'on'); @@ -487,8 +488,9 @@ $node_primary->wait_for_replay_catchup($node_standby); ($result, $stdout, $stderr) = $node_standby->psql('otherdb', "SELECT lsn FROM pg_logical_slot_peek_changes('behaves_ok_activeslot', NULL, NULL) ORDER BY lsn DESC LIMIT 1;" ); -ok( $stderr =~ - m/replication slot "behaves_ok_activeslot" was not created in this database/, +like( + $stderr, + qr/replication slot "behaves_ok_activeslot" was not created in this database/, "replaying logical slot from another database fails"); ################################################## @@ -620,8 +622,9 @@ check_pg_recvlogical_stderr($handle, 'postgres', qq[select pg_copy_logical_replication_slot('vacuum_full_inactiveslot', 'vacuum_full_inactiveslot_copy');], replication => 'database'); -ok( $stderr =~ - /ERROR: cannot copy invalidated replication slot "vacuum_full_inactiveslot"/, +like( + $stderr, + qr/ERROR: cannot copy invalidated replication slot "vacuum_full_inactiveslot"/, "invalidated slot cannot be copied"); # Set hot_standby_feedback to on diff --git a/src/test/recovery/t/040_standby_failover_slots_sync.pl b/src/test/recovery/t/040_standby_failover_slots_sync.pl index 2c61c51e914..3059bb8177b 100644 --- a/src/test/recovery/t/040_standby_failover_slots_sync.pl +++ b/src/test/recovery/t/040_standby_failover_slots_sync.pl @@ -100,8 +100,9 @@ $subscriber1->safe_psql('postgres', # Disable failover for enabled subscription my ($result, $stdout, $stderr) = $subscriber1->psql('postgres', "ALTER SUBSCRIPTION regress_mysub1 SET (failover = false)"); -ok( $stderr =~ - /ERROR: cannot set option "failover" for enabled subscription/, +like( + $stderr, + qr/ERROR: cannot set option "failover" for enabled subscription/, "altering failover is not allowed for enabled subscription"); ################################################## @@ -110,8 +111,9 @@ ok( $stderr =~ ($result, $stdout, $stderr) = $publisher->psql('postgres', "SELECT pg_sync_replication_slots();"); -ok( $stderr =~ - /ERROR: replication slots can only be synchronized to a standby server/, +like( + $stderr, + qr/ERROR: replication slots can only be synchronized to a standby server/, "cannot sync slots on a non-standby server"); ################################################## @@ -313,8 +315,9 @@ $standby1->reload; # Attempting to perform logical decoding on a synced slot should result in an error ($result, $stdout, $stderr) = $standby1->psql('postgres', "select * from pg_logical_slot_get_changes('lsub1_slot', NULL, NULL);"); -ok( $stderr =~ - /ERROR: cannot use replication slot "lsub1_slot" for logical decoding/, +like( + $stderr, + qr/ERROR: cannot use replication slot "lsub1_slot" for logical decoding/, "logical decoding is not allowed on synced slot"); # Attempting to alter a synced slot should result in an error @@ -322,13 +325,17 @@ ok( $stderr =~ 'postgres', qq[ALTER_REPLICATION_SLOT lsub1_slot (failover);], replication => 'database'); -ok($stderr =~ /ERROR: cannot alter replication slot "lsub1_slot"/, +like( + $stderr, + qr/ERROR: cannot alter replication slot "lsub1_slot"/, "synced slot on standby cannot be altered"); # Attempting to drop a synced slot should result in an error ($result, $stdout, $stderr) = $standby1->psql('postgres', "SELECT pg_drop_replication_slot('lsub1_slot');"); -ok($stderr =~ /ERROR: cannot drop replication slot "lsub1_slot"/, +like( + $stderr, + qr/ERROR: cannot drop replication slot "lsub1_slot"/, "synced slot on standby cannot be dropped"); ################################################## @@ -341,8 +348,9 @@ $standby1->reload; ($result, $stdout, $stderr) = $standby1->psql('postgres', "SELECT pg_sync_replication_slots();"); -ok( $stderr =~ - /ERROR: replication slot synchronization requires "dbname" to be specified in "primary_conninfo"/, +like( + $stderr, + qr/ERROR: replication slot synchronization requires "dbname" to be specified in "primary_conninfo"/, "cannot sync slots if dbname is not specified in primary_conninfo"); # Add the dbname back to the primary_conninfo for further tests @@ -379,8 +387,9 @@ $cascading_standby->start; ($result, $stdout, $stderr) = $cascading_standby->psql('postgres', "SELECT pg_sync_replication_slots();"); -ok( $stderr =~ - /ERROR: cannot synchronize replication slots from a standby server/, +like( + $stderr, + qr/ERROR: cannot synchronize replication slots from a standby server/, "cannot sync slots to a cascading standby server"); $cascading_standby->stop; diff --git a/src/test/recovery/t/044_invalidate_inactive_slots.pl b/src/test/recovery/t/044_invalidate_inactive_slots.pl index ccace14b4dd..2cd34f5ef34 100644 --- a/src/test/recovery/t/044_invalidate_inactive_slots.pl +++ b/src/test/recovery/t/044_invalidate_inactive_slots.pl @@ -94,7 +94,9 @@ my ($result, $stdout, $stderr); 'postgres', qq[ SELECT pg_replication_slot_advance('logical_slot', '0/1'); ]); -ok( $stderr =~ /can no longer access replication slot "logical_slot"/, +like( + $stderr, + qr/can no longer access replication slot "logical_slot"/, "detected error upon trying to acquire invalidated slot on node") or die "could not detect error upon trying to acquire invalidated slot \"logical_slot\" on node"; diff --git a/src/test/subscription/t/001_rep_changes.pl b/src/test/subscription/t/001_rep_changes.pl index ca55d8df50d..430c1246d14 100644 --- a/src/test/subscription/t/001_rep_changes.pl +++ b/src/test/subscription/t/001_rep_changes.pl @@ -364,14 +364,17 @@ $node_publisher->safe_psql('postgres', "DELETE FROM tab_full_pk WHERE a = 2"); $node_publisher->wait_for_catchup('tap_sub'); my $logfile = slurp_file($node_subscriber->logfile, $log_location); -ok( $logfile =~ - qr/conflict detected on relation "public.tab_full_pk": conflict=update_missing.*\n.*DETAIL:.* Could not find the row to be updated.*\n.*Remote row \(1, quux\); replica identity \(a\)=\(1\)/m, +like( + $logfile, + qr/conflict detected on relation "public.tab_full_pk": conflict=update_missing.*\n.*DETAIL:.* Could not find the row to be updated.*\n.*Remote row \(1, quux\); replica identity \(a\)=\(1\)/m, 'update target row is missing'); -ok( $logfile =~ - qr/conflict detected on relation "public.tab_full": conflict=update_missing.*\n.*DETAIL:.* Could not find the row to be updated.*\n.*Remote row \(26\); replica identity full \(25\)/m, +like( + $logfile, + qr/conflict detected on relation "public.tab_full": conflict=update_missing.*\n.*DETAIL:.* Could not find the row to be updated.*\n.*Remote row \(26\); replica identity full \(25\)/m, 'update target row is missing'); -ok( $logfile =~ - qr/conflict detected on relation "public.tab_full_pk": conflict=delete_missing.*\n.*DETAIL:.* Could not find the row to be deleted.*\n.*Replica identity \(a\)=\(2\)/m, +like( + $logfile, + qr/conflict detected on relation "public.tab_full_pk": conflict=delete_missing.*\n.*DETAIL:.* Could not find the row to be deleted.*\n.*Replica identity \(a\)=\(2\)/m, 'delete target row is missing'); $node_subscriber->append_conf('postgresql.conf', @@ -515,7 +518,9 @@ $node_publisher->safe_psql('postgres', "INSERT INTO tab_notrep VALUES (11)"); $node_publisher->wait_for_catchup('tap_sub'); $logfile = slurp_file($node_publisher->logfile, $log_location); -ok($logfile =~ qr/skipped replication of an empty transaction with XID/, +like( + $logfile, + qr/skipped replication of an empty transaction with XID/, 'empty transaction is skipped'); $result = @@ -588,8 +593,9 @@ CREATE TABLE skip_wal(); CREATE PUBLICATION tap_pub2 FOR TABLE skip_wal; ROLLBACK; }); -ok( $reterr =~ - m/WARNING: "wal_level" is insufficient to publish logical changes/, +like( + $reterr, + qr/WARNING: "wal_level" is insufficient to publish logical changes/, 'CREATE PUBLICATION while "wal_level=minimal"'); done_testing(); diff --git a/src/test/subscription/t/007_ddl.pl b/src/test/subscription/t/007_ddl.pl index 2a45fb13739..16cb7bca8f2 100644 --- a/src/test/subscription/t/007_ddl.pl +++ b/src/test/subscription/t/007_ddl.pl @@ -45,8 +45,9 @@ pass "subscription disable and drop in same transaction did not hang"; my ($ret, $stdout, $stderr) = $node_subscriber->psql('postgres', "CREATE SUBSCRIPTION mysub1 CONNECTION '$publisher_connstr' PUBLICATION mypub, non_existent_pub" ); -ok( $stderr =~ - m/WARNING: publication "non_existent_pub" does not exist on the publisher/, +like( + $stderr, + qr/WARNING: publication "non_existent_pub" does not exist on the publisher/, "Create subscription throws warning for non-existent publication"); # Wait for initial table sync to finish. @@ -56,16 +57,18 @@ $node_subscriber->wait_for_subscription_sync($node_publisher, 'mysub1'); ($ret, $stdout, $stderr) = $node_subscriber->psql('postgres', "ALTER SUBSCRIPTION mysub1 ADD PUBLICATION non_existent_pub1, non_existent_pub2" ); -ok( $stderr =~ - m/WARNING: publications "non_existent_pub1", "non_existent_pub2" do not exist on the publisher/, +like( + $stderr, + qr/WARNING: publications "non_existent_pub1", "non_existent_pub2" do not exist on the publisher/, "Alter subscription add publication throws warning for non-existent publications" ); # Specifying non-existent publication along with set publication. ($ret, $stdout, $stderr) = $node_subscriber->psql('postgres', "ALTER SUBSCRIPTION mysub1 SET PUBLICATION non_existent_pub"); -ok( $stderr =~ - m/WARNING: publication "non_existent_pub" does not exist on the publisher/, +like( + $stderr, + qr/WARNING: publication "non_existent_pub" does not exist on the publisher/, "Alter subscription set publication throws warning for non-existent publication" ); diff --git a/src/test/subscription/t/013_partition.pl b/src/test/subscription/t/013_partition.pl index 763a91e75a3..3a5e92d094f 100644 --- a/src/test/subscription/t/013_partition.pl +++ b/src/test/subscription/t/013_partition.pl @@ -367,17 +367,21 @@ $node_publisher->wait_for_catchup('sub1'); $node_publisher->wait_for_catchup('sub2'); my $logfile = slurp_file($node_subscriber1->logfile(), $log_location); -ok( $logfile =~ - qr/conflict detected on relation "public.tab1_2_2": conflict=update_missing.*\n.*DETAIL:.* Could not find the row to be updated.*\n.*Remote row \(null, 4, quux\); replica identity \(a\)=\(4\)/, +like( + $logfile, + qr/conflict detected on relation "public.tab1_2_2": conflict=update_missing.*\n.*DETAIL:.* Could not find the row to be updated.*\n.*Remote row \(null, 4, quux\); replica identity \(a\)=\(4\)/, 'update target row is missing in tab1_2_2'); -ok( $logfile =~ - qr/conflict detected on relation "public.tab1_1": conflict=delete_missing.*\n.*DETAIL:.* Could not find the row to be deleted.*\n.*Replica identity \(a\)=\(1\)/, +like( + $logfile, + qr/conflict detected on relation "public.tab1_1": conflict=delete_missing.*\n.*DETAIL:.* Could not find the row to be deleted.*\n.*Replica identity \(a\)=\(1\)/, 'delete target row is missing in tab1_1'); -ok( $logfile =~ - qr/conflict detected on relation "public.tab1_2_2": conflict=delete_missing.*\n.*DETAIL:.* Could not find the row to be deleted.*\n.*Replica identity \(a\)=\(4\)/, +like( + $logfile, + qr/conflict detected on relation "public.tab1_2_2": conflict=delete_missing.*\n.*DETAIL:.* Could not find the row to be deleted.*\n.*Replica identity \(a\)=\(4\)/, 'delete target row is missing in tab1_2_2'); -ok( $logfile =~ - qr/conflict detected on relation "public.tab1_def": conflict=delete_missing.*\n.*DETAIL:.* Could not find the row to be deleted.*\n.*Replica identity \(a\)=\(10\)/, +like( + $logfile, + qr/conflict detected on relation "public.tab1_def": conflict=delete_missing.*\n.*DETAIL:.* Could not find the row to be deleted.*\n.*Replica identity \(a\)=\(10\)/, 'delete target row is missing in tab1_def'); # Tests for replication using root table identity and schema @@ -780,11 +784,13 @@ $node_publisher->wait_for_catchup('sub_viaroot'); $node_publisher->wait_for_catchup('sub2'); $logfile = slurp_file($node_subscriber1->logfile(), $log_location); -ok( $logfile =~ - qr/conflict detected on relation "public.tab2_1": conflict=update_missing.*\n.*DETAIL:.* Could not find the row to be updated.*\n.*Remote row \(pub_tab2, quux, 5\); replica identity \(a\)=\(5\)/, +like( + $logfile, + qr/conflict detected on relation "public.tab2_1": conflict=update_missing.*\n.*DETAIL:.* Could not find the row to be updated.*\n.*Remote row \(pub_tab2, quux, 5\); replica identity \(a\)=\(5\)/, 'update target row is missing in tab2_1'); -ok( $logfile =~ - qr/conflict detected on relation "public.tab2_1": conflict=delete_missing.*\n.*DETAIL:.* Could not find the row to be deleted.*\n.*Replica identity \(a\)=\(1\)/, +like( + $logfile, + qr/conflict detected on relation "public.tab2_1": conflict=delete_missing.*\n.*DETAIL:.* Could not find the row to be deleted.*\n.*Replica identity \(a\)=\(1\)/, 'delete target row is missing in tab2_1'); # Enable the track_commit_timestamp to detect the conflict when attempting @@ -801,8 +807,9 @@ $node_publisher->safe_psql('postgres', $node_publisher->wait_for_catchup('sub_viaroot'); $logfile = slurp_file($node_subscriber1->logfile(), $log_location); -ok( $logfile =~ - qr/conflict detected on relation "public.tab2_1": conflict=update_origin_differs.*\n.*DETAIL:.* Updating the row that was modified locally in transaction [0-9]+ at .*\n.*Existing local row \(yyy, null, 3\); remote row \(pub_tab2, quux, 3\); replica identity \(a\)=\(3\)/, +like( + $logfile, + qr/conflict detected on relation "public.tab2_1": conflict=update_origin_differs.*\n.*DETAIL:.* Updating the row that was modified locally in transaction [0-9]+ at .*\n.*Existing local row \(yyy, null, 3\); remote row \(pub_tab2, quux, 3\); replica identity \(a\)=\(3\)/, 'updating a row that was modified by a different origin'); # The remaining tests no longer test conflict detection. diff --git a/src/test/subscription/t/027_nosuperuser.pl b/src/test/subscription/t/027_nosuperuser.pl index 36af1c16e7f..691731743df 100644 --- a/src/test/subscription/t/027_nosuperuser.pl +++ b/src/test/subscription/t/027_nosuperuser.pl @@ -399,8 +399,9 @@ SKIP: isnt($ret, 0, "non zero exit for subscription whose owner is a non-superuser must specify password parameter of the connection string" ); - ok( $stderr =~ - m/DETAIL: Non-superusers must provide a password in the connection string./, + like( + $stderr, + qr/DETAIL: Non-superusers must provide a password in the connection string./, 'subscription whose owner is a non-superuser must specify password parameter of the connection string' ); diff --git a/src/test/subscription/t/031_column_list.pl b/src/test/subscription/t/031_column_list.pl index e859bcdf4eb..2c14270af21 100644 --- a/src/test/subscription/t/031_column_list.pl +++ b/src/test/subscription/t/031_column_list.pl @@ -1272,8 +1272,9 @@ my ($cmdret, $stdout, $stderr) = $node_subscriber->psql( CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr' PUBLICATION pub_mix_1, pub_mix_2; )); -ok( $stderr =~ - qr/cannot use different column lists for table "public.test_mix_1" in different publications/, +like( + $stderr, + qr/cannot use different column lists for table "public.test_mix_1" in different publications/, 'different column lists detected'); # TEST: If the column list is changed after creating the subscription, we diff --git a/src/test/subscription/t/035_conflicts.pl b/src/test/subscription/t/035_conflicts.pl index 741f5397478..a94bde16f53 100644 --- a/src/test/subscription/t/035_conflicts.pl +++ b/src/test/subscription/t/035_conflicts.pl @@ -224,8 +224,9 @@ ok( $node_B->poll_query_until( # Alter retain_dead_tuples for enabled subscription my ($cmdret, $stdout, $stderr) = $node_A->psql('postgres', "ALTER SUBSCRIPTION $subname_AB SET (retain_dead_tuples = true)"); -ok( $stderr =~ - /ERROR: cannot set option \"retain_dead_tuples\" for enabled subscription/, +like( + $stderr, + qr/ERROR: cannot set option \"retain_dead_tuples\" for enabled subscription/, "altering retain_dead_tuples is not allowed for enabled subscription"); # Disable the subscription @@ -239,8 +240,9 @@ $node_A->poll_query_until('postgres', # Enable retain_dead_tuples for disabled subscription ($cmdret, $stdout, $stderr) = $node_A->psql('postgres', "ALTER SUBSCRIPTION $subname_AB SET (retain_dead_tuples = true);"); -ok( $stderr =~ - /NOTICE: deleted rows to detect conflicts would not be removed until the subscription is enabled/, +like( + $stderr, + qr/NOTICE: deleted rows to detect conflicts would not be removed until the subscription is enabled/, "altering retain_dead_tuples is allowed for disabled subscription"); # Re-enable the subscription @@ -262,9 +264,11 @@ ok( $node_A->poll_query_until( ($cmdret, $stdout, $stderr) = $node_A->psql('postgres', "ALTER SUBSCRIPTION $subname_AB SET (origin = any);"); -ok( $stderr =~ - /WARNING: subscription "tap_sub_a_b" enabled retain_dead_tuples but might not reliably detect conflicts for changes from different origins/, - "warn of the possibility of receiving changes from origins other than the publisher"); +like( + $stderr, + qr/WARNING: subscription "tap_sub_a_b" enabled retain_dead_tuples but might not reliably detect conflicts for changes from different origins/, + "warn of the possibility of receiving changes from origins other than the publisher" +); # Reset the origin to none $node_A->psql('postgres', @@ -302,8 +306,9 @@ $node_A->safe_psql('postgres', "DELETE FROM tab WHERE a = 1;"); 'postgres', qq(VACUUM (verbose) public.tab;) ); -ok( $stderr =~ - qr/1 are dead but not yet removable/, +like( + $stderr, + qr/1 are dead but not yet removable/, 'the deleted column is non-removable'); # Ensure the DELETE is replayed on Node B @@ -311,8 +316,9 @@ $node_A->wait_for_catchup($subname_BA); # Check the conflict detected on Node B my $logfile = slurp_file($node_B->logfile(), $log_location); -ok( $logfile =~ - qr/conflict detected on relation "public.tab": conflict=delete_origin_differs.* +like( + $logfile, + qr/conflict detected on relation "public.tab": conflict=delete_origin_differs.* .*DETAIL:.* Deleting the row that was modified locally in transaction [0-9]+ at .* .*Existing local row \(1, 3\); replica identity \(a\)=\(1\)/, 'delete target row was modified in tab'); @@ -324,8 +330,9 @@ $node_A->safe_psql( $node_B->wait_for_catchup($subname_AB); $logfile = slurp_file($node_A->logfile(), $log_location); -ok( $logfile =~ - qr/conflict detected on relation "public.tab": conflict=update_deleted.* +like( + $logfile, + qr/conflict detected on relation "public.tab": conflict=update_deleted.* .*DETAIL:.* The row to be updated was deleted locally in transaction [0-9]+ at .* .*Remote row \(1, 3\); replica identity \(a\)=\(1\)/, 'update target row was deleted in tab'); @@ -371,8 +378,9 @@ $node_A->safe_psql( $node_B->wait_for_catchup($subname_AB); $logfile = slurp_file($node_A->logfile(), $log_location); -ok( $logfile =~ - qr/conflict detected on relation "public.tab": conflict=update_deleted.* +like( + $logfile, + qr/conflict detected on relation "public.tab": conflict=update_deleted.* .*DETAIL:.* The row to be updated was deleted locally in transaction [0-9]+ at .* .*Remote row \(2, 4\); replica identity full \(2, 2\)/, 'update target row was deleted in tab'); @@ -502,7 +510,9 @@ if ($injection_points_supported != 0) ($cmdret, $stdout, $stderr) = $node_A->psql('postgres', qq(VACUUM (verbose) public.tab;)); - ok($stderr =~ qr/1 are dead but not yet removable/, + like( + $stderr, + qr/1 are dead but not yet removable/, 'the deleted column is non-removable'); $log_location = -s $node_A->logfile; @@ -527,8 +537,9 @@ if ($injection_points_supported != 0) $node_B->wait_for_catchup($subname_AB); $logfile = slurp_file($node_A->logfile(), $log_location); - ok( $logfile =~ - qr/conflict detected on relation "public.tab": conflict=update_deleted.* + like( + $logfile, + qr/conflict detected on relation "public.tab": conflict=update_deleted.* .*DETAIL:.* The row to be updated was deleted locally in transaction [0-9]+ at .* .*Remote row \(1, 2\); replica identity full \(1, 1\)/, 'update target row was deleted in tab'); |
