Thread

Commits

  1. Don't clobber test exit code at cleanup in LDAP/Kerberors tests

  2. Improve check in LDAP test to find the OpenLDAP installation

  1. LDAP & Kerberos test woes

    Heikki Linnakangas <hlinnaka@iki.fi> — 2024-04-07T10:19:01Z

    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)
  2. Re: LDAP & Kerberos test woes

    Heikki Linnakangas <hlinnaka@iki.fi> — 2024-04-07T17:32:27Z

    On 07/04/2024 13:19, Heikki Linnakangas wrote:
    > 1st patch fixes the LDAP setup tests, and 2nd patch fixes the error
    > handling in the END blocks.
    
    Committed and backpatched these test fixes.
    
    -- 
    Heikki Linnakangas
    Neon (https://neon.tech)