Search in sources :

Example 26 with NodeHealth

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

the class AppNodeClusterCheckTest method status_YELLOW_when_two_GREEN_application_node_and_any_number_of_other_is_RED_or_GREEN.

@Test
public void status_YELLOW_when_two_GREEN_application_node_and_any_number_of_other_is_RED_or_GREEN() {
    Set<NodeHealth> nodeHealths = of(// at least 1 RED
    of(appNodeHealth(RED)), // 0 to 10 RED/GREEN
    randomNumberOfAppNodeHealthOfAnyStatus(GREEN, RED), // 2 GREEN
    nodeHealths(GREEN, GREEN)).flatMap(s -> s).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 : IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) RandomStringUtils.randomAlphanumeric(org.apache.commons.lang.RandomStringUtils.randomAlphanumeric) Stream.of(java.util.stream.Stream.of) Set(java.util.Set) Random(java.util.Random) Test(org.junit.Test) RED(org.sonar.process.cluster.health.NodeHealth.Status.RED) GREEN(org.sonar.process.cluster.health.NodeHealth.Status.GREEN) Stream(java.util.stream.Stream) NodeHealth(org.sonar.process.cluster.health.NodeHealth) NodeDetails(org.sonar.process.cluster.health.NodeDetails) YELLOW(org.sonar.process.cluster.health.NodeHealth.Status.YELLOW) HealthAssert.assertThat(org.sonar.server.health.HealthAssert.assertThat) Collectors.toSet(java.util.stream.Collectors.toSet) NodeHealth(org.sonar.process.cluster.health.NodeHealth) NodeHealth(org.sonar.process.cluster.health.NodeHealth) Test(org.junit.Test)

Example 27 with NodeHealth

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

the class AppNodeClusterCheckTest method status_YELLOW_when_two_GREEN_application_node_and_any_number_of_other_is_either_RED_or_YELLOW.

@Test
public void status_YELLOW_when_two_GREEN_application_node_and_any_number_of_other_is_either_RED_or_YELLOW() {
    Set<NodeHealth> nodeHealths = of(// at least 1 RED
    of(appNodeHealth(RED)), // at least 1 YELLOW
    of(appNodeHealth(YELLOW)), // 0 to 10 RED/YELLOW/GREEN
    randomNumberOfAppNodeHealthOfAnyStatus(RED, YELLOW, GREEN), // 2 GREEN
    nodeHealths(GREEN, GREEN)).flatMap(s -> s).collect(toSet());
    Health check = underTest.check(nodeHealths);
    assertThat(check).forInput(nodeHealths).hasStatus(Health.Status.YELLOW).andCauses("At least one application node is YELLOW", "At least one application node is RED");
}
Also used : IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) RandomStringUtils.randomAlphanumeric(org.apache.commons.lang.RandomStringUtils.randomAlphanumeric) Stream.of(java.util.stream.Stream.of) Set(java.util.Set) Random(java.util.Random) Test(org.junit.Test) RED(org.sonar.process.cluster.health.NodeHealth.Status.RED) GREEN(org.sonar.process.cluster.health.NodeHealth.Status.GREEN) Stream(java.util.stream.Stream) NodeHealth(org.sonar.process.cluster.health.NodeHealth) NodeDetails(org.sonar.process.cluster.health.NodeDetails) YELLOW(org.sonar.process.cluster.health.NodeHealth.Status.YELLOW) HealthAssert.assertThat(org.sonar.server.health.HealthAssert.assertThat) Collectors.toSet(java.util.stream.Collectors.toSet) NodeHealth(org.sonar.process.cluster.health.NodeHealth) NodeHealth(org.sonar.process.cluster.health.NodeHealth) Test(org.junit.Test)

Example 28 with NodeHealth

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

the class AppNodeClusterCheckTest method status_GREEN_when_two_GREEN_application_node_and_any_number_of_other_is_GREEN.

@Test
public void status_GREEN_when_two_GREEN_application_node_and_any_number_of_other_is_GREEN() {
    Set<NodeHealth> nodeHealths = of(// at least 1 extra GREEN
    of(appNodeHealth(GREEN)), // 0 to 10 GREEN
    randomNumberOfAppNodeHealthOfAnyStatus(GREEN), // 2 GREEN
    nodeHealths(GREEN, GREEN)).flatMap(s -> s).collect(toSet());
    Health check = underTest.check(nodeHealths);
    assertThat(check).forInput(nodeHealths).hasStatus(Health.Status.GREEN).andCauses();
}
Also used : IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) RandomStringUtils.randomAlphanumeric(org.apache.commons.lang.RandomStringUtils.randomAlphanumeric) Stream.of(java.util.stream.Stream.of) Set(java.util.Set) Random(java.util.Random) Test(org.junit.Test) RED(org.sonar.process.cluster.health.NodeHealth.Status.RED) GREEN(org.sonar.process.cluster.health.NodeHealth.Status.GREEN) Stream(java.util.stream.Stream) NodeHealth(org.sonar.process.cluster.health.NodeHealth) NodeDetails(org.sonar.process.cluster.health.NodeDetails) YELLOW(org.sonar.process.cluster.health.NodeHealth.Status.YELLOW) HealthAssert.assertThat(org.sonar.server.health.HealthAssert.assertThat) Collectors.toSet(java.util.stream.Collectors.toSet) NodeHealth(org.sonar.process.cluster.health.NodeHealth) NodeHealth(org.sonar.process.cluster.health.NodeHealth) Test(org.junit.Test)

Example 29 with NodeHealth

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

the class AppNodeClusterCheckTest method status_RED_when_single_RED_application_node.

@Test
public void status_RED_when_single_RED_application_node() {
    Set<NodeHealth> nodeHealths = nodeHealths(RED).collect(toSet());
    Health check = underTest.check(nodeHealths);
    assertThat(check).forInput(nodeHealths).hasStatus(Health.Status.RED).andCauses("Status of all application nodes is RED", "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 30 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_YELLOW_application_node.

@Test
public void status_YELLOW_when_one_RED_node_and_one_YELLOW_application_node() {
    Set<NodeHealth> nodeHealths = nodeHealths(RED, YELLOW).collect(toSet());
    Health check = underTest.check(nodeHealths);
    assertThat(check).forInput(nodeHealths).hasStatus(Health.Status.YELLOW).andCauses("At least one application node is RED", "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