From 6962446f69eab08e83f120b98a315b1aef6c11ca Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 15 Dec 2014 21:59:49 +0100 Subject: Improve SearchServerTest to prepare upgrade to ES 1.4 --- .../src/test/java/org/sonar/search/SearchServerTest.java | 6 ++++-- server/sonar-server/src/main/java/org/sonar/server/es/EsClient.java | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/server/sonar-search/src/test/java/org/sonar/search/SearchServerTest.java b/server/sonar-search/src/test/java/org/sonar/search/SearchServerTest.java index f2be9704667..8a9823eccc6 100644 --- a/server/sonar-search/src/test/java/org/sonar/search/SearchServerTest.java +++ b/server/sonar-search/src/test/java/org/sonar/search/SearchServerTest.java @@ -40,6 +40,7 @@ import org.sonar.process.Props; import java.util.Properties; import static org.fest.assertions.Assertions.assertThat; +import static org.fest.assertions.Fail.fail; public class SearchServerTest { @@ -84,9 +85,10 @@ public class SearchServerTest { searchServer.awaitStop(); searchServer = null; try { - assertThat(client.admin().cluster().prepareClusterStats().get().getStatus()).isNotEqualTo(ClusterHealthStatus.GREEN); + client.admin().cluster().prepareClusterStats().get(); + fail(); } catch (NoNodeAvailableException exception) { - assertThat(exception.getMessage()).isEqualTo("No node available"); + // ok } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/EsClient.java b/server/sonar-server/src/main/java/org/sonar/server/es/EsClient.java index 1af8a7b0f37..2508fd64191 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/es/EsClient.java +++ b/server/sonar-server/src/main/java/org/sonar/server/es/EsClient.java @@ -48,8 +48,6 @@ import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.metrics.max.Max; import org.picocontainer.Startable; import org.sonar.core.profiling.Profiling; -import org.sonar.server.search.ClusterHealth; -import org.sonar.server.search.SearchClient; import org.sonar.server.es.request.ProxyBulkRequestBuilder; import org.sonar.server.es.request.ProxyClusterHealthRequestBuilder; import org.sonar.server.es.request.ProxyClusterStateRequestBuilder; @@ -69,6 +67,8 @@ import org.sonar.server.es.request.ProxyPutMappingRequestBuilder; import org.sonar.server.es.request.ProxyRefreshRequestBuilder; import org.sonar.server.es.request.ProxySearchRequestBuilder; import org.sonar.server.es.request.ProxySearchScrollRequestBuilder; +import org.sonar.server.search.ClusterHealth; +import org.sonar.server.search.SearchClient; /** * Facade to connect to Elasticsearch node. Handles correctly errors (logging + exceptions -- cgit v1.2.3