mirror of
https://github.com/postgres/postgres.git
synced 2025-06-22 02:52:08 +03:00
Allow TestLib::slurp_file to skip contents, and use as needed
In order to avoid getting old logfile contents certain functions in PostgresNode were doing one of two things. On Windows it rotated the logfile and restarted the server, while elsewhere it truncated the log file. Both of these are unnecessary. We borrow from the buildfarm which does this instead: note the size of the logfile before we start, and then when fetching the logfile skip to that position before accumulating contents. This is spelled differently on Windows but the effect is the same. This is largely centralized in TestLib's slurp_file function, which has a new optional parameter, the offset to skip to before starting to reading the file. Code in the client becomes much neater. Backpatch to all live branches. Michael Paquier, slightly modified by me. Discussion: https://postgr.es/m/YHajnhcMAI3++pJL@paquier.xyz
This commit is contained in:
@ -1616,9 +1616,6 @@ sub command_checks_all
|
||||
Run a command on the node, then verify that $expected_sql appears in the
|
||||
server log file.
|
||||
|
||||
Reads the whole log file so be careful when working with large log outputs.
|
||||
The log file is truncated prior to running the command, however.
|
||||
|
||||
=cut
|
||||
|
||||
sub issues_sql_like
|
||||
@ -1628,10 +1625,11 @@ sub issues_sql_like
|
||||
local $ENV{PGHOST} = $self->host;
|
||||
local $ENV{PGPORT} = $self->port;
|
||||
|
||||
truncate $self->logfile, 0;
|
||||
my $log_location = -s $self->logfile;
|
||||
|
||||
my $result = TestLib::run_log($cmd);
|
||||
ok($result, "@$cmd exit code 0");
|
||||
my $log = TestLib::slurp_file($self->logfile);
|
||||
my $log = TestLib::slurp_file($self->logfile, $log_location);
|
||||
like($log, $expected_sql, "$test_name: SQL found in server log");
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user