[TEST] Allow higher ClusterHealthTimeout on tests if configuration is slow

This commit is contained in:
Simon Willnauer 2014-04-10 10:49:32 +02:00
parent bceac036af
commit 206799662c
2 changed files with 5 additions and 3 deletions

View File

@ -38,6 +38,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; 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.equalTo;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
@ -129,12 +130,13 @@ public class SearchWhileRelocatingTests extends ElasticsearchIntegrationTest {
} }
allowNodes("test", between(1, 3)); allowNodes("test", between(1, 3));
client().admin().cluster().prepareReroute().get(); 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); stop.set(true);
for (int j = 0; j < threads.length; j++) { for (int j = 0; j < threads.length; j++) {
threads[j].join(); threads[j].join();
} }
assertThat(resp.isTimedOut(), equalTo(false)); assertNoTimeout(resp);
if (!thrownExceptions.isEmpty() || !nonCriticalExceptions.isEmpty()) { if (!thrownExceptions.isEmpty() || !nonCriticalExceptions.isEmpty()) {
Client client = client(); Client client = client();
boolean postSearchOK = true; boolean postSearchOK = true;

View File

@ -81,7 +81,7 @@ public class ElasticsearchAssertions {
} }
public static void assertNoTimeout(ClusterHealthResponse response) { 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) { public static void assertAcked(AcknowledgedResponse response) {