Skip to content

Commit e2be62e

Browse files
authored
Wait 3 seconds for the server to reload trust (#79778) (#79989)
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: #77024
1 parent ecc6200 commit e2be62e

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
@@ -39,6 +39,7 @@
3939
import java.nio.file.StandardCopyOption;
4040
import java.util.List;
4141
import java.util.concurrent.ExecutionException;
42+
import java.util.concurrent.TimeUnit;
4243

4344
import static org.hamcrest.Matchers.contains;
4445
import static org.hamcrest.Matchers.containsString;
@@ -335,10 +336,12 @@ public void testSslTrustIsReloaded() throws Exception {
335336
Files.copy(realCa, ldapCaPath, StandardCopyOption.REPLACE_EXISTING);
336337
resourceWatcher.notifyNow(ResourceWatcherService.Frequency.HIGH);
337338

338-
final LdapSession session = session(sessionFactory, user, userPass);
339-
assertThat(session.userDn(), is("cn=Horatio Hornblower,ou=people,o=sevenSeas"));
340-
341-
session.close();
339+
// Occasionally the reload doesn't take immediate effect so the next connection fails.
340+
assertBusy(() -> {
341+
final LdapSession session = session(sessionFactory, user, userPass);
342+
assertThat(session.userDn(), is("cn=Horatio Hornblower,ou=people,o=sevenSeas"));
343+
session.close();
344+
}, 3, TimeUnit.SECONDS);
342345
}
343346
}
344347
}

0 commit comments

Comments
 (0)