From ed76b9a5187863d85e50306b8eaac8b9b9f385cb Mon Sep 17 00:00:00 2001 From: Jay Modi Date: Wed, 14 Jun 2017 08:21:56 -0600 Subject: [PATCH] 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. --- .../upgrades/UpgradeClusterClientYamlTestSuiteIT.java | 1 + .../java/org/elasticsearch/test/rest/ESRestTestCase.java | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/UpgradeClusterClientYamlTestSuiteIT.java b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/UpgradeClusterClientYamlTestSuiteIT.java index 2977e783cf6..6dfdbb987cc 100644 --- a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/UpgradeClusterClientYamlTestSuiteIT.java +++ b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/UpgradeClusterClientYamlTestSuiteIT.java @@ -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(); } } diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java index ce10c631506..0aed6fd137b 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java @@ -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(); }