1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

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
This commit is contained in:
Andres Freund
2020-06-14 11:47:37 -07:00
parent 2661a793ff
commit 229f8c219f
37 changed files with 777 additions and 777 deletions

View File

@ -5,10 +5,10 @@ use PostgresNode;
use TestLib;
use Test::More tests => 31;
my $node_master;
my $node_primary;
my $node_standby;
# Run few queries on both master and standby and check their results match.
# Run few queries on both primary and standby and check their results match.
sub test_index_replay
{
my ($test_name) = @_;
@ -17,7 +17,7 @@ sub test_index_replay
my $applname = $node_standby->name;
my $caughtup_query =
"SELECT pg_current_wal_lsn() <= write_lsn FROM pg_stat_replication WHERE application_name = '$applname';";
$node_master->poll_query_until('postgres', $caughtup_query)
$node_primary->poll_query_until('postgres', $caughtup_query)
or die "Timed out while waiting for standby 1 to catch up";
my $queries = qq(SET enable_seqscan=off;
@ -32,35 +32,35 @@ SELECT * FROM tst WHERE i = 7 AND t = 'e';
);
# Run test queries and compare their result
my $master_result = $node_master->safe_psql("postgres", $queries);
my $primary_result = $node_primary->safe_psql("postgres", $queries);
my $standby_result = $node_standby->safe_psql("postgres", $queries);
is($master_result, $standby_result, "$test_name: query result matches");
is($primary_result, $standby_result, "$test_name: query result matches");
return;
}
# Initialize master node
$node_master = get_new_node('master');
$node_master->init(allows_streaming => 1);
$node_master->start;
# Initialize primary node
$node_primary = get_new_node('primary');
$node_primary->init(allows_streaming => 1);
$node_primary->start;
my $backup_name = 'my_backup';
# Take backup
$node_master->backup($backup_name);
$node_primary->backup($backup_name);
# Create streaming standby linking to master
# Create streaming standby linking to primary
$node_standby = get_new_node('standby');
$node_standby->init_from_backup($node_master, $backup_name,
$node_standby->init_from_backup($node_primary, $backup_name,
has_streaming => 1);
$node_standby->start;
# Create some bloom index on master
$node_master->safe_psql("postgres", "CREATE EXTENSION bloom;");
$node_master->safe_psql("postgres", "CREATE TABLE tst (i int4, t text);");
$node_master->safe_psql("postgres",
# Create some bloom index on primary
$node_primary->safe_psql("postgres", "CREATE EXTENSION bloom;");
$node_primary->safe_psql("postgres", "CREATE TABLE tst (i int4, t text);");
$node_primary->safe_psql("postgres",
"INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,100000) i;"
);
$node_master->safe_psql("postgres",
$node_primary->safe_psql("postgres",
"CREATE INDEX bloomidx ON tst USING bloom (i, t) WITH (col1 = 3);");
# Test that queries give same result
@ -69,12 +69,12 @@ test_index_replay('initial');
# Run 10 cycles of table modification. Run test queries after each modification.
for my $i (1 .. 10)
{
$node_master->safe_psql("postgres", "DELETE FROM tst WHERE i = $i;");
$node_primary->safe_psql("postgres", "DELETE FROM tst WHERE i = $i;");
test_index_replay("delete $i");
$node_master->safe_psql("postgres", "VACUUM tst;");
$node_primary->safe_psql("postgres", "VACUUM tst;");
test_index_replay("vacuum $i");
my ($start, $end) = (100001 + ($i - 1) * 10000, 100000 + $i * 10000);
$node_master->safe_psql("postgres",
$node_primary->safe_psql("postgres",
"INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series($start,$end) i;"
);
test_index_replay("insert $i");