Search in sources :

Example 1 with Props

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

the class ComputeEngineContainerImplTest method real_start.

@Test
public void real_start() throws IOException {
    Properties properties = ProcessProperties.defaults();
    File homeDir = tempFolder.newFolder();
    File dataDir = new File(homeDir, "data");
    File tmpDir = new File(homeDir, "tmp");
    properties.setProperty(PATH_HOME, homeDir.getAbsolutePath());
    properties.setProperty(PATH_DATA, dataDir.getAbsolutePath());
    properties.setProperty(PATH_TEMP, tmpDir.getAbsolutePath());
    properties.setProperty(PROPERTY_PROCESS_INDEX, valueOf(ProcessId.COMPUTE_ENGINE.getIpcIndex()));
    properties.setProperty(PROPERTY_SHARED_PATH, tmpDir.getAbsolutePath());
    properties.setProperty(DatabaseProperties.PROP_URL, ((BasicDataSource) dbTester.database().getDataSource()).getUrl());
    properties.setProperty(DatabaseProperties.PROP_USER, "sonar");
    properties.setProperty(DatabaseProperties.PROP_PASSWORD, "sonar");
    // required persisted properties
    insertProperty(CoreProperties.SERVER_ID, "a_startup_id");
    insertProperty(CoreProperties.SERVER_STARTTIME, DateUtils.formatDateTime(new Date()));
    underTest.start(new Props(properties));
    MutablePicoContainer picoContainer = underTest.getComponentContainer().getPicoContainer();
    assertThat(picoContainer.getComponentAdapters()).hasSize(CONTAINER_ITSELF + // level 4
    75 + // content of CeConfigurationModule
    4 + // content of CeQueueModule
    5 + // content of CeHttpModule
    3 + // content of CeTaskCommonsModule
    3 + // content of ProjectAnalysisTaskModule
    4 + // content of CeTaskProcessorModule
    4);
    assertThat(picoContainer.getParent().getComponentAdapters()).hasSize(CONTAINER_ITSELF + // level 3
    5);
    assertThat(picoContainer.getParent().getParent().getComponentAdapters()).hasSize(CONTAINER_ITSELF + // MigrationConfigurationModule
    10 + // level 2
    17);
    assertThat(picoContainer.getParent().getParent().getParent().getComponentAdapters()).hasSize(COMPONENTS_IN_LEVEL_1_AT_CONSTRUCTION + // level 1
    23 + // content of DaoModule
    47 + // content of EsSearchModule
    3 + // content of CorePropertyDefinitions
    57 + // content of CePropertyDefinitions
    1);
    assertThat(picoContainer.getParent().getParent().getParent().getParent()).isNull();
    underTest.stop();
    assertThat(picoContainer.getLifecycleState().isStarted()).isFalse();
    assertThat(picoContainer.getLifecycleState().isStopped()).isFalse();
    assertThat(picoContainer.getLifecycleState().isDisposed()).isTrue();
}
Also used : MutablePicoContainer(org.picocontainer.MutablePicoContainer) DatabaseProperties(org.sonar.api.database.DatabaseProperties) Properties(java.util.Properties) CoreProperties(org.sonar.api.CoreProperties) ProcessProperties(org.sonar.process.ProcessProperties) Props(org.sonar.process.Props) File(java.io.File) Date(java.util.Date) Test(org.junit.Test)

Example 2 with Props

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

the class EsSettingsTest method cluster_is_enabled.

@Test
public void cluster_is_enabled() throws Exception {
    Props props = minProps();
    props.set(ProcessProperties.CLUSTER_ENABLED, "true");
    props.set(ProcessProperties.CLUSTER_SEARCH_HOSTS, "1.2.3.4:9000,1.2.3.5:8080");
    Settings settings = new EsSettings(props).build();
    assertThat(settings.get("index.number_of_replicas")).isEqualTo("1");
    assertThat(settings.get("discovery.zen.ping.unicast.hosts")).isEqualTo("1.2.3.4:9000,1.2.3.5:8080");
}
Also used : Props(org.sonar.process.Props) Settings(org.elasticsearch.common.settings.Settings) Test(org.junit.Test)

Example 3 with Props

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

the class EsSettingsTest method enable_http_connector.

@Test
public void enable_http_connector() throws Exception {
    Props props = minProps();
    props.set(ProcessProperties.SEARCH_HTTP_PORT, "9010");
    Settings settings = new EsSettings(props).build();
    assertThat(settings.get("http.port")).isEqualTo("9010");
    assertThat(settings.get("http.host")).isEqualTo("127.0.0.1");
    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 4 with Props

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

the class EsSettingsTest method minProps.

private Props minProps() throws IOException {
    File homeDir = temp.newFolder();
    Props props = new Props(new Properties());
    ProcessProperties.completeDefaults(props);
    props.set(ProcessProperties.PATH_HOME, homeDir.getAbsolutePath());
    return props;
}
Also used : Props(org.sonar.process.Props) ProcessProperties(org.sonar.process.ProcessProperties) Properties(java.util.Properties) File(java.io.File)

Example 5 with Props

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

the class TomcatContextsTest method context_path_must_start_with_slash.

@Test
public void context_path_must_start_with_slash() {
    props.setProperty("sonar.web.context", "foo");
    expectedException.expect(MessageException.class);
    expectedException.expectMessage("Value of 'sonar.web.context' must start with a forward slash: 'foo'");
    underTest.configure(tomcat, new Props(props));
}
Also used : 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