Test: allow setting socket timeout for rest client (#25221)

In #25201, a setting was added to allow setting the retry timeout for the rest client under the
impression that this would allow requests to go longer than 30s. However, there is also a socket
timeout that needs to be set to greater than 30s, which this change adds a setting for.
This commit is contained in:
Jay Modi 2017-06-14 08:21:56 -06:00 committed by GitHub
parent a0fcfc732d
commit ed76b9a518
2 changed files with 7 additions and 0 deletions

View File

@ -55,6 +55,7 @@ public class UpgradeClusterClientYamlTestSuiteIT extends ESClientYamlSuiteTestCa
// increase the timeout so that we can actually see the result of failed cluster health
// calls that have a default timeout of 30s
.put(ESRestTestCase.CLIENT_RETRY_TIMEOUT, "40s")
.put(ESRestTestCase.CLIENT_SOCKET_TIMEOUT, "40s")
.build();
}
}

View File

@ -69,6 +69,7 @@ public abstract class ESRestTestCase extends ESTestCase {
public static final String TRUSTSTORE_PATH = "truststore.path";
public static final String TRUSTSTORE_PASSWORD = "truststore.password";
public static final String CLIENT_RETRY_TIMEOUT = "client.retry.timeout";
public static final String CLIENT_SOCKET_TIMEOUT = "client.socket.timeout";
/**
* Convert the entity from a {@link Response} into a map of maps.
@ -346,6 +347,11 @@ public abstract class ESRestTestCase extends ESTestCase {
final TimeValue maxRetryTimeout = TimeValue.parseTimeValue(requestTimeoutString, CLIENT_RETRY_TIMEOUT);
builder.setMaxRetryTimeoutMillis(Math.toIntExact(maxRetryTimeout.getMillis()));
}
final String socketTimeoutString = settings.get(CLIENT_SOCKET_TIMEOUT);
if (socketTimeoutString != null) {
final TimeValue socketTimeout = TimeValue.parseTimeValue(socketTimeoutString, CLIENT_SOCKET_TIMEOUT);
builder.setRequestConfigCallback(conf -> conf.setSocketTimeout(Math.toIntExact(socketTimeout.getMillis())));
}
return builder.build();
}