diff options
author | Jacek <jacek.poreda@sonarsource.com> | 2022-01-26 14:11:35 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-01-27 20:03:05 +0000 |
commit | acdf881491a008872631199e0ebc1f4f7964c441 (patch) | |
tree | 55c510e0f8f0352ba5974110233bfc49c391cc1b /server/sonar-main | |
parent | dca8354af94e9feb46ea2312857e000aaa232372 (diff) | |
download | sonarqube-acdf881491a008872631199e0ebc1f4f7964c441.tar.gz sonarqube-acdf881491a008872631199e0ebc1f4f7964c441.zip |
SONAR-13997 Allow to override 'sonar.es.bootstrap.checks.disable'
- default for jdbc other than H2 to check es bootstrap at startup
- default for H2 to not check es bootstrap at startup
Diffstat (limited to 'server/sonar-main')
-rw-r--r-- | server/sonar-main/src/main/java/org/sonar/application/command/EsJvmOptions.java | 3 | ||||
-rw-r--r-- | server/sonar-main/src/test/java/org/sonar/application/command/EsJvmOptionsTest.java | 52 |
2 files changed, 54 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 5bb7aaafd2e..b9f9e9d18d1 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 @@ -46,7 +46,8 @@ public class EsJvmOptions extends JvmOptions<EsJvmOptions> { 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"); } 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 fe9cc2b40ab..8d0abbe22aa 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 @@ -112,6 +112,58 @@ public class EsJvmOptionsTest { .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. */ |