Search in sources :

Example 36 with Props

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

the class EsSettingsTest method override_dirs.

@Test
public void override_dirs() throws Exception {
    File dataDir = temp.newFolder();
    File logDir = temp.newFolder();
    File tempDir = temp.newFolder();
    Props props = minProps();
    props.set(ProcessProperties.PATH_DATA, dataDir.getAbsolutePath());
    props.set(ProcessProperties.PATH_LOGS, logDir.getAbsolutePath());
    props.set(ProcessProperties.PATH_TEMP, tempDir.getAbsolutePath());
    Settings settings = new EsSettings(props).build();
    assertThat(settings.get("path.data")).isEqualTo(new File(dataDir, "es").getAbsolutePath());
    assertThat(settings.get("path.logs")).isEqualTo(logDir.getAbsolutePath());
    assertThat(settings.get("path.home")).isEqualTo(new File(tempDir, "es").getAbsolutePath());
}
Also used : Props(org.sonar.process.Props) File(java.io.File) Settings(org.elasticsearch.common.settings.Settings) Test(org.junit.Test)

Example 37 with Props

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

the class EsSettingsTest method enable_marvel.

@Test
public void enable_marvel() throws Exception {
    Props props = minProps();
    props.set(EsSettings.PROP_MARVEL_HOSTS, "127.0.0.2,127.0.0.3");
    Settings settings = new EsSettings(props).build();
    assertThat(settings.get("marvel.agent.exporter.es.hosts")).isEqualTo("127.0.0.2,127.0.0.3");
}
Also used : Props(org.sonar.process.Props) Settings(org.elasticsearch.common.settings.Settings) Test(org.junit.Test)

Example 38 with Props

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

the class EsSettingsTest method enable_http_connector_different_host.

@Test
public void enable_http_connector_different_host() throws Exception {
    Props props = minProps();
    props.set(ProcessProperties.SEARCH_HTTP_PORT, "9010");
    props.set(ProcessProperties.SEARCH_HOST, "127.0.0.2");
    Settings settings = new EsSettings(props).build();
    assertThat(settings.get("http.port")).isEqualTo("9010");
    assertThat(settings.get("http.host")).isEqualTo("127.0.0.2");
    assertThat(settings.get("http.enabled")).isEqualTo("true");
}
Also used : Props(org.sonar.process.Props) Settings(org.elasticsearch.common.settings.Settings) Test(org.junit.Test)

Example 39 with Props

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

the class SearchServerTest method start_stop_server.

@Test
public void start_stop_server() throws Exception {
    Props props = new Props(new Properties());
    // the following properties have always default values (see ProcessProperties)
    InetAddress host = InetAddress.getLoopbackAddress();
    props.set(ProcessProperties.SEARCH_HOST, host.getHostAddress());
    props.set(ProcessProperties.SEARCH_PORT, String.valueOf(port));
    props.set(ProcessProperties.CLUSTER_NAME, A_CLUSTER_NAME);
    props.set(EsSettings.CLUSTER_SEARCH_NODE_NAME, A_NODE_NAME);
    props.set(ProcessProperties.PATH_HOME, temp.newFolder().getAbsolutePath());
    props.set(ProcessEntryPoint.PROPERTY_SHARED_PATH, temp.newFolder().getAbsolutePath());
    underTest = new SearchServer(props);
    underTest.start();
    assertThat(underTest.getStatus()).isEqualTo(Monitored.Status.OPERATIONAL);
    Settings settings = Settings.builder().put("cluster.name", A_CLUSTER_NAME).build();
    client = TransportClient.builder().settings(settings).build().addTransportAddress(new InetSocketTransportAddress(host, port));
    assertThat(client.admin().cluster().prepareClusterStats().get().getStatus()).isEqualTo(ClusterHealthStatus.GREEN);
    underTest.stop();
    underTest.awaitStop();
    underTest = null;
    try {
        client.admin().cluster().prepareClusterStats().get();
        fail();
    } catch (NoNodeAvailableException exception) {
    // ok
    }
}
Also used : Props(org.sonar.process.Props) Properties(java.util.Properties) ProcessProperties(org.sonar.process.ProcessProperties) NoNodeAvailableException(org.elasticsearch.client.transport.NoNodeAvailableException) InetAddress(java.net.InetAddress) InetSocketTransportAddress(org.elasticsearch.common.transport.InetSocketTransportAddress) Settings(org.elasticsearch.common.settings.Settings) Test(org.junit.Test)

Aggregations

Props (org.sonar.process.Props)39 Test (org.junit.Test)32 Properties (java.util.Properties)20 File (java.io.File)11 ProcessProperties (org.sonar.process.ProcessProperties)9 Settings (org.elasticsearch.common.settings.Settings)7 InetAddress (java.net.InetAddress)3 Connector (org.apache.catalina.connector.Connector)3 ArgumentMatcher (org.mockito.ArgumentMatcher)3 ProcessEntryPoint (org.sonar.process.ProcessEntryPoint)3 ConnectException (java.net.ConnectException)1 URL (java.net.URL)1 Date (java.util.Date)1 StandardContext (org.apache.catalina.core.StandardContext)1 Tomcat (org.apache.catalina.startup.Tomcat)1 NoNodeAvailableException (org.elasticsearch.client.transport.NoNodeAvailableException)1 InetSocketTransportAddress (org.elasticsearch.common.transport.InetSocketTransportAddress)1 Matchers.anyString (org.mockito.Matchers.anyString)1 MutablePicoContainer (org.picocontainer.MutablePicoContainer)1 CoreProperties (org.sonar.api.CoreProperties)1