fromJvmDotOptionsFile(tmpDir, res);
fromSystemJvmOptionsClass(tmpDir, res);
- if (!props.value("sonar.jdbc.url", "").contains("jdbc:h2") && !props.valueAsBoolean("sonar.es.bootstrap.checks.disable")) {
+ boolean defaultDisableBootstrapChecks = props.value("sonar.jdbc.url", "").contains("jdbc:h2");
+ if (!props.valueAsBoolean("sonar.es.bootstrap.checks.disable", defaultDisableBootstrapChecks)) {
res.put("-Des.enforce.bootstrap.checks=", "true");
}
.doesNotContain("-Des.enforce.bootstrap.checks=true");
}
+ @Test
+ public void boostrap_checks_can_be_set_true_if_h2() throws IOException {
+ properties.put("sonar.jdbc.url", "jdbc:h2:tcp://ffoo:bar/sonar");
+ properties.put("sonar.es.bootstrap.checks.disable", "true");
+
+ File tmpDir = temporaryFolder.newFolder();
+ EsJvmOptions underTest = new EsJvmOptions(new Props(properties), tmpDir);
+
+ assertThat(underTest.getAll())
+ .isNotEmpty()
+ .doesNotContain("-Des.enforce.bootstrap.checks=true");
+ }
+
+ @Test
+ public void boostrap_checks_can_be_set_false_if_h2() throws IOException {
+ properties.put("sonar.jdbc.url", "jdbc:h2:tcp://ffoo:bar/sonar");
+ properties.put("sonar.es.bootstrap.checks.disable", "false");
+
+ File tmpDir = temporaryFolder.newFolder();
+ EsJvmOptions underTest = new EsJvmOptions(new Props(properties), tmpDir);
+
+ assertThat(underTest.getAll())
+ .isNotEmpty()
+ .contains("-Des.enforce.bootstrap.checks=true");
+ }
+
+ @Test
+ public void boostrap_checks_can_be_set_true_if_jdbc_other_than_h2() throws IOException {
+ properties.put("sonar.jdbc.url", randomAlphanumeric(53));
+ properties.put("sonar.es.bootstrap.checks.disable", "true");
+
+ File tmpDir = temporaryFolder.newFolder();
+ EsJvmOptions underTest = new EsJvmOptions(new Props(properties), tmpDir);
+
+ assertThat(underTest.getAll())
+ .isNotEmpty()
+ .doesNotContain("-Des.enforce.bootstrap.checks=true");
+ }
+
+ @Test
+ public void boostrap_checks_can_be_set_false_if_jdbc_other_than_h2() throws IOException {
+ properties.put("sonar.jdbc.url", randomAlphanumeric(53));
+ properties.put("sonar.es.bootstrap.checks.disable", "false");
+
+ File tmpDir = temporaryFolder.newFolder();
+ EsJvmOptions underTest = new EsJvmOptions(new Props(properties), tmpDir);
+
+ assertThat(underTest.getAll())
+ .isNotEmpty()
+ .contains("-Des.enforce.bootstrap.checks=true");
+ }
+
/**
* This test may fail if SQ's test are not executed with target Java version 8.
*/
SEARCH_JAVA_ADDITIONAL_OPTS("sonar.search.javaAdditionalOpts", ""),
SEARCH_REPLICAS("sonar.search.replicas"),
SEARCH_INITIAL_STATE_TIMEOUT("sonar.search.initialStateTimeout"),
+ SONAR_ES_BOOTSTRAP_CHECKS_DISABLE("sonar.es.bootstrap.checks.disable"),
WEB_HOST("sonar.web.host"),
WEB_JAVA_OPTS("sonar.web.javaOpts", "-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError"),