From 206799662c7bbfa5633c54bfc7298afa4f06d1e8 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Thu, 10 Apr 2014 10:49:32 +0200 Subject: [PATCH] [TEST] Allow higher ClusterHealthTimeout on tests if configuration is slow --- .../search/basic/SearchWhileRelocatingTests.java | 6 ++++-- .../test/hamcrest/ElasticsearchAssertions.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingTests.java b/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingTests.java index 173e2802ff8..dddd3efa5c3 100644 --- a/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingTests.java +++ b/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingTests.java @@ -38,6 +38,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; @@ -129,12 +130,13 @@ public class SearchWhileRelocatingTests extends ElasticsearchIntegrationTest { } allowNodes("test", between(1, 3)); client().admin().cluster().prepareReroute().get(); - ClusterHealthResponse resp = client().admin().cluster().prepareHealth().setWaitForRelocatingShards(0).execute().actionGet(); + // this might time out on some machines if they are really busy and you hit lots of throttling + ClusterHealthResponse resp = client().admin().cluster().prepareHealth().setWaitForRelocatingShards(0).setTimeout("5m").get(); stop.set(true); for (int j = 0; j < threads.length; j++) { threads[j].join(); } - assertThat(resp.isTimedOut(), equalTo(false)); + assertNoTimeout(resp); if (!thrownExceptions.isEmpty() || !nonCriticalExceptions.isEmpty()) { Client client = client(); boolean postSearchOK = true; diff --git a/src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java b/src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java index 054f6c3da7c..2bf52575104 100644 --- a/src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java +++ b/src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java @@ -81,7 +81,7 @@ public class ElasticsearchAssertions { } public static void assertNoTimeout(ClusterHealthResponse response) { - assertThat("ClusterHealthResponse has timed out", response.isTimedOut(), is(false)); + assertThat("ClusterHealthResponse has timed out - returned status: [" + response.getStatus() + "]", response.isTimedOut(), is(false)); } public static void assertAcked(AcknowledgedResponse response) {