Search in sources :

Example 31 with NodeHealth

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

the class AppNodeClusterCheckTest method status_YELLOW_when_single_GREEN_application_node.

@Test
public void status_YELLOW_when_single_GREEN_application_node() {
    Set<NodeHealth> nodeHealths = nodeHealths(GREEN).collect(toSet());
    Health check = underTest.check(nodeHealths);
    assertThat(check).forInput(nodeHealths).hasStatus(Health.Status.YELLOW).andCauses("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 32 with NodeHealth

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

the class AppNodeClusterCheckTest method status_YELLOW_when_one_RED_node_and_one_GREEN_application_node.

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

Example 33 with NodeHealth

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

the class ClusterHealthTest method verify_toString.

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

Example 34 with NodeHealth

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

the class ClusterHealthTest method verify_getters.

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

Example 35 with NodeHealth

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

the class ClusterHealthTest method equals_is_based_on_content.

@Test
public void equals_is_based_on_content() {
    Health health = randomHealth();
    Set<NodeHealth> nodeHealths = randomNodeHealths();
    ClusterHealth underTest = new ClusterHealth(health, nodeHealths);
    assertThat(underTest).isEqualTo(underTest).isEqualTo(new ClusterHealth(health, nodeHealths)).isNotEqualTo(new Object()).isNotNull().isNotEqualTo(new ClusterHealth(newHealthCheckBuilder().setStatus(health.getStatus()).addCause("foo_bar").build(), randomNodeHealths())).isNotEqualTo(new ClusterHealth(health, concat(nodeHealths.stream(), Stream.of(randomNodeHealth())).collect(toSet())));
}
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