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

Commit9821492

Browse files
committed
Cleanup some problems in new Perl test code
Noted by Tom Lane:- PostgresNode had a BEGIN block which created files, contrary to perlmod suggestions to do that only on INIT blocks.- Assign ports randomly rather than starting from 90600.Noted by Noah Misch:- Change use of no-longer-set PGPORT environment variable to $node->port- Don't start a server in pg_controldata test- PostgresNode was reading the PID file incorrectly; test the right thing, and chomp the line we read from the PID file.- Remove an unused $devnull variable- Use 'pg_ctl kill' instead of "kill" directly, for Windos portability.- Make server log names more informative.Author: Michael Paquier
1 parentb0cfb02 commit9821492

File tree

3 files changed

+14
-19
lines changed

3 files changed

+14
-19
lines changed

‎src/bin/pg_basebackup/t/010_pg_basebackup.pl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,14 @@
168168

169169
# using a character class for the final "'" here works around an apparent
170170
# bug in several version of the Msys DTK perl
171+
my$port =$node->port;
171172
like(
172173
$recovery_conf,
173174
qr/^standby_mode = 'on[']$/m,
174175
'recovery.conf sets standby_mode');
175176
like(
176177
$recovery_conf,
177-
qr/^primary_conninfo = '.*port=$ENV{PGPORT}.*'$/m,
178+
qr/^primary_conninfo = '.*port=$port.*'$/m,
178179
'recovery.conf sets primary_conninfo');
179180

180181
$node->command_ok(

‎src/bin/pg_controldata/t/001_pg_controldata.pl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
my$node = get_new_node();
1515
$node->init;
16-
$node->start;
1716

1817
command_like(['pg_controldata',$node->data_dir ],
1918
qr/checkpoint/,'pg_controldata produces output');

‎src/test/perl/PostgresNode.pm

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ our @EXPORT = qw(
2727

2828
our ($test_pghost,$last_port_assigned,@all_nodes);
2929

30-
BEGIN
30+
INIT
3131
{
32-
3332
# PGHOST is set once and for all through a single series of tests when
3433
# this module is loaded.
3534
$test_pghost =
@@ -38,24 +37,22 @@ BEGIN
3837
$ENV{PGDATABASE} ='postgres';
3938

4039
# Tracking of last port value assigned to accelerate free port lookup.
41-
# XXX: Should this use PG_VERSION_NUM?
42-
$last_port_assigned = 90600 % 16384 + 49152;
43-
44-
# Node tracking
45-
@all_nodes = ();
40+
$last_port_assigned =int(rand() * 16384) + 49152;
4641
}
4742

4843
subnew
4944
{
5045
my$class =shift;
5146
my$pghost =shift;
5247
my$pgport =shift;
48+
my$testname = basename($0);
49+
$testname =~s/\.[^.]+$//;
5350
my$self = {
5451
_port=>$pgport,
5552
_host=>$pghost,
5653
_basedir=> TestLib::tempdir,
5754
_applname=>"node_$pgport",
58-
_logfile=>"$TestLib::log_path/node_$pgport.log" };
55+
_logfile=>"$TestLib::log_path/${testname}_node_${pgport}.log" };
5956

6057
bless$self,$class;
6158
$self->dump_info;
@@ -297,17 +294,16 @@ sub _update_pid
297294
# If we can open the PID file, read its first line and that's the PID we
298295
# want. If the file cannot be opened, presumably the server is not
299296
# running; don't be noisy in that case.
300-
openmy$pidfile,$self->data_dir ."/postmaster.pid";
301-
if (notdefined$pidfile)
297+
if (openmy$pidfile,$self->data_dir ."/postmaster.pid")
302298
{
303-
$self->{_pid} =undef;
304-
print"# No postmaster PID\n";
299+
chomp($self->{_pid} = <$pidfile>);
300+
print"# Postmaster PID is$self->{_pid}\n";
301+
close$pidfile;
305302
return;
306303
}
307304

308-
$self->{_pid} = <$pidfile>;
309-
print"# Postmaster PID is$self->{_pid}\n";
310-
close$pidfile;
305+
$self->{_pid} =undef;
306+
print"# No postmaster PID\n";
311307
}
312308

313309
#
@@ -327,7 +323,6 @@ sub get_new_node
327323
{
328324
$port++;
329325
print"# Checking for port$port\n";
330-
my$devnull =$TestLib::windows_os ?"nul" :"/dev/null";
331326
if (!TestLib::run_log(['pg_isready','-p',$port ]))
332327
{
333328
$found = 1;
@@ -360,7 +355,7 @@ sub DESTROY
360355
my$self =shift;
361356
returnifnotdefined$self->{_pid};
362357
print"# signalling QUIT to$self->{_pid}\n";
363-
kill'QUIT',$self->{_pid};
358+
TestLib::system_log('pg_ctl','kill','QUIT',$self->{_pid});
364359
}
365360

366361
subteardown_node

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp