Search in sources :

Example 76 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 77 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 78 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 79 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)

Example 80 with Props

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

the class WebServerProcessLoggingTest method check_level_of_jul.

@Test
public void check_level_of_jul() throws IOException {
    Props props = new Props(new Properties());
    File dir = temp.newFolder();
    props.set(PATH_LOGS.getKey(), dir.getAbsolutePath());
    props.set("sonar.log.level.web", "TRACE");
    LoggerContext ctx = underTest.configure(props);
    MemoryAppender memoryAppender = new MemoryAppender();
    memoryAppender.start();
    ctx.getLogger(ROOT_LOGGER_NAME).addAppender(memoryAppender);
    java.util.logging.Logger logger = java.util.logging.Logger.getLogger("com.ms.sqlserver.jdbc.DTV");
    logger.finest("Test");
    memoryAppender.stop();
    assertThat(memoryAppender.getLogs()).hasSize(1);
}
Also used : Props(org.sonar.process.Props) Properties(java.util.Properties) File(java.io.File) LoggerContext(ch.qos.logback.classic.LoggerContext) 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