TAP tests still sensitive to various PG* environment variables

Started by Michael Paquierover 4 years ago5 messages
#1Michael Paquier
michael@paquier.xyz
1 attachment(s)

Hi all,

While looking at a separate issue, I have noticed that TestLib.pm is
lagging behind in terms of environment variables it had better mask to
avoid failures:
/messages/by-id/YLXjFOV3teAPirmS@paquier.xyz

Once I began playing with the variables not covered yet, and tested
fancy cases with junk values, I have been able to see various failures
in the TAP tests, mainly with authentication and SSL.

Attached is a patch to strengthen all that, which I think we'd better
backpatch.

Any objections to that?
--
Michael

Attachments:

testlib-envs.patchtext/x-diff; charset=us-asciiDownload
diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm
index d6c3eb8723..d4f9fc5f2b 100644
--- a/src/test/perl/TestLib.pm
+++ b/src/test/perl/TestLib.pm
@@ -104,13 +104,30 @@ BEGIN
 	delete $ENV{LC_ALL};
 	$ENV{LC_MESSAGES} = 'C';
 
+	delete $ENV{PGCHANNELBINDING};
+	delete $ENV{PGCLIENTENCODING};
 	delete $ENV{PGCONNECT_TIMEOUT};
 	delete $ENV{PGDATA};
 	delete $ENV{PGDATABASE};
+	delete $ENV{PGGSSENCMODE};
+	delete $ENV{PGGSSLIB};
 	delete $ENV{PGHOSTADDR};
+	delete $ENV{PGKRBSRVNAME};
+	delete $ENV{PGPASSFILE};
+	delete $ENV{PGPASSWORD};
+	delete $ENV{PGREQUIREPEER};
 	delete $ENV{PGREQUIRESSL};
 	delete $ENV{PGSERVICE};
+	delete $ENV{PGSERVICEFILE};
+	delete $ENV{PGSSLCERT};
+	delete $ENV{PGSSLCRL};
+	delete $ENV{PGSSLCRLDIR};
+	delete $ENV{PGSSLKEY};
+	delete $ENV{PGSSLMAXPROTOCOLVERSION};
+	delete $ENV{PGSSLMINPROTOCOLVERSION};
 	delete $ENV{PGSSLMODE};
+	delete $ENV{PGSSLROOTCERT};
+	delete $ENV{PGSSLSNI};
 	delete $ENV{PGUSER};
 	delete $ENV{PGPORT};
 	delete $ENV{PGHOST};
#2Daniel Gustafsson
daniel@yesql.se
In reply to: Michael Paquier (#1)
Re: TAP tests still sensitive to various PG* environment variables

On 2 Jun 2021, at 03:49, Michael Paquier <michael@paquier.xyz> wrote:

Attached is a patch to strengthen all that, which I think we'd better
backpatch.

+1

Any objections to that?

Seems like a good idea, to keep test invocation stable across branches, minus
PGSSLCRLDIR and PGSSLSNI which are only available in HEAD etc.

--
Daniel Gustafsson https://vmware.com/

#3Andrew Dunstan
andrew@dunslane.net
In reply to: Michael Paquier (#1)
Re: TAP tests still sensitive to various PG* environment variables

On 6/1/21 9:49 PM, Michael Paquier wrote:

Hi all,

While looking at a separate issue, I have noticed that TestLib.pm is
lagging behind in terms of environment variables it had better mask to
avoid failures:
/messages/by-id/YLXjFOV3teAPirmS@paquier.xyz

Once I began playing with the variables not covered yet, and tested
fancy cases with junk values, I have been able to see various failures
in the TAP tests, mainly with authentication and SSL.

Attached is a patch to strengthen all that, which I think we'd better
backpatch.

Any objections to that?

This is a bit gruesome:

    +��� delete $ENV{PGCHANNELBINDING};
    +��� delete $ENV{PGCLIENTENCODING};
    ���� delete $ENV{PGCONNECT_TIMEOUT};
    ���� delete $ENV{PGDATA};
    ���� delete $ENV{PGDATABASE};
    +��� delete $ENV{PGGSSENCMODE};
    +��� delete $ENV{PGGSSLIB};
    ���� delete $ENV{PGHOSTADDR};
    +��� delete $ENV{PGKRBSRVNAME};
    +��� delete $ENV{PGPASSFILE};
    +��� delete $ENV{PGPASSWORD};
    +��� delete $ENV{PGREQUIREPEER};
    ���� delete $ENV{PGREQUIRESSL};
    ���� delete $ENV{PGSERVICE};
    +��� delete $ENV{PGSERVICEFILE};
    +��� delete $ENV{PGSSLCERT};
    +��� delete $ENV{PGSSLCRL};
    +��� delete $ENV{PGSSLCRLDIR};
    +��� delete $ENV{PGSSLKEY};
    +��� delete $ENV{PGSSLMAXPROTOCOLVERSION};
    +��� delete $ENV{PGSSLMINPROTOCOLVERSION};
    ���� delete $ENV{PGSSLMODE};
    +��� delete $ENV{PGSSLROOTCERT};
    +��� delete $ENV{PGSSLSNI};
    ���� delete $ENV{PGUSER};
    ���� delete $ENV{PGPORT};
    ���� delete $ENV{PGHOST};

Let's change it to something like:

my @scrubkeys = qw ( PGCHANNELBINDING

�� PGCLIENTENCODING PGCONNECT_TIMEOUT PGDATA

�� ...

��� );

delete @ENV{@scrubkeys};

cheers

andrew

--

Andrew Dunstan
EDB: https://www.enterprisedb.com

#4Michael Paquier
michael@paquier.xyz
In reply to: Andrew Dunstan (#3)
Re: TAP tests still sensitive to various PG* environment variables

On Wed, Jun 02, 2021 at 03:43:46PM -0400, Andrew Dunstan wrote:

Let's change it to something like:

my @scrubkeys = qw ( PGCHANNELBINDING
   PGCLIENTENCODING PGCONNECT_TIMEOUT PGDATA
   ...
    );
delete @ENV{@scrubkeys};

Good idea. I have used that. Thanks.
--
Michael

#5Michael Paquier
michael@paquier.xyz
In reply to: Daniel Gustafsson (#2)
Re: TAP tests still sensitive to various PG* environment variables

On Wed, Jun 02, 2021 at 10:39:56AM +0200, Daniel Gustafsson wrote:

Seems like a good idea, to keep test invocation stable across branches, minus
PGSSLCRLDIR and PGSSLSNI which are only available in HEAD etc.

Right. This took me a couple of hours to make consistent across
all the branches. After more review, I have found also about
PGTARGETSESSIONATTRS that would take down the recovery tests as of
10~. Fun.
--
Michael