pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Justin Pryzby <pryzby@telsasoft.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Christoph Berg <myon@debian.org>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: pgsql: Add TAP test to automate the equivalent of check_guc
Date: Fri, 11 Feb 2022 11:29:29 -0600
Message-ID: <20220211172929.GF31460@telsasoft.com> (raw)
In-Reply-To: <2027230.1644594087@sss.pgh.pa.us>
References: <E1nHbaO-0000MF-RO@gemulon.postgresql.org>
	<YgYw25OXV5men8Fj@msg.df7cb.de>
	<2023925.1644591595@sss.pgh.pa.us>
	<20220211153549.GE31460@telsasoft.com>
	<2027230.1644594087@sss.pgh.pa.us>

On Fri, Feb 11, 2022 at 10:41:27AM -0500, Tom Lane wrote:
> Justin Pryzby <pryzby@telsasoft.com> writes:
> > On Fri, Feb 11, 2022 at 09:59:55AM -0500, Tom Lane wrote:
> >> This seems like a pretty bad idea even if it weren't failing outright.
> >> We should be examining the version of the file that's in the source
> >> tree; the one in the installation tree might have version-skew
> >> problems, if you've not yet done "make install".
> 
> > My original way used the source tree, but Michael thought it would be an issue
> > for "installcheck" where the config may not be available.
> 
> Yeah, you are at risk either way, but in practice nobody is going to be
> running these TAP tests without a source tree.
> 
> > This is what I had written:
> > FROM (SELECT regexp_split_to_table(pg_read_file('postgresql.conf'), '\n') AS ln) conf
> 
> That's not using the source tree either, but the copy in the
> cluster-under-test.  I'd fear it to be unstable in the buildfarm, where
> animals can append whatever they please to the config file being used by
> tests.

The important test is that "new GUCs exist in sample.conf".  The converse test
is less interesting, so I think the important half would be okay.

I see the BF client appends to postgresql.conf.
https://github.com/PGBuildFarm/client-code/blob/main/run_build.pl#L1374

It could use "include", which was added in v8.2.  Or it could add a marker,
like pg_regress does:
src/test/regress/pg_regress.c:          fputs("\n# Configuration added by pg_regress\n\n", pg_conf);

If it were desirable to also check that "things that look like GUCs in the conf
are actually GUCs", either of those would avoid false positives.

Or, is it okay to use ABS_SRCDIR?

+\getenv abs_srcdir PG_ABS_SRCDIR
+\set filename :abs_srcdir '../../../../src/backend/utils/misc/postgresql.conf.sample'
+-- test that GUCS are in postgresql.conf
+SELECT lower(name) FROM tab_settings_flags WHERE NOT not_in_sample EXCEPT
+SELECT regexp_replace(ln, '^#?([_[:alpha:]]+) (= .*|[^ ]*$)', '\1') AS guc
+FROM (SELECT regexp_split_to_table(pg_read_file(:'filename'), '\n') AS ln) conf
+WHERE ln ~ '^#?[[:alpha:]]'
+ORDER BY 1;
+
+-- test that lines in postgresql.conf that look like GUCs are GUCs
+SELECT regexp_replace(ln, '^#?([_[:alpha:]]+) (= .*|[^ ]*$)', '\1') AS guc
+FROM (SELECT regexp_split_to_table(pg_read_file(:'filename'), '\n') AS ln) conf
+WHERE ln ~ '^#?[[:alpha:]]'
+EXCEPT SELECT lower(name) FROM tab_settings_flags WHERE NOT not_in_sample
+ORDER BY 1;

-- 
Justin





view thread (26+ messages)  latest in thread

Message-ID: <20220211172929.GF31460@telsasoft.com>
Permalink:  ../20220211172929.GF31460@telsasoft.com/
Also on:    postgresql.org/message-id/20220211172929.GF31460@telsasoft.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: pryzby@telsasoft.com, tgl@sss.pgh.pa.us, myon@debian.org, michael@paquier.xyz, pgsql-hackers@lists.postgresql.org
  Subject: Re: pgsql: Add TAP test to automate the equivalent of check_guc
  In-Reply-To: <20220211172929.GF31460@telsasoft.com>
  References: <E1nHbaO-0000MF-RO@gemulon.postgresql.org> <YgYw25OXV5men8Fj@msg.df7cb.de> <2023925.1644591595@sss.pgh.pa.us> <20220211153549.GE31460@telsasoft.com> <2027230.1644594087@sss.pgh.pa.us> <20220211172929.GF31460@telsasoft.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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