Search in sources :

Example 6 with EsConnector

use of org.sonar.application.es.EsConnector in project sonarqube by SonarSource.

the class EsManagedProcessTest method isOperational_should_return_false_if_status_is_unknown.

@Test
public void isOperational_should_return_false_if_status_is_unknown() {
    EsConnector esConnector = mock(EsConnector.class);
    when(esConnector.getClusterHealthStatus()).thenReturn(Optional.empty());
    EsManagedProcess underTest = new EsManagedProcess(mock(Process.class), ProcessId.ELASTICSEARCH, esConnector, WAIT_FOR_UP_TIMEOUT);
    assertThat(underTest.isOperational()).isFalse();
}
Also used : EsConnector(org.sonar.application.es.EsConnector) Test(org.junit.Test)

Example 7 with EsConnector

use of org.sonar.application.es.EsConnector in project sonarqube by SonarSource.

the class EsManagedProcessTest method isOperational_should_return_false_if_Elasticsearch_status_cannot_be_evaluated.

@Test
public void isOperational_should_return_false_if_Elasticsearch_status_cannot_be_evaluated() {
    EsConnector esConnector = mock(EsConnector.class);
    when(esConnector.getClusterHealthStatus()).thenThrow(new RuntimeException("test"));
    EsManagedProcess underTest = new EsManagedProcess(mock(Process.class), ProcessId.ELASTICSEARCH, esConnector, WAIT_FOR_UP_TIMEOUT);
    assertThat(underTest.isOperational()).isFalse();
}
Also used : EsConnector(org.sonar.application.es.EsConnector) Test(org.junit.Test)

Example 8 with EsConnector

use of org.sonar.application.es.EsConnector in project sonarqube by SonarSource.

the class EsManagedProcessTest method isOperational_should_retry_if_Elasticsearch_is_unreachable.

@Test
public void isOperational_should_retry_if_Elasticsearch_is_unreachable() {
    EsConnector esConnector = mock(EsConnector.class);
    when(esConnector.getClusterHealthStatus()).thenReturn(Optional.empty()).thenReturn(Optional.of(ClusterHealthStatus.GREEN));
    EsManagedProcess underTest = new EsManagedProcess(mock(Process.class), ProcessId.ELASTICSEARCH, esConnector, WAIT_FOR_UP_TIMEOUT);
    assertThat(underTest.isOperational()).isTrue();
}
Also used : EsConnector(org.sonar.application.es.EsConnector) Test(org.junit.Test)

Example 9 with EsConnector

use of org.sonar.application.es.EsConnector in project sonarqube by SonarSource.

the class EsManagedProcessTest method isOperational_should_return_false_if_ElasticsearchException_thrown.

@Test
public void isOperational_should_return_false_if_ElasticsearchException_thrown() {
    EsConnector esConnector = mock(EsConnector.class);
    when(esConnector.getClusterHealthStatus()).thenThrow(new ElasticsearchException("test"));
    EsManagedProcess underTest = new EsManagedProcess(mock(Process.class), ProcessId.ELASTICSEARCH, esConnector, WAIT_FOR_UP_TIMEOUT);
    assertThat(underTest.isOperational()).isFalse();
}
Also used : EsConnector(org.sonar.application.es.EsConnector) ElasticsearchException(org.elasticsearch.ElasticsearchException) Test(org.junit.Test)

Example 10 with EsConnector

use of org.sonar.application.es.EsConnector in project sonarqube by SonarSource.

the class EsManagedProcessTest method isOperational_should_return_true_if_Elasticsearch_is_GREEN.

@Test
public void isOperational_should_return_true_if_Elasticsearch_is_GREEN() {
    EsConnector esConnector = mock(EsConnector.class);
    when(esConnector.getClusterHealthStatus()).thenReturn(Optional.of(ClusterHealthStatus.GREEN));
    EsManagedProcess underTest = new EsManagedProcess(mock(Process.class), ProcessId.ELASTICSEARCH, esConnector, WAIT_FOR_UP_TIMEOUT);
    assertThat(underTest.isOperational()).isTrue();
}
Also used : EsConnector(org.sonar.application.es.EsConnector) Test(org.junit.Test)

Aggregations

EsConnector (org.sonar.application.es.EsConnector)13 Test (org.junit.Test)12 ElasticsearchException (org.elasticsearch.ElasticsearchException)3 LoggerContext (ch.qos.logback.classic.LoggerContext)1 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)1 ConnectException (java.net.ConnectException)1 ExecutionException (java.util.concurrent.ExecutionException)1 ElasticsearchStatusException (org.elasticsearch.ElasticsearchStatusException)1 AppStateListener (org.sonar.application.AppStateListener)1 AppNodesClusterHostsConsistency (org.sonar.application.cluster.AppNodesClusterHostsConsistency)1 ClusterAppStateImpl (org.sonar.application.cluster.ClusterAppStateImpl)1 HazelcastMember (org.sonar.process.cluster.hz.HazelcastMember)1