pgsql: libpq: Fix some issues in TAP tests for service files

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: libpq: Fix some issues in TAP tests for service files
Date: 2025-04-07 03:57:59
Message-ID: E1u1dcV-0033pR-17@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

libpq: Fix some issues in TAP tests for service files

The valid service file was not correctly shaped, as append_to_file() was
called with an array as input. This is changed so as the parameter and
value pairs from the valid connection string are appended to the valid
service file one by one.

Even with the first issue fixed, the tests should fail. However, they
have been passing because all the connection attempts relied on the
default values given to PGPORT and PGHOST from the node when using
Cluster.pm's connect_ok() and connect_fails(), rather than the data in
the service file. The test is updated to use an interesting trick: a
dummy node is initialized but not started, and all the connection
attempts are done through it. This ensures that the data inside the
service file is used for all the connection tests. Note that breaking
the contents of the valid service file on purpose makes all the tests
that rely on it fail.

Issues introduced by 72c2f36d5727.

Author: Andrew Jackson <andrewjackson947(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAKK5BkG_6_YSaebM6gG=8EuKaY7_VX1RFgYeySuwFPh8FZY73g@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2c7bd2ba507e273f2d7fe1b2f6d30775ed4f3c09

Modified Files
--------------
src/interfaces/libpq/t/006_service.pl | 38 ++++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 14 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2025-04-07 06:46:48 pgsql: Fix grammar in log message of pg_restore.c
Previous Message Michael Paquier 2025-04-07 01:16:03 pgsql: Clarify comment for worst-case allocation in quote_literal_cstr(