Skip to content

Commit 11e1577

Browse files
committed
Simplify TAP tests of kerberos with expected log file contents
The TAP tests of kerberos rely on the logs generated by the backend to check various connection scenarios. In order to make sure that a given test does not overlap with the log contents generated by a previous test, the test suite relied on a logic with the logging collector and a rotation of the log files to ensure the uniqueness of the log generated with a wait phase. Parsing the log contents for expected patterns is a problem that has been solved in a simpler way by PostgresNode::issues_sql_like() where the log file is truncated before checking for the contents generated, with the backend sending its output to a log file given by pg_ctl instead. This commit switches the kerberos test suite to use such a method, removing any wait phase and simplifying the whole logic, resulting in less code. If a failure happens in the tests, the contents of the logs are still showed to the user at the moment of the failure thanks to like(), so this has no impact on debugging capabilities. I have bumped into this issue while reviewing a different patch set aiming at extending the kerberos test suite to check for multiple log patterns instead of one now. Author: Michael Paquier Reviewed-by: Stephen Frost, Bharath Rupireddy Discussion: https://postgr.es/m/YFXcq2vBTDGQVBNC@paquier.xyz
1 parent 595b9cb commit 11e1577

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

src/test/kerberos/t/001_auth.pl

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
if ($ENV{with_gssapi} eq 'yes')
2222
{
23-
plan tests => 34;
23+
plan tests => 26;
2424
}
2525
else
2626
{
@@ -170,10 +170,7 @@ END
170170
'postgresql.conf', qq{
171171
listen_addresses = '$hostaddr'
172172
krb_server_keyfile = '$keytab'
173-
logging_collector = on
174173
log_connections = on
175-
# these ensure stability of test results:
176-
log_rotation_age = 0
177174
lc_messages = 'C'
178175
});
179176
$node->start;
@@ -212,29 +209,15 @@ sub test_access
212209
# Verify specified log message is logged in the log file.
213210
if ($expect_log_msg ne '')
214211
{
215-
my $current_logfiles = slurp_file($node->data_dir . '/current_logfiles');
216-
note "current_logfiles = $current_logfiles";
217-
like($current_logfiles, qr|^stderr log/postgresql-.*log$|,
218-
'current_logfiles is sane');
219-
220-
my $lfname = $current_logfiles;
221-
$lfname =~ s/^stderr //;
222-
chomp $lfname;
223-
224-
# might need to retry if logging collector process is slow...
225-
my $max_attempts = 180 * 10;
226-
my $first_logfile;
227-
for (my $attempts = 0; $attempts < $max_attempts; $attempts++)
228-
{
229-
$first_logfile = slurp_file($node->data_dir . '/' . $lfname);
230-
last if $first_logfile =~ m/\Q$expect_log_msg\E/;
231-
usleep(100_000);
232-
}
212+
my $first_logfile = slurp_file($node->logfile);
233213

234214
like($first_logfile, qr/\Q$expect_log_msg\E/,
235215
'found expected log file content');
236216
}
237217

218+
# Clean up any existing contents in the node's log file so as
219+
# future tests don't step on each other's generated contents.
220+
truncate $node->logfile, 0;
238221
return;
239222
}
240223

0 commit comments

Comments
 (0)