Search in sources :

Example 36 with NodeHealth

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

the class ClusterHealthTest method hashcode_is_based_on_content.

@Test
public void hashcode_is_based_on_content() {
    Health health = randomHealth();
    Set<NodeHealth> nodeHealths = randomNodeHealths();
    ClusterHealth underTest = new ClusterHealth(health, nodeHealths);
    assertThat(underTest).hasSameHashCodeAs(underTest);
}
Also used : NodeHealth(org.sonar.process.cluster.health.NodeHealth) NodeHealth(org.sonar.process.cluster.health.NodeHealth) Test(org.junit.Test)

Example 37 with NodeHealth

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

the class HealthActionTest method response_contains_information_of_nodes_when_clustered.

@Test
public void response_contains_information_of_nodes_when_clustered() {
    authenticateWithRandomMethod();
    NodeHealth nodeHealth = randomNodeHealth();
    when(webServer.isStandalone()).thenReturn(false);
    when(healthChecker.checkCluster()).thenReturn(new ClusterHealth(GREEN, singleton(nodeHealth)));
    System.HealthResponse response = underTest.newRequest().executeProtobuf(System.HealthResponse.class);
    assertThat(response.getNodes().getNodesList()).hasSize(1);
    System.Node node = response.getNodes().getNodesList().iterator().next();
    assertThat(node.getHealth().name()).isEqualTo(nodeHealth.getStatus().name());
    assertThat(node.getCausesList()).extracting(System.Cause::getMessage).containsOnly(nodeHealth.getCauses().toArray(new String[0]));
    assertThat(node.getName()).isEqualTo(nodeHealth.getDetails().getName());
    assertThat(node.getHost()).isEqualTo(nodeHealth.getDetails().getHost());
    assertThat(node.getPort()).isEqualTo(nodeHealth.getDetails().getPort());
    assertThat(node.getStartedAt()).isEqualTo(formatDateTime(nodeHealth.getDetails().getStartedAt()));
    assertThat(node.getType().name()).isEqualTo(nodeHealth.getDetails().getType().name());
}
Also used : System(org.sonarqube.ws.System) NodeHealth(org.sonar.process.cluster.health.NodeHealth) ClusterHealth(org.sonar.server.health.ClusterHealth) 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