pgsql: Add TAP test to automate the equivalent of check_guc

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add TAP test to automate the equivalent of check_guc
Date: 2022-02-09 01:15:56
Message-ID: E1nHbaO-0000MF-RO@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Add TAP test to automate the equivalent of check_guc

src/backend/utils/misc/check_guc is a script that cross-checks the
consistency of the GUCs with postgresql.conf.sample, making sure that
its format is in line with what guc.c has. It has never been run
automatically, and has rotten over the years, creating a lot of false
positives as per a report from Justin Pryzby.

d10e41d has introduced a SQL function to publish the most relevant flags
associated to a GUC, with tests added in the main regression test suite
to make sure that we avoid most of the inconsistencies in the GUC
settings, based on recent reports, but there was nothing able to
cross-check postgresql.conf.sample with the contents of guc.c.

This commit adds a TAP test that covers the remaining gap. It emulates
the most relevant checks that check_guc does, so as any format mistakes
are detected in postgresql.conf.sample at development stage, with the
following checks:
- Check that parameters marked as NOT_IN_SAMPLE are not in the sample
file.
- Check that there are no dead entries in postgresql.conf.sample for
parameters not marked as NOT_IN_SAMPLE.
- Check that no parameters are missing from the sample file if listed in
guc.c without NOT_IN_SAMPLE.

The idea of building a list of the GUCs by parsing the sample file comes
from Justin, and he wrote the regex used in the patch to find all the
GUCs (this same formatting rule basically applies for the last 20~ years
or so). In order to test this patch, I have played with manual
modifications of postgresql.conf.sample and guc.c, making sure that we
detect problems with the GUC rules and the sample file format.

The test is located in src/test/modules/test_misc, which is the best
location I could think about for such sanity checks.

Reviewed-by: Justin Pryzby
Discussion: https://postgr.es/m/Yf9YGSwPiMu0c7fP@paquier.xyz

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b0a55f4d4ad58e4bc152f8c1696b4af46525e3f1

Modified Files
--------------
src/test/modules/test_misc/t/003_check_guc.pl | 108 ++++++++++++++++++++++++++
1 file changed, 108 insertions(+)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2022-02-09 01:23:06 Re: pgsql: Avoid race in RelationBuildDesc() affecting CREATE INDEX CONCURR
Previous Message Andres Freund 2022-02-09 00:43:47 Re: pgsql: Avoid race in RelationBuildDesc() affecting CREATE INDEX CONCURR

Browse pgsql-hackers by date

  From Date Subject
Next Message tanghy.fnst@fujitsu.com 2022-02-09 01:18:24 RE: [BUG]Update Toast data failure in logical replication
Previous Message Jacob Champion 2022-02-09 00:52:48 Re: [PATCH] Accept IP addresses in server certificate SANs