Search in sources :

Example 46 with Props

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

the class ClusterSettingsTest method verifyAnyHostsConfigurationIsValid.

private void verifyAnyHostsConfigurationIsValid(String searchPropertyValue) {
    TestAppSettings settings = new TestAppSettings(ImmutableMap.<String, String>builder().put(CLUSTER_ENABLED.getKey(), "true").put(CLUSTER_NODE_TYPE.getKey(), "search").put(CLUSTER_NODE_SEARCH_HOST.getKey(), "search_host").put(CLUSTER_ES_HOSTS.getKey(), "transport_host,transport_host").put(CLUSTER_NODE_ES_HOST.getKey(), "transport_host").put(CLUSTER_SEARCH_HOSTS.getKey(), searchPropertyValue).build());
    ClusterSettings clusterSettings = new ClusterSettings(network);
    Props props = settings.getProps();
    assertThatCode(() -> clusterSettings.accept(props)).doesNotThrowAnyException();
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Props(org.sonar.process.Props)

Example 47 with Props

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

the class ClusterSettingsTest method verifyLoopbackChecked.

private void verifyLoopbackChecked(TestAppSettings settings, Collection<String> hosts, String expectedMessage) {
    reset(network);
    mockAllHostsValid();
    mockLocalNonLoopback("hz_host", "search_host", "transport_host");
    // will overwrite above move if necessary
    hosts.forEach(this::mockLoopback);
    ClusterSettings clusterSettings = new ClusterSettings(network);
    Props props = settings.getProps();
    assertThatThrownBy(() -> clusterSettings.accept(props)).isInstanceOf(MessageException.class).hasMessage(expectedMessage);
}
Also used : MessageException(org.sonar.process.MessageException) Props(org.sonar.process.Props)

Example 48 with Props

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

the class ClusterSettingsTest method accept_throws_MessageException_if_h2_on_application_node.

@Test
@UseDataProvider("validIPv4andIPv6Addresses")
public void accept_throws_MessageException_if_h2_on_application_node(String host) {
    TestAppSettings settings = newSettingsForAppNode(host, of("sonar.jdbc.url", "jdbc:h2:mem"));
    ClusterSettings clusterSettings = new ClusterSettings(network);
    Props props = settings.getProps();
    assertThatThrownBy(() -> clusterSettings.accept(props)).isInstanceOf(MessageException.class).hasMessage("Embedded database is not supported in cluster mode");
}
Also used : MessageException(org.sonar.process.MessageException) Props(org.sonar.process.Props) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 49 with Props

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

the class ClusterSettingsTest method accept_throws_MessageException_on_application_node_if_default_jdbc_url.

@Test
@UseDataProvider("validIPv4andIPv6Addresses")
public void accept_throws_MessageException_on_application_node_if_default_jdbc_url(String host) {
    TestAppSettings settings = newSettingsForAppNode(host);
    settings.clearProperty(JDBC_URL.getKey());
    ClusterSettings clusterSettings = new ClusterSettings(network);
    Props props = settings.getProps();
    assertThatThrownBy(() -> clusterSettings.accept(props)).isInstanceOf(MessageException.class).hasMessage("Embedded database is not supported in cluster mode");
}
Also used : MessageException(org.sonar.process.MessageException) Props(org.sonar.process.Props) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 50 with Props

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

the class ClusterSettingsTest method verifyHostIsChecked.

private void verifyHostIsChecked(TestAppSettings settings, Collection<String> invalidHosts, String expectedMessage) {
    reset(network);
    mockAllHostsValidBut(invalidHosts);
    mockLocalNonLoopback("hz_host", "search_host");
    ClusterSettings clusterSettings = new ClusterSettings(network);
    Props props = settings.getProps();
    assertThatThrownBy(() -> clusterSettings.accept(props)).isInstanceOf(MessageException.class).hasMessage(expectedMessage);
}
Also used : MessageException(org.sonar.process.MessageException) Props(org.sonar.process.Props)

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