Skip to content

Commit 229f8c2

Browse files
committed
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
1 parent 2661a79 commit 229f8c2

37 files changed

+777
-777
lines changed

contrib/bloom/t/001_wal.pl

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
use TestLib;
66
use Test::More tests => 31;
77

8-
my $node_master;
8+
my $node_primary;
99
my $node_standby;
1010

11-
# Run few queries on both master and standby and check their results match.
11+
# Run few queries on both primary and standby and check their results match.
1212
sub test_index_replay
1313
{
1414
my ($test_name) = @_;
@@ -17,7 +17,7 @@ sub test_index_replay
1717
my $applname = $node_standby->name;
1818
my $caughtup_query =
1919
"SELECT pg_current_wal_lsn() <= write_lsn FROM pg_stat_replication WHERE application_name = '$applname';";
20-
$node_master->poll_query_until('postgres', $caughtup_query)
20+
$node_primary->poll_query_until('postgres', $caughtup_query)
2121
or die "Timed out while waiting for standby 1 to catch up";
2222

2323
my $queries = qq(SET enable_seqscan=off;
@@ -32,35 +32,35 @@ sub test_index_replay
3232
);
3333

3434
# Run test queries and compare their result
35-
my $master_result = $node_master->safe_psql("postgres", $queries);
35+
my $primary_result = $node_primary->safe_psql("postgres", $queries);
3636
my $standby_result = $node_standby->safe_psql("postgres", $queries);
3737

38-
is($master_result, $standby_result, "$test_name: query result matches");
38+
is($primary_result, $standby_result, "$test_name: query result matches");
3939
return;
4040
}
4141

42-
# Initialize master node
43-
$node_master = get_new_node('master');
44-
$node_master->init(allows_streaming => 1);
45-
$node_master->start;
42+
# Initialize primary node
43+
$node_primary = get_new_node('primary');
44+
$node_primary->init(allows_streaming => 1);
45+
$node_primary->start;
4646
my $backup_name = 'my_backup';
4747

4848
# Take backup
49-
$node_master->backup($backup_name);
49+
$node_primary->backup($backup_name);
5050

51-
# Create streaming standby linking to master
51+
# Create streaming standby linking to primary
5252
$node_standby = get_new_node('standby');
53-
$node_standby->init_from_backup($node_master, $backup_name,
53+
$node_standby->init_from_backup($node_primary, $backup_name,
5454
has_streaming => 1);
5555
$node_standby->start;
5656

57-
# Create some bloom index on master
58-
$node_master->safe_psql("postgres", "CREATE EXTENSION bloom;");
59-
$node_master->safe_psql("postgres", "CREATE TABLE tst (i int4, t text);");
60-
$node_master->safe_psql("postgres",
57+
# Create some bloom index on primary
58+
$node_primary->safe_psql("postgres", "CREATE EXTENSION bloom;");
59+
$node_primary->safe_psql("postgres", "CREATE TABLE tst (i int4, t text);");
60+
$node_primary->safe_psql("postgres",
6161
"INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,100000) i;"
6262
);
63-
$node_master->safe_psql("postgres",
63+
$node_primary->safe_psql("postgres",
6464
"CREATE INDEX bloomidx ON tst USING bloom (i, t) WITH (col1 = 3);");
6565

6666
# Test that queries give same result
@@ -69,12 +69,12 @@ sub test_index_replay
6969
# Run 10 cycles of table modification. Run test queries after each modification.
7070
for my $i (1 .. 10)
7171
{
72-
$node_master->safe_psql("postgres", "DELETE FROM tst WHERE i = $i;");
72+
$node_primary->safe_psql("postgres", "DELETE FROM tst WHERE i = $i;");
7373
test_index_replay("delete $i");
74-
$node_master->safe_psql("postgres", "VACUUM tst;");
74+
$node_primary->safe_psql("postgres", "VACUUM tst;");
7575
test_index_replay("vacuum $i");
7676
my ($start, $end) = (100001 + ($i - 1) * 10000, 100000 + $i * 10000);
77-
$node_master->safe_psql("postgres",
77+
$node_primary->safe_psql("postgres",
7878
"INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series($start,$end) i;"
7979
);
8080
test_index_replay("insert $i");

src/bin/pg_rewind/t/001_basic.pl

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,66 +13,66 @@ sub run_test
1313
my $test_mode = shift;
1414

1515
RewindTest::setup_cluster($test_mode);
16-
RewindTest::start_master();
16+
RewindTest::start_primary();
1717

18-
# Create a test table and insert a row in master.
19-
master_psql("CREATE TABLE tbl1 (d text)");
20-
master_psql("INSERT INTO tbl1 VALUES ('in master')");
18+
# Create a test table and insert a row in primary.
19+
primary_psql("CREATE TABLE tbl1 (d text)");
20+
primary_psql("INSERT INTO tbl1 VALUES ('in primary')");
2121

2222
# This test table will be used to test truncation, i.e. the table
23-
# is extended in the old master after promotion
24-
master_psql("CREATE TABLE trunc_tbl (d text)");
25-
master_psql("INSERT INTO trunc_tbl VALUES ('in master')");
23+
# is extended in the old primary after promotion
24+
primary_psql("CREATE TABLE trunc_tbl (d text)");
25+
primary_psql("INSERT INTO trunc_tbl VALUES ('in primary')");
2626

2727
# This test table will be used to test the "copy-tail" case, i.e. the
28-
# table is truncated in the old master after promotion
29-
master_psql("CREATE TABLE tail_tbl (id integer, d text)");
30-
master_psql("INSERT INTO tail_tbl VALUES (0, 'in master')");
28+
# table is truncated in the old primary after promotion
29+
primary_psql("CREATE TABLE tail_tbl (id integer, d text)");
30+
primary_psql("INSERT INTO tail_tbl VALUES (0, 'in primary')");
3131

32-
master_psql("CHECKPOINT");
32+
primary_psql("CHECKPOINT");
3333

3434
RewindTest::create_standby($test_mode);
3535

36-
# Insert additional data on master that will be replicated to standby
37-
master_psql("INSERT INTO tbl1 values ('in master, before promotion')");
38-
master_psql(
39-
"INSERT INTO trunc_tbl values ('in master, before promotion')");
40-
master_psql(
41-
"INSERT INTO tail_tbl SELECT g, 'in master, before promotion: ' || g FROM generate_series(1, 10000) g"
36+
# Insert additional data on primary that will be replicated to standby
37+
primary_psql("INSERT INTO tbl1 values ('in primary, before promotion')");
38+
primary_psql(
39+
"INSERT INTO trunc_tbl values ('in primary, before promotion')");
40+
primary_psql(
41+
"INSERT INTO tail_tbl SELECT g, 'in primary, before promotion: ' || g FROM generate_series(1, 10000) g"
4242
);
4343

44-
master_psql('CHECKPOINT');
44+
primary_psql('CHECKPOINT');
4545

4646
RewindTest::promote_standby();
4747

48-
# Insert a row in the old master. This causes the master and standby
48+
# Insert a row in the old primary. This causes the primary and standby
4949
# to have "diverged", it's no longer possible to just apply the
50-
# standy's logs over master directory - you need to rewind.
51-
master_psql("INSERT INTO tbl1 VALUES ('in master, after promotion')");
50+
# standy's logs over primary directory - you need to rewind.
51+
primary_psql("INSERT INTO tbl1 VALUES ('in primary, after promotion')");
5252

5353
# Also insert a new row in the standby, which won't be present in the
54-
# old master.
54+
# old primary.
5555
standby_psql("INSERT INTO tbl1 VALUES ('in standby, after promotion')");
5656

5757
# Insert enough rows to trunc_tbl to extend the file. pg_rewind should
5858
# truncate it back to the old size.
59-
master_psql(
60-
"INSERT INTO trunc_tbl SELECT 'in master, after promotion: ' || g FROM generate_series(1, 10000) g"
59+
primary_psql(
60+
"INSERT INTO trunc_tbl SELECT 'in primary, after promotion: ' || g FROM generate_series(1, 10000) g"
6161
);
6262

6363
# Truncate tail_tbl. pg_rewind should copy back the truncated part
6464
# (We cannot use an actual TRUNCATE command here, as that creates a
6565
# whole new relfilenode)
66-
master_psql("DELETE FROM tail_tbl WHERE id > 10");
67-
master_psql("VACUUM tail_tbl");
66+
primary_psql("DELETE FROM tail_tbl WHERE id > 10");
67+
primary_psql("VACUUM tail_tbl");
6868

6969
# Before running pg_rewind, do a couple of extra tests with several
7070
# option combinations. As the code paths taken by those tests
7171
# do not change for the "local" and "remote" modes, just run them
7272
# in "local" mode for simplicity's sake.
7373
if ($test_mode eq 'local')
7474
{
75-
my $master_pgdata = $node_master->data_dir;
75+
my $primary_pgdata = $node_primary->data_dir;
7676
my $standby_pgdata = $node_standby->data_dir;
7777

7878
# First check that pg_rewind fails if the target cluster is
@@ -82,7 +82,7 @@ sub run_test
8282
[
8383
'pg_rewind', '--debug',
8484
'--source-pgdata', $standby_pgdata,
85-
'--target-pgdata', $master_pgdata,
85+
'--target-pgdata', $primary_pgdata,
8686
'--no-sync'
8787
],
8888
'pg_rewind with running target');
@@ -94,20 +94,20 @@ sub run_test
9494
[
9595
'pg_rewind', '--debug',
9696
'--source-pgdata', $standby_pgdata,
97-
'--target-pgdata', $master_pgdata,
97+
'--target-pgdata', $primary_pgdata,
9898
'--no-sync', '--no-ensure-shutdown'
9999
],
100100
'pg_rewind --no-ensure-shutdown with running target');
101101

102102
# Stop the target, and attempt to run with a local source
103103
# still running. This fails as pg_rewind requires to have
104104
# a source cleanly stopped.
105-
$node_master->stop;
105+
$node_primary->stop;
106106
command_fails(
107107
[
108108
'pg_rewind', '--debug',
109109
'--source-pgdata', $standby_pgdata,
110-
'--target-pgdata', $master_pgdata,
110+
'--target-pgdata', $primary_pgdata,
111111
'--no-sync', '--no-ensure-shutdown'
112112
],
113113
'pg_rewind with unexpected running source');
@@ -121,30 +121,30 @@ sub run_test
121121
[
122122
'pg_rewind', '--debug',
123123
'--source-pgdata', $standby_pgdata,
124-
'--target-pgdata', $master_pgdata,
124+
'--target-pgdata', $primary_pgdata,
125125
'--no-sync', '--dry-run'
126126
],
127127
'pg_rewind --dry-run');
128128

129129
# Both clusters need to be alive moving forward.
130130
$node_standby->start;
131-
$node_master->start;
131+
$node_primary->start;
132132
}
133133

134134
RewindTest::run_pg_rewind($test_mode);
135135

136136
check_query(
137137
'SELECT * FROM tbl1',
138-
qq(in master
139-
in master, before promotion
138+
qq(in primary
139+
in primary, before promotion
140140
in standby, after promotion
141141
),
142142
'table content');
143143

144144
check_query(
145145
'SELECT * FROM trunc_tbl',
146-
qq(in master
147-
in master, before promotion
146+
qq(in primary
147+
in primary, before promotion
148148
),
149149
'truncation');
150150

@@ -160,7 +160,7 @@ sub run_test
160160
skip "unix-style permissions not supported on Windows", 1
161161
if ($windows_os);
162162

163-
ok(check_mode_recursive($node_master->data_dir(), 0700, 0600),
163+
ok(check_mode_recursive($node_primary->data_dir(), 0700, 0600),
164164
'check PGDATA permissions');
165165
}
166166

src/bin/pg_rewind/t/002_databases.pl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@ sub run_test
1313
my $test_mode = shift;
1414

1515
RewindTest::setup_cluster($test_mode, ['-g']);
16-
RewindTest::start_master();
16+
RewindTest::start_primary();
1717

18-
# Create a database in master with a table.
19-
master_psql('CREATE DATABASE inmaster');
20-
master_psql('CREATE TABLE inmaster_tab (a int)', 'inmaster');
18+
# Create a database in primary with a table.
19+
primary_psql('CREATE DATABASE inprimary');
20+
primary_psql('CREATE TABLE inprimary_tab (a int)', 'inprimary');
2121

2222
RewindTest::create_standby($test_mode);
2323

2424
# Create another database with another table, the creation is
2525
# replicated to the standby.
26-
master_psql('CREATE DATABASE beforepromotion');
27-
master_psql('CREATE TABLE beforepromotion_tab (a int)',
26+
primary_psql('CREATE DATABASE beforepromotion');
27+
primary_psql('CREATE TABLE beforepromotion_tab (a int)',
2828
'beforepromotion');
2929

3030
RewindTest::promote_standby();
3131

32-
# Create databases in the old master and the new promoted standby.
33-
master_psql('CREATE DATABASE master_afterpromotion');
34-
master_psql('CREATE TABLE master_promotion_tab (a int)',
35-
'master_afterpromotion');
32+
# Create databases in the old primary and the new promoted standby.
33+
primary_psql('CREATE DATABASE primary_afterpromotion');
34+
primary_psql('CREATE TABLE primary_promotion_tab (a int)',
35+
'primary_afterpromotion');
3636
standby_psql('CREATE DATABASE standby_afterpromotion');
3737
standby_psql('CREATE TABLE standby_promotion_tab (a int)',
3838
'standby_afterpromotion');
@@ -45,7 +45,7 @@ sub run_test
4545
check_query(
4646
'SELECT datname FROM pg_database ORDER BY 1',
4747
qq(beforepromotion
48-
inmaster
48+
inprimary
4949
postgres
5050
standby_afterpromotion
5151
template0
@@ -59,7 +59,7 @@ sub run_test
5959
skip "unix-style permissions not supported on Windows", 1
6060
if ($windows_os);
6161

62-
ok(check_mode_recursive($node_master->data_dir(), 0750, 0640),
62+
ok(check_mode_recursive($node_primary->data_dir(), 0750, 0640),
6363
'check PGDATA permissions');
6464
}
6565

0 commit comments

Comments
 (0)