Browse Source

SONAR-11792 fix path.conf to allow ES 6.6 runtime to boot

tags/7.7
Sébastien Lesaint 5 years ago
parent
commit
fed8aa63af

+ 3
- 3
server/sonar-main/src/main/java/org/sonar/application/command/CommandFactoryImpl.java View 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")

+ 0
- 1
server/sonar-main/src/main/java/org/sonar/application/es/EsSettings.java View 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());
}


+ 22
- 13
server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java View 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

+ 2
- 2
server/sonar-main/src/test/java/org/sonar/application/es/EsSettingsTest.java View 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

Loading…
Cancel
Save