Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8a19c1a

Browse files
committed
Make PostgresNode::append_conf append a newline automatically.
Although the documentation for append_conf said clearly that it didn'tadd a newline, many test authors seem to have forgotten that ... or maybethey just consulted the example at the top of the POD documentation,which clearly shows adding a config entry without bothering to add atrailing newline. The worst part of that is that it works, as long asyou don't do it more than once, since the backend isn't picky aboutwhether config files end with newlines. So there's not a strong forcingfunction reminding test authors not to do it like that. Upshot is thatthis is a terribly fragile way to go about things, and there's at leastone existing test case that is demonstrably broken and not testing whatit thinks it is.Let's just make append_conf append a newline, instead; that is clearlyway safer than the old definition.I also cleaned up a few call sites that were unnecessarily ugly.(I left things alone in places where it's plausible that additionalconfig lines would need to be added someday.)Back-patch the change in append_conf itself to 9.6 where it was added,as having a definitional inconsistency between branches would obviouslybe pretty hazardous for back-patching TAP tests. The other changes arejust cosmetic and don't need to be back-patched.Discussion:https://postgr.es/m/19751.1492892376@sss.pgh.pa.us
1 parentf92562a commit8a19c1a

File tree

5 files changed

+14
-27
lines changed

5 files changed

+14
-27
lines changed

‎src/test/modules/commit_ts/t/004_restart.pl

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77

88
my$node_master = get_new_node('master');
99
$node_master->init(allows_streaming=> 1);
10-
$node_master->append_conf(
11-
'postgresql.conf',qq(
12-
track_commit_timestamp = on
13-
));
10+
$node_master->append_conf('postgresql.conf','track_commit_timestamp = on');
1411
$node_master->start;
1512

1613
my ($ret,$stdout,$stderr);
@@ -75,10 +72,7 @@
7572

7673
# Now disable commit timestamps
7774

78-
$node_master->append_conf(
79-
'postgresql.conf',qq(
80-
track_commit_timestamp = off
81-
));
75+
$node_master->append_conf('postgresql.conf','track_commit_timestamp = off');
8276

8377
$node_master->stop('fast');
8478
$node_master->start;
@@ -110,10 +104,7 @@
110104
'expected error from disabled tx when committs disabled');
111105

112106
# Re-enable, restart and ensure we can still get the old timestamps
113-
$node_master->append_conf(
114-
'postgresql.conf',qq(
115-
track_commit_timestamp = on
116-
));
107+
$node_master->append_conf('postgresql.conf','track_commit_timestamp = on');
117108

118109
$node_master->stop('fast');
119110
$node_master->start;

‎src/test/perl/PostgresNode.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ A shortcut method to append to files like pg_hba.conf and postgresql.conf.
455455
Does no validation or sanity checking. Does not reload the configuration
456456
after writing.
457457
458-
A newline isNOTautomatically appended to the string.
458+
A newline is automatically appended to the string.
459459
460460
=cut
461461

@@ -465,7 +465,7 @@ sub append_conf
465465

466466
my$conffile =$self->data_dir .'/' .$filename;
467467

468-
TestLib::append_to_file($conffile,$str);
468+
TestLib::append_to_file($conffile,$str ."\n");
469469
}
470470

471471
=pod

‎src/test/recovery/t/001_stream_rep.pl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,16 @@ sub test_target_session_attrs
113113
# standbys. Since we're going to be testing things that affect the slot state,
114114
# also increase the standby feedback interval to ensure timely updates.
115115
my ($slotname_1,$slotname_2) = ('standby_1','standby_2');
116-
$node_master->append_conf('postgresql.conf',"max_replication_slots = 4\n");
116+
$node_master->append_conf('postgresql.conf',"max_replication_slots = 4");
117117
$node_master->restart;
118118
is($node_master->psql('postgres',qq[SELECT pg_create_physical_replication_slot('$slotname_1');]), 0,'physical slot created on master');
119-
$node_standby_1->append_conf('recovery.conf',"primary_slot_name =$slotname_1\n");
120-
$node_standby_1->append_conf('postgresql.conf',"wal_receiver_status_interval = 1\n");
121-
$node_standby_1->append_conf('postgresql.conf',"max_replication_slots = 4\n");
119+
$node_standby_1->append_conf('recovery.conf',"primary_slot_name =$slotname_1");
120+
$node_standby_1->append_conf('postgresql.conf',"wal_receiver_status_interval = 1");
121+
$node_standby_1->append_conf('postgresql.conf',"max_replication_slots = 4");
122122
$node_standby_1->restart;
123123
is($node_standby_1->psql('postgres',qq[SELECT pg_create_physical_replication_slot('$slotname_2');]), 0,'physical slot created on intermediate replica');
124-
$node_standby_2->append_conf('recovery.conf',"primary_slot_name =$slotname_2\n");
125-
$node_standby_2->append_conf('postgresql.conf',"wal_receiver_status_interval = 1\n");
124+
$node_standby_2->append_conf('recovery.conf',"primary_slot_name =$slotname_2");
125+
$node_standby_2->append_conf('postgresql.conf',"wal_receiver_status_interval = 1");
126126
$node_standby_2->restart;
127127

128128
subget_slot_xmins

‎src/test/recovery/t/002_archiving.pl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@
2323
my$node_standby = get_new_node('standby');
2424
$node_standby->init_from_backup($node_master,$backup_name,
2525
has_restoring=> 1);
26-
$node_standby->append_conf(
27-
'postgresql.conf',qq(
28-
wal_retrieve_retry_interval = '100ms'
29-
));
26+
$node_standby->append_conf('postgresql.conf',
27+
"wal_retrieve_retry_interval = '100ms'");
3028
$node_standby->start;
3129

3230
# Create some content on master

‎src/test/recovery/t/003_recovery_targets.pl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ sub test_recovery_standby
2323
foreachmy$param_item (@$recovery_params)
2424
{
2525
$node_standby->append_conf(
26-
'recovery.conf',
27-
qq($param_item
28-
));
26+
'recovery.conf',qq($param_item));
2927
}
3028

3129
$node_standby->start;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp