aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-main
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2019-05-23 13:50:32 +0200
committerSonarTech <sonartech@sonarsource.com>2019-05-24 20:21:09 +0200
commitbcd1bf53c45459ec754270a0c6408e3d68144442 (patch)
tree7d9a684c61d601d78193fbf647cbb3a8be9448e9 /server/sonar-main
parent5340427e788552bdff13756721110bf7c41b91f0 (diff)
downloadsonarqube-bcd1bf53c45459ec754270a0c6408e3d68144442.tar.gz
sonarqube-bcd1bf53c45459ec754270a0c6408e3d68144442.zip
SONAR-11264 don't enforce ES bootstrap checks when connecting to H2
Diffstat (limited to 'server/sonar-main')
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/command/EsJvmOptions.java2
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/command/EsJvmOptionsTest.java33
2 files changed, 34 insertions, 1 deletions
diff --git a/server/sonar-main/src/main/java/org/sonar/application/command/EsJvmOptions.java b/server/sonar-main/src/main/java/org/sonar/application/command/EsJvmOptions.java
index 75dc84ef5b3..92272e5bd6c 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/command/EsJvmOptions.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/command/EsJvmOptions.java
@@ -126,7 +126,7 @@ public class EsJvmOptions extends JvmOptions<EsJvmOptions> {
res.put("-XX:UseAVX=", "2");
}
- if (!props.valueAsBoolean("sonar.es.bootstrap.checks.disable")) {
+ if (!props.value("sonar.jdbc.url", "").contains("jdbc:h2") && !props.valueAsBoolean("sonar.es.bootstrap.checks.disable")) {
res.put("-Des.enforce.bootstrap.checks=", "true");
}
diff --git a/server/sonar-main/src/test/java/org/sonar/application/command/EsJvmOptionsTest.java b/server/sonar-main/src/test/java/org/sonar/application/command/EsJvmOptionsTest.java
index 5c0d30e2987..f1a9b08552f 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/command/EsJvmOptionsTest.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/command/EsJvmOptionsTest.java
@@ -34,6 +34,7 @@ import org.sonar.process.Props;
import org.sonar.process.System2;
import org.sonar.test.ExceptionCauseMatcher;
+import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -87,6 +88,38 @@ public class EsJvmOptionsTest {
.doesNotContain("-Des.enforce.bootstrap.checks=true");
}
+ @Test
+ @UseDataProvider("java8or11")
+ public void constructor_forces_boostrap_checks_if_jdbc_url_property_does_not_exist(System2 system2) throws IOException {
+ File tmpDir = temporaryFolder.newFolder();
+ EsJvmOptions underTest = new EsJvmOptions(system2, new Props(properties), tmpDir);
+
+ assertThat(underTest.getAll())
+ .contains("-Des.enforce.bootstrap.checks=true");
+ }
+
+ @Test
+ @UseDataProvider("java8or11")
+ public void constructor_forces_boostrap_checks_if_jdbc_url_property_is_not_h2(System2 system2) throws IOException {
+ properties.put("sonar.jdbc.url", randomAlphanumeric(53));
+ File tmpDir = temporaryFolder.newFolder();
+ EsJvmOptions underTest = new EsJvmOptions(system2, new Props(properties), tmpDir);
+
+ assertThat(underTest.getAll())
+ .contains("-Des.enforce.bootstrap.checks=true");
+ }
+
+ @Test
+ @UseDataProvider("java8or11")
+ public void constructor_does_not_force_boostrap_checks_if_jdbc_url_property_contains_h2(System2 system2) throws IOException {
+ properties.put("sonar.jdbc.url", "jdbc:h2:tcp://ffoo:bar/sonar");
+ File tmpDir = temporaryFolder.newFolder();
+ EsJvmOptions underTest = new EsJvmOptions(system2, new Props(properties), tmpDir);
+
+ assertThat(underTest.getAll())
+ .doesNotContain("-Des.enforce.bootstrap.checks=true");
+ }
+
@DataProvider
public static Object[][] java8or11() {
System2 java8 = mock(System2.class);