Skip to content

Commit c7578fa

Browse files
committed
Fix some failures with connection tests on Windows hosts
The truncation of the log file, that this set of tests relies on to make sure that a connection attempt matches with its expected backend log pattern, fails, as reported by buildfarm member fairywren. Instead of a truncation, do a rotation of the log file and restart the node. This will ensure that the connection attempt data is unique for each test. Discussion: https://postgr.es/m/YG05nCI8x8B+Ad3G@paquier.xyz
1 parent e717a9a commit c7578fa

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/test/perl/PostgresNode.pm

+22-2
Original file line numberDiff line numberDiff line change
@@ -1920,7 +1920,17 @@ sub connect_ok
19201920
if (@log_like or @log_unlike)
19211921
{
19221922
# Don't let previous log entries match for this connection.
1923-
truncate $self->logfile, 0;
1923+
# On Windows, the truncation would not work, so rotate the log
1924+
# file before restarting the server afresh.
1925+
if ($TestLib::windows_os)
1926+
{
1927+
$self->rotate_logfile;
1928+
$self->restart;
1929+
}
1930+
else
1931+
{
1932+
truncate $self->logfile, 0;
1933+
}
19241934
}
19251935

19261936
# Never prompt for a password, any callers of this routine should
@@ -1994,7 +2004,17 @@ sub connect_fails
19942004
if (@log_like or @log_unlike)
19952005
{
19962006
# Don't let previous log entries match for this connection.
1997-
truncate $self->logfile, 0;
2007+
# On Windows, the truncation would not work, so rotate the log
2008+
# file before restarting the server afresh.
2009+
if ($TestLib::windows_os)
2010+
{
2011+
$self->rotate_logfile;
2012+
$self->restart;
2013+
}
2014+
else
2015+
{
2016+
truncate $self->logfile, 0;
2017+
}
19982018
}
19992019

20002020
# Never prompt for a password, any callers of this routine should

0 commit comments

Comments
 (0)