Search in sources :

Example 6 with NodeHealth

use of org.sonar.process.cluster.health.NodeHealth in project sonarqube by SonarSource.

the class SearchNodeHealthProviderTest method get_returns_status_RED_with_cause_if_elasticsearch_process_is_not_operational_in_ClusterAppState.

@Test
public void get_returns_status_RED_with_cause_if_elasticsearch_process_is_not_operational_in_ClusterAppState() {
    Properties properties = new Properties();
    setRequiredPropertiesAndMocks(properties);
    when(clusterAppState.isOperational(ProcessId.ELASTICSEARCH, true)).thenReturn(false);
    SearchNodeHealthProvider underTest = new SearchNodeHealthProvider(new Props(properties), clusterAppState, networkUtils, clock);
    NodeHealth nodeHealth = underTest.get();
    assertThat(nodeHealth.getStatus()).isEqualTo(NodeHealth.Status.RED);
    assertThat(nodeHealth.getCauses()).containsOnly("Elasticsearch is not operational");
}
Also used : Properties(java.util.Properties) Props(org.sonar.process.Props) NodeHealth(org.sonar.process.cluster.health.NodeHealth) Test(org.junit.Test)

Example 7 with NodeHealth

use of org.sonar.process.cluster.health.NodeHealth in project sonarqube by SonarSource.

the class AppNodeClusterCheckTest method status_YELLOW_when_single_YELLOW_application_node.

@Test
public void status_YELLOW_when_single_YELLOW_application_node() {
    Set<NodeHealth> nodeHealths = nodeHealths(YELLOW).collect(toSet());
    Health check = underTest.check(nodeHealths);
    assertThat(check).forInput(nodeHealths).hasStatus(Health.Status.YELLOW).andCauses("Status of all application nodes is YELLOW", "There should be at least two application nodes");
}
Also used : NodeHealth(org.sonar.process.cluster.health.NodeHealth) NodeHealth(org.sonar.process.cluster.health.NodeHealth) Test(org.junit.Test)

Example 8 with NodeHealth

use of org.sonar.process.cluster.health.NodeHealth in project sonarqube by SonarSource.

the class AppNodeClusterCheckTest method status_YELLOW_when_two_YELLOW_application_nodes.

@Test
public void status_YELLOW_when_two_YELLOW_application_nodes() {
    Set<NodeHealth> nodeHealths = nodeHealths(YELLOW, YELLOW).collect(toSet());
    Health check = underTest.check(nodeHealths);
    assertThat(check).forInput(nodeHealths).hasStatus(Health.Status.YELLOW).andCauses("Status of all application nodes is YELLOW");
}
Also used : NodeHealth(org.sonar.process.cluster.health.NodeHealth) NodeHealth(org.sonar.process.cluster.health.NodeHealth) Test(org.junit.Test)

Example 9 with NodeHealth

use of org.sonar.process.cluster.health.NodeHealth in project sonarqube by SonarSource.

the class AppNodeClusterCheckTest method status_RED_when_no_application_node.

@Test
public void status_RED_when_no_application_node() {
    Set<NodeHealth> nodeHealths = nodeHealths().collect(toSet());
    Health check = underTest.check(nodeHealths);
    assertThat(check).forInput(nodeHealths).hasStatus(Health.Status.RED).andCauses("No application node");
}
Also used : NodeHealth(org.sonar.process.cluster.health.NodeHealth) NodeHealth(org.sonar.process.cluster.health.NodeHealth) Test(org.junit.Test)

Example 10 with NodeHealth

use of org.sonar.process.cluster.health.NodeHealth in project sonarqube by SonarSource.

the class AppNodeClusterCheckTest method status_YELLOW_when_one_YELLOW_node_and_one_GREEN_application_node.

@Test
public void status_YELLOW_when_one_YELLOW_node_and_one_GREEN_application_node() {
    Set<NodeHealth> nodeHealths = nodeHealths(YELLOW, GREEN).collect(toSet());
    Health check = underTest.check(nodeHealths);
    assertThat(check).forInput(nodeHealths).hasStatus(Health.Status.YELLOW).andCauses("At least one application node is YELLOW");
}
Also used : NodeHealth(org.sonar.process.cluster.health.NodeHealth) NodeHealth(org.sonar.process.cluster.health.NodeHealth) Test(org.junit.Test)

Aggregations

NodeHealth (org.sonar.process.cluster.health.NodeHealth)37 Test (org.junit.Test)33 Arrays (java.util.Arrays)6 Properties (java.util.Properties)6 Random (java.util.Random)6 IntStream (java.util.stream.IntStream)6 RandomStringUtils.randomAlphanumeric (org.apache.commons.lang.RandomStringUtils.randomAlphanumeric)6 Props (org.sonar.process.Props)6 NodeDetails (org.sonar.process.cluster.health.NodeDetails)6 Set (java.util.Set)5 Collectors.toSet (java.util.stream.Collectors.toSet)4 Stream (java.util.stream.Stream)4 Stream.of (java.util.stream.Stream.of)4 GREEN (org.sonar.process.cluster.health.NodeHealth.Status.GREEN)4 RED (org.sonar.process.cluster.health.NodeHealth.Status.RED)4 YELLOW (org.sonar.process.cluster.health.NodeHealth.Status.YELLOW)4 HealthAssert.assertThat (org.sonar.server.health.HealthAssert.assertThat)4 Date (java.util.Date)3 HashSet (java.util.HashSet)2 List (java.util.List)2