]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11792 fix path.conf to allow ES 6.6 runtime to boot
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 13 Feb 2019 14:16:46 +0000 (15:16 +0100)
committerSonarTech <sonartech@sonarsource.com>
Tue, 19 Mar 2019 19:21:24 +0000 (20:21 +0100)
server/sonar-main/src/main/java/org/sonar/application/command/CommandFactoryImpl.java
server/sonar-main/src/main/java/org/sonar/application/es/EsSettings.java
server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java
server/sonar-main/src/test/java/org/sonar/application/es/EsSettingsTest.java

index c1feaaf69473c898251a679ae316605c43957c43..e41f0f663182b40d259eb3fce8fc38db84f1f6be 100644 (file)
@@ -100,7 +100,7 @@ public class CommandFactoryImpl implements CommandFactory {
     EsInstallation esInstallation = createEsInstallation();
     return new EsScriptCommand(ProcessId.ELASTICSEARCH, esInstallation.getHomeDirectory())
       .setEsInstallation(esInstallation)
-      .addOption("-Epath.conf=" + esInstallation.getConfDirectory().getAbsolutePath())
+      .setEnvVariable("ES_PATH_CONF", esInstallation.getConfDirectory().getAbsolutePath())
       .setEnvVariable("ES_JVM_OPTIONS", esInstallation.getJvmOptions().getAbsolutePath())
       .setEnvVariable("JAVA_HOME", System.getProperties().getProperty("java.home"))
       .suppressEnvVariable(ENV_VAR_JAVA_TOOL_OPTIONS)
@@ -112,12 +112,12 @@ public class CommandFactoryImpl implements CommandFactory {
     return new JavaCommand<EsJvmOptions>(ProcessId.ELASTICSEARCH, esInstallation.getHomeDirectory())
       .setEsInstallation(esInstallation)
       .setReadsArgumentsFromFile(false)
-      .setArgument("path.conf", esInstallation.getConfDirectory().getAbsolutePath())
       .setJvmOptions(new EsJvmOptions()
         .addFromMandatoryProperty(props, SEARCH_JAVA_OPTS.getKey())
         .addFromMandatoryProperty(props, SEARCH_JAVA_ADDITIONAL_OPTS.getKey())
         .add("-Delasticsearch")
-        .add("-Des.path.home=" + esInstallation.getHomeDirectory()))
+        .add("-Des.path.home=" + esInstallation.getHomeDirectory().getAbsolutePath())
+        .add("-Des.path.conf=" + esInstallation.getConfDirectory().getAbsolutePath()))
       .setEnvVariable("ES_JVM_OPTIONS", esInstallation.getJvmOptions().getAbsolutePath())
       .setEnvVariable("JAVA_HOME", System.getProperties().getProperty("java.home"))
       .setClassName("org.elasticsearch.bootstrap.Elasticsearch")
index e908a7fa158da1fe6cec1c230240bc55779d5b11..8f68f21b6618b2f792827700ee55d4a49872a72f 100644 (file)
@@ -82,7 +82,6 @@ public class EsSettings {
 
   private void configureFileSystem(Map<String, String> builder) {
     builder.put("path.data", fileSystem.getDataDirectory().getAbsolutePath());
-    builder.put("path.conf", fileSystem.getConfDirectory().getAbsolutePath());
     builder.put("path.logs", fileSystem.getLogDirectory().getAbsolutePath());
   }
 
index eae7e231be64f0262b2e82597d706600bd2f7bbe..a18409ab1cda67f70ce2506c0e12b101c3779855 100644 (file)
@@ -127,10 +127,11 @@ public class CommandFactoryImplTest {
     Properties props = new Properties();
     props.setProperty("sonar.search.host", "localhost");
 
-    AbstractCommand esCommand = newFactory(props, system2).createEsCommand();
+    AbstractCommand command = newFactory(props, system2).createEsCommand();
+    assertThat(command).isInstanceOf(EsScriptCommand.class);
+    EsScriptCommand esCommand = (EsScriptCommand) command;
     EsInstallation esConfig = esCommand.getEsInstallation();
 
-    assertThat(esCommand).isInstanceOf(EsScriptCommand.class);
     assertThat(esConfig.getClusterName()).isEqualTo("sonarqube");
     assertThat(esConfig.getHost()).isNotEmpty();
     assertThat(esConfig.getPort()).isEqualTo(9001);
@@ -139,15 +140,15 @@ public class CommandFactoryImplTest {
       .contains("-XX:+UseConcMarkSweepGC", "-Dfile.encoding=UTF-8")
       // default settings
       .contains("-Xms512m", "-Xmx512m", "-XX:+HeapDumpOnOutOfMemoryError");
-    File esConfDir = new File(tempDir, "conf/es");
-    assertThat(esCommand.getEnvVariables())
-      .contains(entry("ES_JVM_OPTIONS", new File(esConfDir, "jvm.options").getAbsolutePath()))
-      .containsKey("JAVA_HOME");
     assertThat(esConfig.getEsYmlSettings()).isNotNull();
-
     assertThat(esConfig.getLog4j2Properties())
       .contains(entry("appender.file_es.fileName", new File(logsDir, "es.log").getAbsolutePath()));
 
+    File esConfDir = new File(tempDir, "conf/es");
+    assertThat(esCommand.getEnvVariables())
+      .contains(entry("ES_PATH_CONF", esConfDir.getAbsolutePath()))
+      .contains(entry("ES_JVM_OPTIONS", new File(esConfDir, "jvm.options").getAbsolutePath()))
+      .containsKey("JAVA_HOME");
     assertThat(esCommand.getSuppressedEnvVariables()).containsOnly("JAVA_TOOL_OPTIONS", "ES_JAVA_OPTS");
   }
 
@@ -160,10 +161,11 @@ public class CommandFactoryImplTest {
     Properties props = new Properties();
     props.setProperty("sonar.search.host", "localhost");
 
-    AbstractCommand esCommand = newFactory(props, system2).createEsCommand();
+    AbstractCommand command = newFactory(props, system2).createEsCommand();
+    assertThat(command).isInstanceOf(JavaCommand.class);
+    JavaCommand<?> esCommand = (JavaCommand<?>) command;
     EsInstallation esConfig = esCommand.getEsInstallation();
 
-    assertThat(esCommand).isInstanceOf(JavaCommand.class);
     assertThat(esConfig.getClusterName()).isEqualTo("sonarqube");
     assertThat(esConfig.getHost()).isNotEmpty();
     assertThat(esConfig.getPort()).isEqualTo(9001);
@@ -172,16 +174,23 @@ public class CommandFactoryImplTest {
       .contains("-XX:+UseConcMarkSweepGC", "-Dfile.encoding=UTF-8")
       // default settings
       .contains("-Xms512m", "-Xmx512m", "-XX:+HeapDumpOnOutOfMemoryError");
-    File esConfDir = new File(tempDir, "conf/es");
-    assertThat(esCommand.getEnvVariables())
-      .contains(entry("ES_JVM_OPTIONS", new File(esConfDir, "jvm.options").getAbsolutePath()))
-      .containsKey("JAVA_HOME");
     assertThat(esConfig.getEsYmlSettings()).isNotNull();
 
     assertThat(esConfig.getLog4j2Properties())
       .contains(entry("appender.file_es.fileName", new File(logsDir, "es.log").getAbsolutePath()));
 
+    File esConfDir = new File(tempDir, "conf/es");
+    assertThat(esCommand.getArguments()).isEmpty();
+    assertThat(esCommand.getEnvVariables())
+      .contains(entry("ES_JVM_OPTIONS", new File(esConfDir, "jvm.options").getAbsolutePath()))
+      .containsKey("JAVA_HOME");
     assertThat(esCommand.getSuppressedEnvVariables()).containsOnly("JAVA_TOOL_OPTIONS", "ES_JAVA_OPTS");
+
+    assertThat(esCommand.getJvmOptions().getAll())
+      .containsAll(esConfig.getEsJvmOptions().getAll())
+      .contains("-Delasticsearch")
+      .contains("-Des.path.home=" + new File(homeDir, "elasticsearch"))
+      .contains("-Des.path.conf=" + esConfDir.getAbsolutePath());
   }
 
   @Test
index 1fcd2e5f42eb3db384330cb7dd990c21e0d47502..8d4a0ab1afc0b7fff8c9e22675928e80f540d97e 100644 (file)
@@ -141,7 +141,7 @@ public class EsSettingsTest {
     assertThat(generated.get("path.data")).isNotNull();
     assertThat(generated.get("path.logs")).isNotNull();
     assertThat(generated.get("path.home")).isNull();
-    assertThat(generated.get("path.conf")).isNotNull();
+    assertThat(generated.get("path.conf")).isNull();
 
     // http is disabled for security reasons
     assertThat(generated.get("http.enabled")).isEqualTo("false");
@@ -226,7 +226,7 @@ public class EsSettingsTest {
     Map<String, String> generated = underTest.build();
     assertThat(generated.get("path.data")).isEqualTo(data.getPath());
     assertThat(generated.get("path.logs")).isEqualTo(log.getPath());
-    assertThat(generated.get("path.conf")).isEqualTo(conf.getPath());
+    assertThat(generated.get("path.conf")).isNull();
   }
 
   @Test