Skip to content

Commit

Permalink
Wait 3 seconds for the server to reload trust (elastic#79778)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tvernum committed Oct 28, 2021
1 parent 8aa9549 commit 9938316
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.nio.file.StandardCopyOption;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

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

final LdapSession session = session(sessionFactory, user, userPass);
assertThat(session.userDn(), is("cn=Horatio Hornblower,ou=people,o=sevenSeas"));

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

0 comments on commit 9938316

Please sign in to comment.