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)
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")
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);
.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");
}
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);
.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