aboutsummaryrefslogtreecommitdiff
path: root/src/test/modules/commit_ts
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2020-06-14 11:47:37 -0700
committerAndres Freund <andres@anarazel.de>2020-07-08 12:39:56 -0700
commit229f8c219f8fffacc253eca6023eab10a16eb009 (patch)
tree5c3df9c9ad633caa94566aaa620b126189f97126 /src/test/modules/commit_ts
parent2661a793ff59149af1d844d6be504e421c04733e (diff)
downloadpostgresql-229f8c219f8fffacc253eca6023eab10a16eb009.tar.gz
postgresql-229f8c219f8fffacc253eca6023eab10a16eb009.zip
tap tests: replace 'master' with 'primary'.
We've largely replaced master with primary in docs etc, but tap test still widely used master. Author: Andres Freund Reviewed-By: David Steele Discussion: https://postgr.es/m/20200615182235.x7lch5n6kcjq4aue@alap3.anarazel.de
Diffstat (limited to 'src/test/modules/commit_ts')
-rw-r--r--src/test/modules/commit_ts/t/002_standby.pl40
-rw-r--r--src/test/modules/commit_ts/t/003_standby_2.pl36
-rw-r--r--src/test/modules/commit_ts/t/004_restart.pl64
3 files changed, 70 insertions, 70 deletions
diff --git a/src/test/modules/commit_ts/t/002_standby.pl b/src/test/modules/commit_ts/t/002_standby.pl
index f376b595962..872efb2e8ea 100644
--- a/src/test/modules/commit_ts/t/002_standby.pl
+++ b/src/test/modules/commit_ts/t/002_standby.pl
@@ -8,45 +8,45 @@ use Test::More tests => 4;
use PostgresNode;
my $bkplabel = 'backup';
-my $master = get_new_node('master');
-$master->init(allows_streaming => 1);
+my $primary = get_new_node('primary');
+$primary->init(allows_streaming => 1);
-$master->append_conf(
+$primary->append_conf(
'postgresql.conf', qq{
track_commit_timestamp = on
max_wal_senders = 5
});
-$master->start;
-$master->backup($bkplabel);
+$primary->start;
+$primary->backup($bkplabel);
my $standby = get_new_node('standby');
-$standby->init_from_backup($master, $bkplabel, has_streaming => 1);
+$standby->init_from_backup($primary, $bkplabel, has_streaming => 1);
$standby->start;
for my $i (1 .. 10)
{
- $master->safe_psql('postgres', "create table t$i()");
+ $primary->safe_psql('postgres', "create table t$i()");
}
-my $master_ts = $master->safe_psql('postgres',
+my $primary_ts = $primary->safe_psql('postgres',
qq{SELECT ts.* FROM pg_class, pg_xact_commit_timestamp(xmin) AS ts WHERE relname = 't10'}
);
-my $master_lsn =
- $master->safe_psql('postgres', 'select pg_current_wal_lsn()');
+my $primary_lsn =
+ $primary->safe_psql('postgres', 'select pg_current_wal_lsn()');
$standby->poll_query_until('postgres',
- qq{SELECT '$master_lsn'::pg_lsn <= pg_last_wal_replay_lsn()})
+ qq{SELECT '$primary_lsn'::pg_lsn <= pg_last_wal_replay_lsn()})
or die "standby never caught up";
my $standby_ts = $standby->safe_psql('postgres',
qq{select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = 't10'}
);
-is($master_ts, $standby_ts, "standby gives same value as master");
+is($primary_ts, $standby_ts, "standby gives same value as primary");
-$master->append_conf('postgresql.conf', 'track_commit_timestamp = off');
-$master->restart;
-$master->safe_psql('postgres', 'checkpoint');
-$master_lsn = $master->safe_psql('postgres', 'select pg_current_wal_lsn()');
+$primary->append_conf('postgresql.conf', 'track_commit_timestamp = off');
+$primary->restart;
+$primary->safe_psql('postgres', 'checkpoint');
+$primary_lsn = $primary->safe_psql('postgres', 'select pg_current_wal_lsn()');
$standby->poll_query_until('postgres',
- qq{SELECT '$master_lsn'::pg_lsn <= pg_last_wal_replay_lsn()})
+ qq{SELECT '$primary_lsn'::pg_lsn <= pg_last_wal_replay_lsn()})
or die "standby never caught up";
$standby->safe_psql('postgres', 'checkpoint');
@@ -54,10 +54,10 @@ $standby->safe_psql('postgres', 'checkpoint');
my ($ret, $standby_ts_stdout, $standby_ts_stderr) = $standby->psql('postgres',
'select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = \'t10\''
);
-is($ret, 3, 'standby errors when master turned feature off');
+is($ret, 3, 'standby errors when primary turned feature off');
is($standby_ts_stdout, '',
- "standby gives no value when master turned feature off");
+ "standby gives no value when primary turned feature off");
like(
$standby_ts_stderr,
qr/could not get commit timestamp data/,
- 'expected error when master turned feature off');
+ 'expected error when primary turned feature off');
diff --git a/src/test/modules/commit_ts/t/003_standby_2.pl b/src/test/modules/commit_ts/t/003_standby_2.pl
index 9165d500536..36ab829dfdd 100644
--- a/src/test/modules/commit_ts/t/003_standby_2.pl
+++ b/src/test/modules/commit_ts/t/003_standby_2.pl
@@ -1,4 +1,4 @@
-# Test master/standby scenario where the track_commit_timestamp GUC is
+# Test primary/standby scenario where the track_commit_timestamp GUC is
# repeatedly toggled on and off.
use strict;
use warnings;
@@ -8,31 +8,31 @@ use Test::More tests => 4;
use PostgresNode;
my $bkplabel = 'backup';
-my $master = get_new_node('master');
-$master->init(allows_streaming => 1);
-$master->append_conf(
+my $primary = get_new_node('primary');
+$primary->init(allows_streaming => 1);
+$primary->append_conf(
'postgresql.conf', qq{
track_commit_timestamp = on
max_wal_senders = 5
});
-$master->start;
-$master->backup($bkplabel);
+$primary->start;
+$primary->backup($bkplabel);
my $standby = get_new_node('standby');
-$standby->init_from_backup($master, $bkplabel, has_streaming => 1);
+$standby->init_from_backup($primary, $bkplabel, has_streaming => 1);
$standby->start;
for my $i (1 .. 10)
{
- $master->safe_psql('postgres', "create table t$i()");
+ $primary->safe_psql('postgres', "create table t$i()");
}
-$master->append_conf('postgresql.conf', 'track_commit_timestamp = off');
-$master->restart;
-$master->safe_psql('postgres', 'checkpoint');
-my $master_lsn =
- $master->safe_psql('postgres', 'select pg_current_wal_lsn()');
+$primary->append_conf('postgresql.conf', 'track_commit_timestamp = off');
+$primary->restart;
+$primary->safe_psql('postgres', 'checkpoint');
+my $primary_lsn =
+ $primary->safe_psql('postgres', 'select pg_current_wal_lsn()');
$standby->poll_query_until('postgres',
- qq{SELECT '$master_lsn'::pg_lsn <= pg_last_wal_replay_lsn()})
+ qq{SELECT '$primary_lsn'::pg_lsn <= pg_last_wal_replay_lsn()})
or die "standby never caught up";
$standby->safe_psql('postgres', 'checkpoint');
@@ -49,10 +49,10 @@ like(
qr/could not get commit timestamp data/,
'expected err msg after restart');
-$master->append_conf('postgresql.conf', 'track_commit_timestamp = on');
-$master->restart;
-$master->append_conf('postgresql.conf', 'track_commit_timestamp = off');
-$master->restart;
+$primary->append_conf('postgresql.conf', 'track_commit_timestamp = on');
+$primary->restart;
+$primary->append_conf('postgresql.conf', 'track_commit_timestamp = off');
+$primary->restart;
system_or_bail('pg_ctl', '-D', $standby->data_dir, 'promote');
diff --git a/src/test/modules/commit_ts/t/004_restart.pl b/src/test/modules/commit_ts/t/004_restart.pl
index 39ca25a06bf..4e6ae776b97 100644
--- a/src/test/modules/commit_ts/t/004_restart.pl
+++ b/src/test/modules/commit_ts/t/004_restart.pl
@@ -5,15 +5,15 @@ use PostgresNode;
use TestLib;
use Test::More tests => 16;
-my $node_master = get_new_node('master');
-$node_master->init(allows_streaming => 1);
-$node_master->append_conf('postgresql.conf', 'track_commit_timestamp = on');
-$node_master->start;
+my $node_primary = get_new_node('primary');
+$node_primary->init(allows_streaming => 1);
+$node_primary->append_conf('postgresql.conf', 'track_commit_timestamp = on');
+$node_primary->start;
my ($ret, $stdout, $stderr);
($ret, $stdout, $stderr) =
- $node_master->psql('postgres', qq[SELECT pg_xact_commit_timestamp('0');]);
+ $node_primary->psql('postgres', qq[SELECT pg_xact_commit_timestamp('0');]);
is($ret, 3, 'getting ts of InvalidTransactionId reports error');
like(
$stderr,
@@ -21,27 +21,27 @@ like(
'expected error from InvalidTransactionId');
($ret, $stdout, $stderr) =
- $node_master->psql('postgres', qq[SELECT pg_xact_commit_timestamp('1');]);
+ $node_primary->psql('postgres', qq[SELECT pg_xact_commit_timestamp('1');]);
is($ret, 0, 'getting ts of BootstrapTransactionId succeeds');
is($stdout, '', 'timestamp of BootstrapTransactionId is null');
($ret, $stdout, $stderr) =
- $node_master->psql('postgres', qq[SELECT pg_xact_commit_timestamp('2');]);
+ $node_primary->psql('postgres', qq[SELECT pg_xact_commit_timestamp('2');]);
is($ret, 0, 'getting ts of FrozenTransactionId succeeds');
is($stdout, '', 'timestamp of FrozenTransactionId is null');
# Since FirstNormalTransactionId will've occurred during initdb, long before we
# enabled commit timestamps, it'll be null since we have no cts data for it but
# cts are enabled.
-is( $node_master->safe_psql(
+is( $node_primary->safe_psql(
'postgres', qq[SELECT pg_xact_commit_timestamp('3');]),
'',
'committs for FirstNormalTransactionId is null');
-$node_master->safe_psql('postgres',
+$node_primary->safe_psql('postgres',
qq[CREATE TABLE committs_test(x integer, y timestamp with time zone);]);
-my $xid = $node_master->safe_psql(
+my $xid = $node_primary->safe_psql(
'postgres', qq[
BEGIN;
INSERT INTO committs_test(x, y) VALUES (1, current_timestamp);
@@ -49,43 +49,43 @@ my $xid = $node_master->safe_psql(
COMMIT;
]);
-my $before_restart_ts = $node_master->safe_psql('postgres',
+my $before_restart_ts = $node_primary->safe_psql('postgres',
qq[SELECT pg_xact_commit_timestamp('$xid');]);
ok($before_restart_ts ne '' && $before_restart_ts ne 'null',
'commit timestamp recorded');
-$node_master->stop('immediate');
-$node_master->start;
+$node_primary->stop('immediate');
+$node_primary->start;
-my $after_crash_ts = $node_master->safe_psql('postgres',
+my $after_crash_ts = $node_primary->safe_psql('postgres',
qq[SELECT pg_xact_commit_timestamp('$xid');]);
is($after_crash_ts, $before_restart_ts,
'timestamps before and after crash are equal');
-$node_master->stop('fast');
-$node_master->start;
+$node_primary->stop('fast');
+$node_primary->start;
-my $after_restart_ts = $node_master->safe_psql('postgres',
+my $after_restart_ts = $node_primary->safe_psql('postgres',
qq[SELECT pg_xact_commit_timestamp('$xid');]);
is($after_restart_ts, $before_restart_ts,
'timestamps before and after restart are equal');
# Now disable commit timestamps
-$node_master->append_conf('postgresql.conf', 'track_commit_timestamp = off');
-$node_master->stop('fast');
+$node_primary->append_conf('postgresql.conf', 'track_commit_timestamp = off');
+$node_primary->stop('fast');
# Start the server, which generates a XLOG_PARAMETER_CHANGE record where
# the parameter change is registered.
-$node_master->start;
+$node_primary->start;
# Now restart again the server so as no XLOG_PARAMETER_CHANGE record are
# replayed with the follow-up immediate shutdown.
-$node_master->restart;
+$node_primary->restart;
# Move commit timestamps across page boundaries. Things should still
# be able to work across restarts with those transactions committed while
# track_commit_timestamp is disabled.
-$node_master->safe_psql(
+$node_primary->safe_psql(
'postgres',
qq(CREATE PROCEDURE consume_xid(cnt int)
AS \$\$
@@ -100,9 +100,9 @@ DECLARE
\$\$
LANGUAGE plpgsql;
));
-$node_master->safe_psql('postgres', 'CALL consume_xid(2000)');
+$node_primary->safe_psql('postgres', 'CALL consume_xid(2000)');
-($ret, $stdout, $stderr) = $node_master->psql('postgres',
+($ret, $stdout, $stderr) = $node_primary->psql('postgres',
qq[SELECT pg_xact_commit_timestamp('$xid');]);
is($ret, 3, 'no commit timestamp from enable tx when cts disabled');
like(
@@ -111,7 +111,7 @@ like(
'expected error from enabled tx when committs disabled');
# Do a tx while cts disabled
-my $xid_disabled = $node_master->safe_psql(
+my $xid_disabled = $node_primary->safe_psql(
'postgres', qq[
BEGIN;
INSERT INTO committs_test(x, y) VALUES (2, current_timestamp);
@@ -120,7 +120,7 @@ my $xid_disabled = $node_master->safe_psql(
]);
# Should be inaccessible
-($ret, $stdout, $stderr) = $node_master->psql('postgres',
+($ret, $stdout, $stderr) = $node_primary->psql('postgres',
qq[SELECT pg_xact_commit_timestamp('$xid_disabled');]);
is($ret, 3, 'no commit timestamp when disabled');
like(
@@ -129,21 +129,21 @@ like(
'expected error from disabled tx when committs disabled');
# Re-enable, restart and ensure we can still get the old timestamps
-$node_master->append_conf('postgresql.conf', 'track_commit_timestamp = on');
+$node_primary->append_conf('postgresql.conf', 'track_commit_timestamp = on');
# An immediate shutdown is used here. At next startup recovery will
# replay transactions which committed when track_commit_timestamp was
# disabled, and the facility should be able to work properly.
-$node_master->stop('immediate');
-$node_master->start;
+$node_primary->stop('immediate');
+$node_primary->start;
-my $after_enable_ts = $node_master->safe_psql('postgres',
+my $after_enable_ts = $node_primary->safe_psql('postgres',
qq[SELECT pg_xact_commit_timestamp('$xid');]);
is($after_enable_ts, '', 'timestamp of enabled tx null after re-enable');
-my $after_enable_disabled_ts = $node_master->safe_psql('postgres',
+my $after_enable_disabled_ts = $node_primary->safe_psql('postgres',
qq[SELECT pg_xact_commit_timestamp('$xid_disabled');]);
is($after_enable_disabled_ts, '',
'timestamp of disabled tx null after re-enable');
-$node_master->stop;
+$node_primary->stop;