]> source.dussan.org Git - sonarqube.git/commitdiff
End of CI error investigations - creation of ES indices was not synchronous, so faile...
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Sat, 29 Nov 2014 11:41:39 +0000 (12:41 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Sat, 29 Nov 2014 11:41:39 +0000 (12:41 +0100)
12 files changed:
server/sonar-server/pom.xml
server/sonar-server/src/main/java/org/sonar/server/es/EsClient.java
server/sonar-server/src/main/java/org/sonar/server/es/IndexCreator.java
server/sonar-server/src/test/java/org/sonar/server/es/BulkIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/es/EsClientTest.java
server/sonar-server/src/test/java/org/sonar/server/es/EsTester.java
server/sonar-server/src/test/java/org/sonar/server/es/IndexCreatorTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueAuthorizationIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/source/index/SourceLineIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/source/index/SourceLineIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/tester/ServerTester.java

index e56b41df18318b798a6c2f4bed443865dad86172..f928fe087180ce076cbbaea38b310675a236bd34 100644 (file)
@@ -9,11 +9,10 @@
     <relativePath>..</relativePath>
   </parent>
   <artifactId>sonar-server</artifactId>
-  <packaging>jar</packaging>
   <name>SonarQube :: Server</name>
 
   <properties>
-    <argLine>-Xmx1G -Djava.awt.headless=true -XX:MaxPermSize=128m</argLine>
+    <argLine>-Xmx512m -Djava.awt.headless=true -XX:MaxPermSize=128m</argLine>
   </properties>
 
   <dependencies>
index ff73df80f91e3c03e72143e4d4d0aff0caabca23..2e737b8c4bea9ac5da753a15b8d5ccb1632679cd 100644 (file)
@@ -41,6 +41,7 @@ import org.elasticsearch.action.index.IndexRequestBuilder;
 import org.elasticsearch.action.search.SearchRequestBuilder;
 import org.elasticsearch.action.search.SearchScrollRequestBuilder;
 import org.elasticsearch.client.Client;
+import org.elasticsearch.common.Priority;
 import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.search.aggregations.AggregationBuilders;
 import org.elasticsearch.search.aggregations.metrics.max.Max;
@@ -100,7 +101,6 @@ public class EsClient implements Startable {
     return health;
   }
 
-
   public RefreshRequestBuilder prepareRefresh(String... indices) {
     return new ProxyRefreshRequestBuilder(client, profiling).setIndices(indices);
   }
@@ -129,6 +129,10 @@ public class EsClient implements Startable {
     return new ProxyClusterHealthRequestBuilder(client, profiling).setIndices(indices);
   }
 
+  public void waitForStatus(ClusterHealthStatus status) {
+    prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForStatus(status).get();
+  }
+
   public IndicesExistsRequestBuilder prepareExists(String... indices) {
     return new ProxyIndicesExistsRequestBuilder(client, profiling, indices);
   }
@@ -200,7 +204,7 @@ public class EsClient implements Startable {
   @Override
   public void stop() {
     // TODO re-enable when SearchClient is dropped
-    //client.close();
+    // client.close();
   }
 
   protected Client nativeClient() {
index 6f9a01c63f3842f51b12c039441c358307cb0be7..2d3a8f7c2559dddfd0a752329090ddd940d9bd4a 100644 (file)
@@ -20,9 +20,9 @@
 package org.sonar.server.es;
 
 import org.apache.commons.lang.StringUtils;
+import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
 import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
 import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
-import org.elasticsearch.common.Priority;
 import org.elasticsearch.common.settings.ImmutableSettings;
 import org.picocontainer.Startable;
 import org.slf4j.Logger;
@@ -85,7 +85,7 @@ public class IndexCreator implements ServerComponent, Startable {
     if (!indexResponse.isAcknowledged()) {
       throw new IllegalStateException("Failed to create index " + index.getName());
     }
-    client.prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
+    client.waitForStatus(ClusterHealthStatus.YELLOW);
 
     // create types
     for (Map.Entry<String, IndexRegistry.IndexType> entry : index.getTypes().entrySet()) {
@@ -99,6 +99,7 @@ public class IndexCreator implements ServerComponent, Startable {
         throw new IllegalStateException("Failed to create type " + entry.getKey());
       }
     }
+    client.waitForStatus(ClusterHealthStatus.YELLOW);
   }
 
   private void deleteIndex(String indexName) {
index 1699c62b231b0fef1386507e3d2de84ddb476ef4..0d855cdfe7018031791ca08e8f67adaf86c0007f 100644 (file)
@@ -25,13 +25,11 @@ import org.elasticsearch.action.index.IndexRequest;
 import org.elasticsearch.cluster.metadata.IndexMetaData;
 import org.elasticsearch.common.unit.ByteSizeUnit;
 import org.elasticsearch.common.unit.ByteSizeValue;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 
 import static org.fest.assertions.Assertions.assertThat;
 
-@Ignore
 public class BulkIndexerTest {
 
   @Rule
index aafd7c14985a30c4a750d49c7cbaeb3eefe055ba..66b91c01ede77b6a211d92f9612ec77899b13c80 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.es;
 
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.server.search.request.ProxyBulkRequestBuilder;
@@ -43,7 +42,6 @@ import org.sonar.server.search.request.ProxySearchScrollRequestBuilder;
 
 import static org.fest.assertions.Assertions.assertThat;
 
-@Ignore
 public class EsClientTest {
 
   @Rule
index 087fc619ee9ed18f3611f2df3cc5f7f1ec6fced8..ad08d619827cc6ea80dacb32c70aa54b8d81ce3f 100644 (file)
@@ -41,7 +41,6 @@ import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.node.Node;
 import org.elasticsearch.node.NodeBuilder;
 import org.elasticsearch.search.SearchHit;
-import org.junit.Ignore;
 import org.junit.rules.ExternalResource;
 import org.sonar.api.config.Settings;
 import org.sonar.api.platform.ComponentContainer;
@@ -55,7 +54,6 @@ import java.util.List;
 
 import static org.fest.assertions.Assertions.assertThat;
 
-@Ignore
 public class EsTester extends ExternalResource {
 
   private static final int INSTANCE_ID = RandomUtils.nextInt();
@@ -69,7 +67,7 @@ public class EsTester extends ExternalResource {
   }
 
   protected void before() throws Throwable {
-    String nodeName = "es-ram-" + INSTANCE_ID;
+    String nodeName = "tmp-es-" + INSTANCE_ID;
     node = NodeBuilder.nodeBuilder().local(true).data(true).settings(ImmutableSettings.builder()
       .put("cluster.name", nodeName)
       .put("node.name", nodeName)
index 933db29182474c84bcedc3a28a7d78f9cb94afaa..8f46e89cc6b79d56a260f34befa67d4c7294d3c7 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.server.es;
 import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
 import org.elasticsearch.cluster.metadata.MappingMetaData;
 import org.elasticsearch.common.collect.ImmutableOpenMap;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 
@@ -33,7 +32,6 @@ import java.util.Map;
 
 import static org.fest.assertions.Assertions.assertThat;
 
-@Ignore
 public class IndexCreatorTest {
 
   @Rule
index 38099b022b72553544a0308f4da141b28cb887f7..a0ea5860886fd088de31071177f5be6c21ae1a6a 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.server.issue.index;
 
 import org.elasticsearch.search.SearchHit;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.config.Settings;
@@ -34,7 +33,6 @@ import java.util.List;
 
 import static org.fest.assertions.Assertions.assertThat;
 
-@Ignore
 public class IssueAuthorizationIndexerTest {
 
   @Rule
index 5a283363fce23ef582323b7952c341a493883294..70544f861e218ac07f70b51e450ec370526c97de 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.server.issue.index;
 
 import com.google.common.collect.Iterators;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.config.Settings;
@@ -33,7 +32,6 @@ import java.util.List;
 
 import static org.fest.assertions.Assertions.assertThat;
 
-@Ignore
 public class IssueIndexerTest {
 
   @Rule
index eabe084163f2986a9991a172cbf458ebbbd5e8de..ced283fc0bbce91febaa324095014b87c1b7b03d 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.server.source.index;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.config.Settings;
@@ -28,7 +27,6 @@ import org.sonar.server.es.EsTester;
 
 import static org.fest.assertions.Assertions.assertThat;
 
-@Ignore
 public class SourceLineIndexTest {
 
   @Rule
index 35c5e804525cfbaa3a520c291ae995fedaa9507d..b4c16ec448c3a772462beca1d1a606daf5b9d839 100644 (file)
@@ -26,7 +26,6 @@ import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.index.query.QueryBuilders;
 import org.fest.assertions.MapAssert;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.config.Settings;
@@ -43,7 +42,6 @@ import java.util.Map;
 
 import static org.fest.assertions.Assertions.assertThat;
 
-@Ignore
 public class SourceLineIndexerTest {
 
   @Rule
index c8552358fd1dffecf02851a373b4d5d305709113..d2c4cab058f91ebd1dd2ab44972ced01c6726ed6 100644 (file)
@@ -120,7 +120,6 @@ public class ServerTester extends ExternalResource {
       platform.addComponents(components);
       platform.doStart();
     } catch (Exception e) {
-      LOG.error("Fail to start ServerTester", e);
       stop();
       Throwables.propagate(e);
     }