Skip to content

Commit 0bb5323

Browse files
authored
Wait 3 seconds for the server to reload trust (#79778) (#79988)
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 1caa26d commit 0bb5323

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
@@ -38,6 +38,7 @@
3838
import java.nio.file.StandardCopyOption;
3939
import java.util.List;
4040
import java.util.concurrent.ExecutionException;
41+
import java.util.concurrent.TimeUnit;
4142

4243
import static org.hamcrest.Matchers.contains;
4344
import static org.hamcrest.Matchers.containsString;
@@ -294,10 +295,12 @@ public void testSslTrustIsReloaded() throws Exception {
294295
Files.copy(realCa, ldapCaPath, StandardCopyOption.REPLACE_EXISTING);
295296
resourceWatcher.notifyNow(ResourceWatcherService.Frequency.HIGH);
296297

297-
final LdapSession session = session(sessionFactory, user, userPass);
298-
assertThat(session.userDn(), is("cn=Horatio Hornblower,ou=people,o=sevenSeas"));
299-
300-
session.close();
298+
// Occasionally the reload doesn't take immediate effect so the next connection fails.
299+
assertBusy(() -> {
300+
final LdapSession session = session(sessionFactory, user, userPass);
301+
assertThat(session.userDn(), is("cn=Horatio Hornblower,ou=people,o=sevenSeas"));
302+
session.close();
303+
}, 3, TimeUnit.SECONDS);
301304
}
302305
}
303306
}

0 commit comments

Comments
 (0)