Skip to content

Commit 9464c11

Browse files
committed
Wait 3 seconds for the server to reload trust (elastic#79778)
Sometimes the final session seems to fail because it is still using the old trust configuration. This commit adds an assertBusy to give it time to settle. Resolves: elastic#77024
1 parent 323bae7 commit 9464c11

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapSessionFactoryTests.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import java.security.GeneralSecurityException;
4242
import java.util.List;
4343
import java.util.concurrent.ExecutionException;
44+
import java.util.concurrent.TimeUnit;
4445

4546
import javax.net.ssl.SSLException;
4647

@@ -351,10 +352,12 @@ public void testSslTrustIsReloaded() throws Exception {
351352
Files.copy(realCa, ldapCaPath, StandardCopyOption.REPLACE_EXISTING);
352353
resourceWatcher.notifyNow(ResourceWatcherService.Frequency.HIGH);
353354

354-
final LdapSession session = session(sessionFactory, user, userPass);
355-
assertThat(session.userDn(), is("cn=Horatio Hornblower,ou=people,o=sevenSeas"));
356-
357-
session.close();
355+
// Occasionally the reload doesn't take immediate effect so the next connection fails.
356+
assertBusy(() -> {
357+
final LdapSession session = session(sessionFactory, user, userPass);
358+
assertThat(session.userDn(), is("cn=Horatio Hornblower,ou=people,o=sevenSeas"));
359+
session.close();
360+
}, 3, TimeUnit.SECONDS);
358361
}
359362
}
360363
}

0 commit comments

Comments
 (0)