Skip to content

Commit

Permalink
[Test] Increase LDAP connection timeout (#87208) (#88119)
Browse files Browse the repository at this point in the history
Increased LDAP connection timeout to 10s to avoid test failures.

By default, LDAP and Active Directory's timeout was set to 5s.
This seems not to be enough when running integration tests on CI servers
that use Samba fixture.

Closes #86958
  • Loading branch information
slobodanadamovic committed Jun 28, 2022
1 parent 3b6c150 commit 56063db
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.ssl.SslConfiguration;
import org.elasticsearch.common.ssl.SslVerificationMode;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.TestEnvironment;
import org.elasticsearch.xpack.core.security.authc.ldap.support.SessionFactorySettings;
import org.elasticsearch.xpack.core.ssl.SSLService;
import org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils;

import java.nio.file.Path;

public class LdapTestUtils {

/**
* Timeout is set to 10 seconds in order to avoid timeouts of some test cases that use the Samba fixture.
*/
private static final TimeValue DEFAULT_LDAP_TIMEOUT = TimeValue.timeValueSeconds(10);

private LdapTestUtils() {
// Utility class
}
Expand All @@ -48,8 +53,8 @@ public static LDAPConnection openConnection(String url, String bindDN, String bi
LDAPConnectionOptions options = new LDAPConnectionOptions();
options.setFollowReferrals(true);
options.setAllowConcurrentSocketFactoryUse(true);
options.setConnectTimeoutMillis(Math.toIntExact(SessionFactorySettings.TIMEOUT_DEFAULT.millis()));
options.setResponseTimeoutMillis(SessionFactorySettings.TIMEOUT_DEFAULT.millis());
options.setConnectTimeoutMillis(Math.toIntExact(DEFAULT_LDAP_TIMEOUT.millis()));
options.setResponseTimeoutMillis(DEFAULT_LDAP_TIMEOUT.millis());

final SslConfiguration sslConfiguration = sslService.getSSLConfiguration("xpack.security.authc.realms.ldap.foo.ssl");
return LdapUtils.privilegedConnect(
Expand Down

0 comments on commit 56063db

Please sign in to comment.