Search in sources :

Example 56 with Props

use of org.sonar.process.Props in project sonarqube by SonarSource.

the class EsInstallationTest method constructor_fails_with_IAE_if_temp_dir_property_is_not_defined.

@Test
public void constructor_fails_with_IAE_if_temp_dir_property_is_not_defined() throws IOException {
    Props props = new Props(new Properties());
    props.set(PATH_DATA.getKey(), temp.newFolder().getAbsolutePath());
    props.set(PATH_HOME.getKey(), temp.newFolder().getAbsolutePath());
    assertThatThrownBy(() -> new EsInstallation(props)).isInstanceOf(IllegalArgumentException.class).hasMessage("Property sonar.path.temp is not set");
}
Also used : Props(org.sonar.process.Props) Properties(java.util.Properties) Test(org.junit.Test)

Example 57 with Props

use of org.sonar.process.Props in project sonarqube by SonarSource.

the class EsInstallationTest method override_data_dir.

@Test
public void override_data_dir() throws Exception {
    File sqHomeDir = temp.newFolder();
    File tempDir = temp.newFolder();
    File dataDir = temp.newFolder();
    Props props = new Props(new Properties());
    props.set(PATH_HOME.getKey(), sqHomeDir.getAbsolutePath());
    props.set(PATH_TEMP.getKey(), tempDir.getAbsolutePath());
    props.set(PATH_LOGS.getKey(), temp.newFolder().getAbsolutePath());
    props.set(PATH_DATA.getKey(), dataDir.getAbsolutePath());
    EsInstallation underTest = new EsInstallation(props);
    assertThat(underTest.getDataDirectory()).isEqualTo(new File(dataDir, "es7"));
}
Also used : Props(org.sonar.process.Props) Properties(java.util.Properties) File(java.io.File) Test(org.junit.Test)

Example 58 with Props

use of org.sonar.process.Props in project sonarqube by SonarSource.

the class EsInstallationTest method getJvmOptions_is_in_es_conf_directory.

@Test
public void getJvmOptions_is_in_es_conf_directory() throws IOException {
    File tempDir = temp.newFolder();
    Props props = new Props(new Properties());
    props.set(PATH_DATA.getKey(), temp.newFolder().getAbsolutePath());
    props.set(PATH_HOME.getKey(), temp.newFolder().getAbsolutePath());
    props.set(PATH_TEMP.getKey(), tempDir.getAbsolutePath());
    props.set(PATH_LOGS.getKey(), temp.newFolder().getAbsolutePath());
    EsInstallation underTest = new EsInstallation(props);
    assertThat(underTest.getJvmOptions()).isEqualTo(new File(tempDir, "conf/es/jvm.options"));
}
Also used : Props(org.sonar.process.Props) Properties(java.util.Properties) File(java.io.File) Test(org.junit.Test)

Example 59 with Props

use of org.sonar.process.Props in project sonarqube by SonarSource.

the class EsInstallationTest method constructor_fails_with_IAE_if_sq_home_property_is_not_defined.

@Test
public void constructor_fails_with_IAE_if_sq_home_property_is_not_defined() {
    Props props = new Props(new Properties());
    assertThatThrownBy(() -> new EsInstallation(props)).isInstanceOf(IllegalArgumentException.class).hasMessage("Property sonar.path.home is not set");
}
Also used : Props(org.sonar.process.Props) Properties(java.util.Properties) Test(org.junit.Test)

Example 60 with Props

use of org.sonar.process.Props in project sonarqube by SonarSource.

the class EsInstallationTest method getOutdatedSearchDirectories_returns_all_previously_used_es_data_directory_names.

@Test
public void getOutdatedSearchDirectories_returns_all_previously_used_es_data_directory_names() throws IOException {
    File sqHomeDir = temp.newFolder();
    File logDir = temp.newFolder();
    Props props = new Props(new Properties());
    props.set(PATH_DATA.getKey(), temp.newFolder().getAbsolutePath());
    props.set(PATH_HOME.getKey(), sqHomeDir.getAbsolutePath());
    props.set(PATH_TEMP.getKey(), temp.newFolder().getAbsolutePath());
    props.set(PATH_LOGS.getKey(), logDir.getAbsolutePath());
    EsInstallation underTest = new EsInstallation(props);
    assertThat(underTest.getOutdatedSearchDirectories()).extracting(File::getName).containsExactlyInAnyOrder("es", "es5", "es6");
}
Also used : Props(org.sonar.process.Props) Properties(java.util.Properties) File(java.io.File) Test(org.junit.Test)

Aggregations

Props (org.sonar.process.Props)143 Test (org.junit.Test)119 Properties (java.util.Properties)71 File (java.io.File)44 MessageException (org.sonar.process.MessageException)21 ProcessProperties (org.sonar.process.ProcessProperties)19 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)13 Settings (org.elasticsearch.common.settings.Settings)7 NodeHealth (org.sonar.process.cluster.health.NodeHealth)6 InetAddress (java.net.InetAddress)5 LoggerContext (ch.qos.logback.classic.LoggerContext)4 Tomcat (org.apache.catalina.startup.Tomcat)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 Map (java.util.Map)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Assert.fail (org.junit.Assert.fail)3 ArgumentMatchers.argThat (org.mockito.ArgumentMatchers.argThat)3 Mockito (org.mockito.Mockito)3 Mockito.mock (org.mockito.Mockito.mock)3 Mockito.verify (org.mockito.Mockito.verify)3