LDAP & Kerberos test woes

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: LDAP & Kerberos test woes
Date: 2024-04-07 10:19:01
Message-ID: fb898a70-3a88-4629-88e9-f2375020061d@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

While refactoring the Kerberos test module in preparation for adding
libpq encryption negotiation tests [1], I noticed that if the test
script die()s during setup, the whole test is marked as SKIPped rather
than failed. The cleanup END section is missing this trick:

--- a/src/test/kerberos/t/001_auth.pl
+++ b/src/test/kerberos/t/001_auth.pl
@@ -203,7 +203,12 @@ system_or_bail $krb5kdc, '-P', $kdc_pidfile;

END
{
+ # take care not to change the script's exit value
+ my $exit_code = $?;
+
kill 'INT', `cat $kdc_pidfile` if defined($kdc_pidfile) && -f
$kdc_pidfile;
+
+ $? = $exit_code;
}

The PostgreSQL::Cluster module got that right, but this test and the
LdapServer module didn't get the memo.

After fixing that, the ldap tests started failing on my laptop:

[12:45:28.997](0.054s) # setting up LDAP server
# Checking port 59839
# Found port 59839
# Checking port 59840
# Found port 59840
# Running: /usr/sbin/slapd -f
/home/heikki/git-sandbox/postgresql/build/testrun/ldap/001_auth/data/ldap-001_auth_j_WZ/slapd.conf
-s0 -h ldap://localhost:59839 ldaps://localhost:59840
Can't exec "/usr/sbin/slapd": No such file or directory at
/home/heikki/git-sandbox/postgresql/src/test/perl/PostgreSQL/Test/Utils.pm
line 349.
[12:45:29.004](0.008s) Bail out! command "/usr/sbin/slapd -f
/home/heikki/git-sandbox/postgresql/build/testrun/ldap/001_auth/data/ldap-001_auth_j_WZ/slapd.conf
-s0 -h ldap://localhost:59839 ldaps://localhost:59840" exited with value 2

That's because I don't have 'slapd' installed. The test script it
supposed to check for that, and mark the test as SKIPped, but it's not
really doing that on Linux. Attached patch fixes that, and also makes
the error message a bit more precise, when the OpenLDAP installation is
not found.

There's a lot more we could do with that code that tries to find the
OpenLDAP installation. It should probably be a configure/meson test.
This patch is just the minimum to keep this working after fixing the END
block.

1st patch fixes the LDAP setup tests, and 2nd patch fixes the error
handling in the END blocks.

[1] https://commitfest.postgresql.org/47/4742/

--
Heikki Linnakangas
Neon (https://neon.tech)

Attachment Content-Type Size
0001-Improve-check-in-LDAP-test-to-find-the-OpenLDAP-inst.patch text/x-patch 5.6 KB
0002-Don-t-clobber-test-exit-code-at-cleanup.patch text/x-patch 1.4 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tender Wang 2024-04-07 10:33:30 Re: Can't find not null constraint, but \d+ shows that
Previous Message John Naylor 2024-04-07 10:05:36 Re: Add bump memory context type and use it for tuplesorts