aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2019-07-26 10:01:18 +1200
committerThomas Munro <tmunro@postgresql.org>2019-07-26 10:09:31 +1200
commit3964d3bce9ca1e45301f99800fc798768f7b57ac (patch)
tree1282b574648089a4bb194c1a6eaab4d2b6c3ab50
parentc4944a93eb526f3799a36f30d46d6e765108b2b4 (diff)
downloadpostgresql-3964d3bce9ca1e45301f99800fc798768f7b57ac.tar.gz
postgresql-3964d3bce9ca1e45301f99800fc798768f7b57ac.zip
Fix LDAP test instability.
After starting slapd, wait until it can accept a connection before beginning the real test work. This avoids occasional test failures. Back-patch to 11, where the LDAP tests arrived. Author: Thomas Munro Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/20190719033013.GI1859%40paquier.xyz
-rw-r--r--src/test/ldap/t/001_auth.pl16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/ldap/t/001_auth.pl b/src/test/ldap/t/001_auth.pl
index 6c02f2530b6..84a3300d964 100644
--- a/src/test/ldap/t/001_auth.pl
+++ b/src/test/ldap/t/001_auth.pl
@@ -120,6 +120,22 @@ END
append_to_file($ldap_pwfile, $ldap_rootpw);
chmod 0600, $ldap_pwfile or die;
+# wait until slapd accepts requests
+my $retries = 0;
+while (1)
+{
+ last
+ if (
+ system_log(
+ "ldapsearch", "-h", $ldap_server, "-p",
+ $ldap_port, "-s", "base", "-b",
+ $ldap_basedn, "-D", $ldap_rootdn, "-y",
+ $ldap_pwfile, "-n", "'objectclass=*'") == 0);
+ die "cannot connect to slapd" if ++$retries >= 300;
+ note "waiting for slapd to accept requests...";
+ Time::HiRes::usleep(1000000);
+}
+
$ENV{'LDAPURI'} = $ldap_url;
$ENV{'LDAPBINDDN'} = $ldap_rootdn;
$ENV{'LDAPCONF'} = $ldap_conf;