use of org.sonar.application.es.EsConnector in project sonarqube by SonarSource.
the class EsManagedProcessTest method isOperational_should_return_false_if_ElasticsearchException_with_connection_refused_thrown.
@Test
public void isOperational_should_return_false_if_ElasticsearchException_with_connection_refused_thrown() {
EsConnector esConnector = mock(EsConnector.class);
when(esConnector.getClusterHealthStatus()).thenThrow(new ElasticsearchException("Connection refused"));
EsManagedProcess underTest = new EsManagedProcess(mock(Process.class), ProcessId.ELASTICSEARCH, esConnector, WAIT_FOR_UP_TIMEOUT);
assertThat(underTest.isOperational()).isFalse();
}
use of org.sonar.application.es.EsConnector in project sonarqube by SonarSource.
the class ClusterAppStateImplTest method check_if_elasticsearch_is_operational_on_cluster.
@Test
public void check_if_elasticsearch_is_operational_on_cluster() {
AppStateListener listener = mock(AppStateListener.class);
EsConnector esConnectorMock = mock(EsConnector.class);
when(esConnectorMock.getClusterHealthStatus()).thenReturn(Optional.empty()).thenReturn(Optional.of(ClusterHealthStatus.RED)).thenReturn(Optional.of(ClusterHealthStatus.GREEN));
try (ClusterAppStateImpl underTest = createClusterAppState(esConnectorMock)) {
underTest.addListener(listener);
underTest.isOperational(ProcessId.ELASTICSEARCH, false);
// wait until undergoing thread marks ES as operational
verify(listener, timeout(20_000)).onAppStateOperational(ProcessId.ELASTICSEARCH);
}
}
use of org.sonar.application.es.EsConnector in project sonarqube by SonarSource.
the class AppStateFactory method create.
public AppState create() {
if (ClusterSettings.shouldStartHazelcast(settings)) {
EsConnector esConnector = createEsConnector(settings.getProps());
HazelcastMember hzMember = createHzMember(settings.getProps());
AppNodesClusterHostsConsistency appNodesClusterHostsConsistency = AppNodesClusterHostsConsistency.setInstance(hzMember, settings);
return new ClusterAppStateImpl(settings, hzMember, esConnector, appNodesClusterHostsConsistency);
}
return new AppStateImpl();
}
Aggregations