Skip to content

Commit aba4e21

Browse files
authored
Extend HTTP timeout in repo analysis tests (#132193)
We set a 120s timeout on the repo analysis that runs in these tests, but the REST client in use has a read timeout of 60s so any analysis that lasts longer than that will yield an HTTP timeout that contains very limited information to help further investigation. With this commit we extend the HTTP timeout to be a few seconds longer than the analysis timeout so we should get a proper response in these cases. Backport of #131744 to 8.18
1 parent 3a285cf commit aba4e21

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

x-pack/plugin/snapshot-repo-test-kit/src/test/java/org/elasticsearch/repositories/blobstore/testkit/analyze/AbstractRepositoryAnalysisRestTestCase.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77

88
package org.elasticsearch.repositories.blobstore.testkit.analyze;
99

10+
import org.apache.http.client.config.RequestConfig;
1011
import org.apache.http.client.methods.HttpPost;
1112
import org.elasticsearch.client.Request;
13+
import org.elasticsearch.client.RequestOptions;
1214
import org.elasticsearch.common.settings.Settings;
15+
import org.elasticsearch.core.TimeValue;
1316
import org.elasticsearch.test.rest.ESRestTestCase;
1417

1518
public abstract class AbstractRepositoryAnalysisRestTestCase extends ESRestTestCase {
@@ -26,12 +29,18 @@ public void testRepositoryAnalysis() throws Exception {
2629
logger.info("creating repository [{}] of type [{}]", repository, repositoryType);
2730
registerRepository(repository, repositoryType, true, repositorySettings);
2831

32+
final TimeValue timeout = TimeValue.timeValueSeconds(120);
2933
final Request request = new Request(HttpPost.METHOD_NAME, "/_snapshot/" + repository + "/_analyze");
3034
request.addParameter("blob_count", "10");
3135
request.addParameter("concurrency", "4");
3236
request.addParameter("max_blob_size", "1mb");
33-
request.addParameter("timeout", "120s");
37+
request.addParameter("timeout", timeout.getStringRep());
3438
request.addParameter("seed", Long.toString(randomLong()));
39+
request.setOptions(
40+
RequestOptions.DEFAULT.toBuilder()
41+
.setRequestConfig(RequestConfig.custom().setSocketTimeout(Math.toIntExact(timeout.millis() + 10_000)).build())
42+
);
43+
3544
assertOK(client().performRequest(request));
3645
}
3746

0 commit comments

Comments
 (0)