Search in sources :

Example 86 with Props

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

the class EsSettingsTest method in_standalone_initialTimeout_is_not_overridable.

@Test
public void in_standalone_initialTimeout_is_not_overridable() throws Exception {
    Props props = minProps(CLUSTER_DISABLED);
    props.set(SEARCH_INITIAL_STATE_TIMEOUT.getKey(), "10s");
    Map<String, String> settings = new EsSettings(props, new EsInstallation(props), system).build();
    assertThat(settings).containsEntry("discovery.initial_state_timeout", "30s");
}
Also used : Props(org.sonar.process.Props) Test(org.junit.Test)

Example 87 with Props

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

the class EsSettingsTest method minimalProps.

private Props minimalProps() {
    Props props = new Props(new Properties());
    props.set(PATH_HOME.getKey(), randomAlphanumeric(12));
    props.set(PATH_DATA.getKey(), randomAlphanumeric(12));
    props.set(PATH_TEMP.getKey(), randomAlphanumeric(12));
    props.set(PATH_LOGS.getKey(), randomAlphanumeric(12));
    props.set(CLUSTER_NAME.getKey(), randomAlphanumeric(12));
    return props;
}
Also used : Props(org.sonar.process.Props) Properties(java.util.Properties) ProcessProperties(org.sonar.process.ProcessProperties)

Example 88 with Props

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

the class EsSettingsTest method test_default_settings_for_standalone_mode.

@Test
public void test_default_settings_for_standalone_mode() throws Exception {
    File homeDir = temp.newFolder();
    Props props = new Props(new Properties());
    props.set(SEARCH_PORT.getKey(), "1234");
    props.set(ES_PORT.getKey(), "5678");
    props.set(SEARCH_HOST.getKey(), "127.0.0.1");
    props.set(PATH_HOME.getKey(), homeDir.getAbsolutePath());
    props.set(PATH_DATA.getKey(), temp.newFolder().getAbsolutePath());
    props.set(PATH_TEMP.getKey(), temp.newFolder().getAbsolutePath());
    props.set(PATH_LOGS.getKey(), temp.newFolder().getAbsolutePath());
    props.set(CLUSTER_NAME.getKey(), "sonarqube");
    EsSettings esSettings = new EsSettings(props, new EsInstallation(props), system);
    Map<String, String> generated = esSettings.build();
    assertThat(generated).containsEntry("transport.port", "5678").containsEntry("transport.host", "127.0.0.1").containsEntry("http.port", "1234").containsEntry("http.host", "127.0.0.1").containsEntry("cluster.name", "sonarqube").containsEntry("node.name", "sonarqube").containsEntry("discovery.seed_hosts", "127.0.0.1").containsEntry("cluster.initial_master_nodes", "127.0.0.1");
    assertThat(generated.get("path.data")).isNotNull();
    assertThat(generated.get("path.logs")).isNotNull();
    assertThat(generated.get("path.home")).isNull();
    assertThat(generated.get("path.conf")).isNull();
    assertThat(generated).containsEntry("discovery.initial_state_timeout", "30s").containsEntry("action.auto_create_index", "false");
}
Also used : Props(org.sonar.process.Props) Properties(java.util.Properties) ProcessProperties(org.sonar.process.ProcessProperties) File(java.io.File) Test(org.junit.Test)

Example 89 with Props

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

the class ClusterSettingsLoopbackTest method ClusterSettings_throws_MessageException_if_es_transport_host_of_search_node_is_loopback.

@Test
public void ClusterSettings_throws_MessageException_if_es_transport_host_of_search_node_is_loopback() {
    TestAppSettings settings = newSettingsForSearchNode(ImmutableMap.of(CLUSTER_NODE_ES_HOST.getKey(), loopback.getHostAddress()));
    Props props = settings.getProps();
    ClusterSettings clusterSettings = new ClusterSettings(network);
    assertThatThrownBy(() -> clusterSettings.accept(props)).isInstanceOf(MessageException.class).hasMessage("Property " + CLUSTER_NODE_ES_HOST.getKey() + " must be a local non-loopback address: " + loopback.getHostAddress());
}
Also used : MessageException(org.sonar.process.MessageException) Props(org.sonar.process.Props) Test(org.junit.Test)

Example 90 with Props

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

the class ClusterSettingsLoopbackTest method ClusterSettings_throws_MessageException_if_host_of_app_node_is_loopback.

@Test
public void ClusterSettings_throws_MessageException_if_host_of_app_node_is_loopback() {
    TestAppSettings settings = newSettingsForAppNode(ImmutableMap.of(CLUSTER_NODE_HOST.getKey(), loopback.getHostAddress()));
    Props props = settings.getProps();
    ClusterSettings clusterSettings = new ClusterSettings(network);
    assertThatThrownBy(() -> clusterSettings.accept(props)).isInstanceOf(MessageException.class).hasMessage("Property " + CLUSTER_NODE_HOST.getKey() + " must be a local non-loopback address: " + loopback.getHostAddress());
}
Also used : MessageException(org.sonar.process.MessageException) Props(org.sonar.process.Props) 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