pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Close stdin where it's not needed in TestLib.pm procedures
11+ messages / 5 participants
[nested] [flat]
Commits from this thread:
2019-11-27 ca266a069a Revert "Close stdin where it's not needed in TestLib.pm procedures"
* pgsql: Close stdin where it's not needed in TestLib.pm procedures
@ 2019-11-25 21:01 Andrew Dunstan <andrew@dunslane.net>
0 siblings, 1 reply; 11+ messages in thread
From: Andrew Dunstan @ 2019-11-25 21:01 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Close stdin where it's not needed in TestLib.pm procedures
Where possible, do this using a pseudoterminal, so that things like
openssl that want to open /dev/tty if stdin isn't a tty won't.
Elsewhere, i.e. Windows, just close by providing an empty string using
the standard IPC::Run pipe mechanism.
Patch by Andrew Dunstan, based on an idea from Craig Ringer.
Reviewed by Mark Dilger.
Discussion: https://postgr.es/m/873ebb57-fc98-340d-949d-691b1810bf66@2ndQuadrant.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/9af34f3c6b02779fac6dbb6cd4c5bb225a019f43
Modified Files
--------------
src/test/perl/TestLib.pm | 37 +++++++++++++++++++++++++++----------
1 file changed, 27 insertions(+), 10 deletions(-)
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: pgsql: Close stdin where it's not needed in TestLib.pm procedures
@ 2019-11-26 04:43 Michael Paquier <michael@paquier.xyz>
parent: Andrew Dunstan <andrew@dunslane.net>
0 siblings, 2 replies; 11+ messages in thread
From: Michael Paquier @ 2019-11-26 04:43 UTC (permalink / raw)
To: Andrew Dunstan <andrew@dunslane.net>; +Cc: pgsql-committers@lists.postgresql.org
Hi Andrew,
On Mon, Nov 25, 2019 at 09:01:46PM +0000, Andrew Dunstan wrote:
> Close stdin where it's not needed in TestLib.pm procedures
>
> Where possible, do this using a pseudoterminal, so that things like
> openssl that want to open /dev/tty if stdin isn't a tty won't.
> Elsewhere, i.e. Windows, just close by providing an empty string using
> the standard IPC::Run pipe mechanism.
>
> Patch by Andrew Dunstan, based on an idea from Craig Ringer.
>
> Reviewed by Mark Dilger.
>
> Discussion: https://postgr.es/m/873ebb57-fc98-340d-949d-691b1810bf66@2ndQuadrant.com
This one is causing failures with the TAP tests of initdb on all AIX
animals and prairiedog:
# Running: initdb --help
Can't locate IO/Pty.pm in @INC (@INC contains: ../../../src/test/perl/
. /usr/local/perl5.8.3/lib/5.8.3/darwin-2level
[...]
Unexpected SCALAR(0x1987690) in harness() parameter 7 at
../../../src/test/perl//TestLib.pm line 692
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: pgsql: Close stdin where it's not needed in TestLib.pm procedures
@ 2019-11-26 07:13 Tom Lane <tgl@sss.pgh.pa.us>
parent: Michael Paquier <michael@paquier.xyz>
1 sibling, 1 reply; 11+ messages in thread
From: Tom Lane @ 2019-11-26 07:13 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Andrew Dunstan <andrew@dunslane.net>; pgsql-committers@lists.postgresql.org
Michael Paquier <michael@paquier.xyz> writes:
> On Mon, Nov 25, 2019 at 09:01:46PM +0000, Andrew Dunstan wrote:
>> Close stdin where it's not needed in TestLib.pm procedures
>>
>> Where possible, do this using a pseudoterminal, so that things like
>> openssl that want to open /dev/tty if stdin isn't a tty won't.
> This one is causing failures with the TAP tests of initdb on all AIX
> animals and prairiedog:
> # Running: initdb --help
> Can't locate IO/Pty.pm in @INC (@INC contains: ../../../src/test/perl/
> . /usr/local/perl5.8.3/lib/5.8.3/darwin-2level
Perhaps the "where possible" caveat needs to include a test whether
IO::Pty is installed? It's evidently not there by default everywhere.
It's possible that we should just move the goalposts and say IO::Pty
is required for TAP testing. I can foresee that we'll have to do
that if we ever want automated tests of psql's tab completion,
for example.
regards, tom lane
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: pgsql: Close stdin where it's not needed in TestLib.pm procedures
@ 2019-11-26 08:47 Michael Paquier <michael@paquier.xyz>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 11+ messages in thread
From: Michael Paquier @ 2019-11-26 08:47 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Andrew Dunstan <andrew@dunslane.net>; pgsql-committers@lists.postgresql.org
On Tue, Nov 26, 2019 at 02:13:50AM -0500, Tom Lane wrote:
> Perhaps the "where possible" caveat needs to include a test whether
> IO::Pty is installed? It's evidently not there by default everywhere.
>
> It's possible that we should just move the goalposts and say IO::Pty
> is required for TAP testing. I can foresee that we'll have to do
> that if we ever want automated tests of psql's tab completion,
> for example.
Hmm. I am not sure that we are at that point yet (in which case we'd
need to check after it in configure). Any other modules we require to
be installed are directly imported to our code, but here we visibly
have a dependency forced by the loaded code. My point is that it does
not impact platforms that do not need it, so it seems like a waste to
require for everybody something which is actually necessary only for a
portion of users running the TAP tests.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: pgsql: Close stdin where it's not needed in TestLib.pm procedures
@ 2019-11-26 08:51 Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
parent: Michael Paquier <michael@paquier.xyz>
1 sibling, 1 reply; 11+ messages in thread
From: Peter Eisentraut @ 2019-11-26 08:51 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; Andrew Dunstan <andrew@dunslane.net>; +Cc: pgsql-committers@lists.postgresql.org
On 2019-11-26 05:43, Michael Paquier wrote:
> This one is causing failures with the TAP tests of initdb on all AIX
> animals and prairiedog:
> # Running: initdb --help
> Can't locate IO/Pty.pm in @INC (@INC contains: ../../../src/test/perl/
> . /usr/local/perl5.8.3/lib/5.8.3/darwin-2level
> [...]
> Unexpected SCALAR(0x1987690) in harness() parameter 7 at
> ../../../src/test/perl//TestLib.pm line 692
I'm also seeing this problem on macOS in
src/test/recovery/t/016_min_consistency.pl .
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: pgsql: Close stdin where it's not needed in TestLib.pm procedures
@ 2019-11-26 12:51 Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
parent: Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 11+ messages in thread
From: Andrew Dunstan @ 2019-11-26 12:51 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Andrew Dunstan <andrew@dunslane.net>; pgsql-committers@lists.postgresql.org
On 11/26/19 3:47 AM, Michael Paquier wrote:
> On Tue, Nov 26, 2019 at 02:13:50AM -0500, Tom Lane wrote:
>> Perhaps the "where possible" caveat needs to include a test whether
>> IO::Pty is installed? It's evidently not there by default everywhere.
>>
>> It's possible that we should just move the goalposts and say IO::Pty
>> is required for TAP testing. I can foresee that we'll have to do
>> that if we ever want automated tests of psql's tab completion,
>> for example.
> Hmm. I am not sure that we are at that point yet (in which case we'd
> need to check after it in configure). Any other modules we require to
> be installed are directly imported to our code, but here we visibly
> have a dependency forced by the loaded code. My point is that it does
> not impact platforms that do not need it, so it seems like a waste to
> require for everybody something which is actually necessary only for a
> portion of users running the TAP tests.
Yeah, I don't want to go that far at this stage at least.
here's my proposed fix.
I will adjust the code that wants to use it to have a block containing
the tests that need the pty code something like this:
SKIP:
{
skip 3, "no Pty support" unless $have_io_pty;
...
}
cheers
andrew
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:
fix-testlib-pty.patch (text/x-patch, 1.9K) download
diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm
index 18b4ce35c2..7d62914218 100644
--- a/src/test/perl/TestLib.pm
+++ b/src/test/perl/TestLib.pm
@@ -21,6 +21,7 @@ TestLib - helper module for writing PostgreSQL's C<prove> tests.
# Miscellanea
print "on Windows" if $TestLib::windows_os;
+ print "IO::Pty is available" If $TestLib::have_io_pty;
my $path = TestLib::perl2host($backup_dir);
ok(check_mode_recursive($stream_dir, 0700, 0600),
"check stream dir permissions");
@@ -83,9 +84,10 @@ our @EXPORT = qw(
command_checks_all
$windows_os
+ $have_io_pty
);
-our ($windows_os, $tmp_check, $log_path, $test_logfile);
+our ($windows_os, $tmp_check, $log_path, $test_logfile, $have_io_pty);
my @no_stdin;
@@ -119,6 +121,9 @@ BEGIN
require Win32API::File;
Win32API::File->import(qw(createFile OsFHandleOpen CloseHandle));
}
+
+ eval { require IO::Pty; };
+ $have_io_pty = 1 unless $@;
}
=pod
@@ -133,6 +138,11 @@ Set to true when running under Windows, except on Cygwin.
=back
+=item C<$have_io_pty>
+
+Set to true when IO::Pty is available.
+
+=back
=cut
INIT
@@ -182,18 +192,17 @@ INIT
autoflush $testlog 1;
# Settings to close stdin for certain commands.
- # On non-Windows, use a pseudo-terminal, so that libraries like openssl
- # which open the tty if they think stdin isn't one for a password
- # don't block. Windows doesn't have ptys, so just provide an empty
- # string for stdin.
- if ($windows_os)
+ # If IO::Pty is present, use a pseudo-terminal, so that libraries like
+ # openssl which open the tty if they think stdin isn't one for a password
+ # don't block. Elsewhere just provide an empty string for stdin.
+ if ($have_io_pty)
{
- @no_stdin = ('<', \"");
+ use charnames ':full';
+ @no_stdin = ('<pty<', \"\N{END OF TRANSMISSION}");
}
else
{
- use charnames ':full';
- @no_stdin = ('<pty<', \"\N{END OF TRANSMISSION}");
+ @no_stdin = ('<', \"");
}
}
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: pgsql: Close stdin where it's not needed in TestLib.pm procedures
@ 2019-11-26 14:51 Tom Lane <tgl@sss.pgh.pa.us>
parent: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
0 siblings, 0 replies; 11+ messages in thread
From: Tom Lane @ 2019-11-26 14:51 UTC (permalink / raw)
To: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>; +Cc: Michael Paquier <michael@paquier.xyz>; Andrew Dunstan <andrew@dunslane.net>; pgsql-committers@lists.postgresql.org
Andrew Dunstan <andrew.dunstan@2ndquadrant.com> writes:
> here's my proposed fix.
Looks sane by eyeball (didn't test it).
regards, tom lane
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: pgsql: Close stdin where it's not needed in TestLib.pm procedures
@ 2019-11-26 20:30 Tom Lane <tgl@sss.pgh.pa.us>
parent: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
0 siblings, 1 reply; 11+ messages in thread
From: Tom Lane @ 2019-11-26 20:30 UTC (permalink / raw)
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; +Cc: Michael Paquier <michael@paquier.xyz>; Andrew Dunstan <andrew@dunslane.net>; pgsql-committers@lists.postgresql.org
Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:
> On 2019-11-26 05:43, Michael Paquier wrote:
>> This one is causing failures with the TAP tests of initdb on all AIX
>> animals and prairiedog:
>> # Running: initdb --help
>> Can't locate IO/Pty.pm in @INC (@INC contains: ../../../src/test/perl/
>> . /usr/local/perl5.8.3/lib/5.8.3/darwin-2level
>> [...]
>> Unexpected SCALAR(0x1987690) in harness() parameter 7 at
>> ../../../src/test/perl//TestLib.pm line 692
> I'm also seeing this problem on macOS in
> src/test/recovery/t/016_min_consistency.pl .
I just noticed that my buildfarm animal longfin has been stuck for
the past 24 hours in t/001_initdb.pl, and I can replicate that
in a manual build. ktrace says it's in some sort of loop.
Apparently, macOS has got IO::Pty but it doesn't actually work
the way this patch expects. Therefore, the proposed patch will
leave things still broken for macOS :-(
I tried this:
inline patch 1: src/test/perl/TestLib.pm (+1/-2 lines) download inline-1.patch
diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm
index 18b4ce35c2..d67ffc4368 100644
--- a/src/test/perl/TestLib.pm
+++ b/src/test/perl/TestLib.pm
@@ -192,8 +192,7 @@ INIT
}
else
{
- use charnames ':full';
- @no_stdin = ('<pty<', \"\N{END OF TRANSMISSION}");
+ @no_stdin = ('<pty<', \"");
}
}
and that seems to fix it. I wonder what's the point of sending
a nonempty string to the pty, exactly?
regards, tom lane
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: pgsql: Close stdin where it's not needed in TestLib.pm procedures
@ 2019-11-26 22:08 Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 11+ messages in thread
From: Andrew Dunstan @ 2019-11-26 22:08 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; +Cc: Michael Paquier <michael@paquier.xyz>; Andrew Dunstan <andrew@dunslane.net>; pgsql-committers@lists.postgresql.org
On 11/26/19 3:30 PM, Tom Lane wrote:
> Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:
>> On 2019-11-26 05:43, Michael Paquier wrote:
>>> This one is causing failures with the TAP tests of initdb on all AIX
>>> animals and prairiedog:
>>> # Running: initdb --help
>>> Can't locate IO/Pty.pm in @INC (@INC contains: ../../../src/test/perl/
>>> . /usr/local/perl5.8.3/lib/5.8.3/darwin-2level
>>> [...]
>>> Unexpected SCALAR(0x1987690) in harness() parameter 7 at
>>> ../../../src/test/perl//TestLib.pm line 692
>> I'm also seeing this problem on macOS in
>> src/test/recovery/t/016_min_consistency.pl .
> I just noticed that my buildfarm animal longfin has been stuck for
> the past 24 hours in t/001_initdb.pl, and I can replicate that
> in a manual build. ktrace says it's in some sort of loop.
>
> Apparently, macOS has got IO::Pty but it doesn't actually work
> the way this patch expects. Therefore, the proposed patch will
> leave things still broken for macOS :-(
>
> I tried this:
>
> diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm
> index 18b4ce35c2..d67ffc4368 100644
> --- a/src/test/perl/TestLib.pm
> +++ b/src/test/perl/TestLib.pm
> @@ -192,8 +192,7 @@ INIT
> }
> else
> {
> - use charnames ':full';
> - @no_stdin = ('<pty<', \"\N{END OF TRANSMISSION}");
> + @no_stdin = ('<pty<', \"");
> }
> }
>
> and that seems to fix it. I wonder what's the point of sending
> a nonempty string to the pty, exactly?
>
>
Oh, I missed seeing this.
The short answer is I didn't question it because it worked for me. I'll
test out your change on Linux with my test case.
cheers
andrew
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: pgsql: Close stdin where it's not needed in TestLib.pm procedures
@ 2019-11-27 02:36 Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
parent: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
0 siblings, 1 reply; 11+ messages in thread
From: Andrew Dunstan @ 2019-11-27 02:36 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; +Cc: Michael Paquier <michael@paquier.xyz>; Andrew Dunstan <andrew@dunslane.net>; pgsql-committers@lists.postgresql.org
On 11/26/19 5:08 PM, Andrew Dunstan wrote:
> On 11/26/19 3:30 PM, Tom Lane wrote:
>> Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:
>>> On 2019-11-26 05:43, Michael Paquier wrote:
>>>> This one is causing failures with the TAP tests of initdb on all AIX
>>>> animals and prairiedog:
>>>> # Running: initdb --help
>>>> Can't locate IO/Pty.pm in @INC (@INC contains: ../../../src/test/perl/
>>>> . /usr/local/perl5.8.3/lib/5.8.3/darwin-2level
>>>> [...]
>>>> Unexpected SCALAR(0x1987690) in harness() parameter 7 at
>>>> ../../../src/test/perl//TestLib.pm line 692
>>> I'm also seeing this problem on macOS in
>>> src/test/recovery/t/016_min_consistency.pl .
>> I just noticed that my buildfarm animal longfin has been stuck for
>> the past 24 hours in t/001_initdb.pl, and I can replicate that
>> in a manual build. ktrace says it's in some sort of loop.
>>
>> Apparently, macOS has got IO::Pty but it doesn't actually work
>> the way this patch expects. Therefore, the proposed patch will
>> leave things still broken for macOS :-(
>>
>> I tried this:
>>
>> diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm
>> index 18b4ce35c2..d67ffc4368 100644
>> --- a/src/test/perl/TestLib.pm
>> +++ b/src/test/perl/TestLib.pm
>> @@ -192,8 +192,7 @@ INIT
>> }
>> else
>> {
>> - use charnames ':full';
>> - @no_stdin = ('<pty<', \"\N{END OF TRANSMISSION}");
>> + @no_stdin = ('<pty<', \"");
>> }
>> }
>>
>> and that seems to fix it. I wonder what's the point of sending
>> a nonempty string to the pty, exactly?
>>
>>
>
>
> Oh, I missed seeing this.
>
>
> The short answer is I didn't question it because it worked for me. I'll
> test out your change on Linux with my test case.
>
>
This causes some of the new tests I want to run to hang on Linux,
presumably waiting for the pty to close :-(
So I'm a bit stuck. Probably the best thing to do for now is revert the
patch and mark the tests that need it in the libpq-sslpassword patch as
TODO (with todo_skip). If somebody whose perl-fu is greater than mine
can disentangle this mess that would be nice :-)
Thoughts?
cheers
andrew
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: pgsql: Close stdin where it's not needed in TestLib.pm procedures
@ 2019-11-27 03:59 Michael Paquier <michael@paquier.xyz>
parent: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
0 siblings, 0 replies; 11+ messages in thread
From: Michael Paquier @ 2019-11-27 03:59 UTC (permalink / raw)
To: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; Andrew Dunstan <andrew@dunslane.net>; pgsql-committers@lists.postgresql.org
On Tue, Nov 26, 2019 at 09:36:50PM -0500, Andrew Dunstan wrote:
> So I'm a bit stuck. Probably the best thing to do for now is revert the
> patch and mark the tests that need it in the libpq-sslpassword patch as
> TODO (with todo_skip). If somebody whose perl-fu is greater than mine
> can disentangle this mess that would be nice :-)
A revert sounds fine to me at this point. Some buildfarm animals are
not reporting back :(
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 11+ messages in thread
end of thread, other threads:[~2019-11-27 03:59 UTC | newest]
Thread overview: 11+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-11-25 21:01 pgsql: Close stdin where it's not needed in TestLib.pm procedures Andrew Dunstan <andrew@dunslane.net>
2019-11-26 04:43 ` Michael Paquier <michael@paquier.xyz>
2019-11-26 07:13 ` Tom Lane <tgl@sss.pgh.pa.us>
2019-11-26 08:47 ` Michael Paquier <michael@paquier.xyz>
2019-11-26 12:51 ` Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
2019-11-26 14:51 ` Tom Lane <tgl@sss.pgh.pa.us>
2019-11-26 08:51 ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2019-11-26 20:30 ` Tom Lane <tgl@sss.pgh.pa.us>
2019-11-26 22:08 ` Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
2019-11-27 02:36 ` Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
2019-11-27 03:59 ` Michael Paquier <michael@paquier.xyz>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox