]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5408 - Process and ProcessWrapper working with temp properties files
authorStephane Gamard <stephane.gamard@searchbox.com>
Fri, 18 Jul 2014 13:52:07 +0000 (15:52 +0200)
committerStephane Gamard <stephane.gamard@searchbox.com>
Fri, 18 Jul 2014 13:52:17 +0000 (15:52 +0200)
server/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java
server/sonar-search/src/main/java/org/sonar/search/ElasticSearch.java
server/sonar-search/src/test/java/org/sonar/search/ElasticSearchTest.java
server/sonar-search/src/test/resources/search.properties [new file with mode: 0644]
sonar-start/src/main/java/org/sonar/start/StartServer.java

index 9e0495eafc3d81f31bf7aeccf6aac55c17b6c1d1..428d85d42fbcbcc54790637520432c56d5344a62 100644 (file)
@@ -173,6 +173,10 @@ public class ProcessWrapper extends Thread {
       for (Map.Entry<String, String> property : properties.entrySet()) {
         props.put(property.getKey(), property.getValue());
       }
+      props.put(Process.SONAR_HOME, workDir);
+      props.put(Process.NAME_PROPERTY, this.getName());
+      props.put(Process.PORT_PROPERTY, Integer.toString(port));
+
       OutputStream out = new FileOutputStream(propertyFile);
       props.store(out, "Temporary properties file for Process [" + getName() + "]");
       out.close();
index a98e9e3b27bb917e5270e9f5c4bf4ac23d1203de..625f1d4ce6208e0da354aa59e43c9e93cec3dbcf 100644 (file)
@@ -65,6 +65,7 @@ public class ElasticSearch extends Process {
         .get()
         .getStatus() != ClusterHealthStatus.RED);
     } catch (Exception e) {
+      //LOGGER.warn("ES is not ready yet.", e);
       return false;
     }
   }
@@ -119,11 +120,11 @@ public class ElasticSearch extends Process {
 
     node = NodeBuilder.nodeBuilder()
       .settings(esSettings)
-      .build();
+      .build().start();
 
-    while (!node.isClosed()) {
+    while (node != null && !node.isClosed()) {
       try {
-        Thread.sleep(1000);
+        Thread.sleep(100);
       } catch (InterruptedException e) {
         e.printStackTrace();
       }
index 28451883656c5548769257ecde506c87998de133..743b2bc427bd8b1974b9adf1fc46f1e09a73bd11 100644 (file)
@@ -126,13 +126,16 @@ public class ElasticSearchTest {
     }).start();
     assertThat(elasticSearch.isReady()).isFalse();
 
-    while (!elasticSearch.isReady()) {
+    int count = 0;
+    while (!elasticSearch.isReady() && count < 100) {
       try {
-        Thread.sleep(200);
+        Thread.sleep(500);
       } catch (InterruptedException e) {
         e.printStackTrace();
       }
+      count++;
     }
+    assertThat(count).isLessThan(100);
 
     Settings settings = ImmutableSettings.settingsBuilder()
       .put("cluster.name", "sonarqube")
diff --git a/server/sonar-search/src/test/resources/search.properties b/server/sonar-search/src/test/resources/search.properties
new file mode 100644 (file)
index 0000000..0284324
--- /dev/null
@@ -0,0 +1,8 @@
+#Temporary properties file for Process [ES]
+#Fri Jul 18 15:05:56 CEST 2014
+SONAR_HOME=/Volumes/data/sonar/sonarqube/sonar-start/target/sonarqube-4.5-SNAPSHOT/
+esHome=/Volumes/data/sonar/sonarqube/sonar-start/target/sonarqube-4.5-SNAPSHOT/.
+esDebug=true
+esPort=57013
+pName=ES
+#pPort=57011
index 2eff7ddce0c5518f94a94711976e4e4f137180d6..f363ba618639c52296d2011e0d7cb21674733c1c 100644 (file)
@@ -151,8 +151,8 @@ public final class StartServer {
 
   public static void main(String... args) throws InterruptedException, IOException, URISyntaxException {
 
-    //String home = System.getenv(SONAR_HOME);
-    String home = "/Volumes/data/sonar/sonarqube/sonar-start/target/sonarqube-4.5-SNAPSHOT";
+    String home = System.getenv(SONAR_HOME);
+    //String home = "/Volumes/data/sonar/sonarqube/sonar-start/target/sonarqube-4.5-SNAPSHOT";
 
     //Check if we have a SONAR_HOME
     if (StringUtils.isEmpty(home)) {