blob: e84319d36586fd5851c2aba56bb05db44fbeecc2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
use strict;
use warnings;
use PostgresNode;
use TestLib;
use Test::More;
use Time::HiRes qw(usleep);
if ($windows_os)
{
plan skip_all => 'logrotate test not supported on Windows';
exit;
}
else
{
plan tests => 1;
}
my $tempdir = TestLib::tempdir;
my $node = get_new_node('primary');
$node->init(allows_streaming => 1);
$node->append_conf(
'postgresql.conf', qq(
logging_collector = on
log_directory = 'log'
log_filename = 'postgresql.log'
));
$node->start();
# Rename log file and rotate log. Then log file should appear again.
my $logfile = $node->data_dir . '/log/postgresql.log';
my $old_logfile = $node->data_dir . '/log/postgresql.old';
rename($logfile, $old_logfile);
$node->logrotate();
# pg_ctl logrotate doesn't wait until rotation request being completed. So
# we have to wait some time until log file appears.
my $attempts = 0;
my $max_attempts = 180 * 10;
while (not -e $logfile and $attempts < $max_attempts)
{
usleep(100_000);
$attempts++;
}
ok(-e $logfile, "log file exists");
$node->stop();
|