diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-08-28 15:18:11 +0200 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-09-13 15:50:47 +0200 |
commit | a27b49327ffe7e55a5ec9c94d3c2a30b0c8e7433 (patch) | |
tree | efcbe4760761fc288cae92cd31186614839e2c1b | |
parent | 93e75a9602ba57fb1b9f2d7622ca6c1ce0b7c4e4 (diff) | |
download | sonarqube-a27b49327ffe7e55a5ec9c94d3c2a30b0c8e7433.tar.gz sonarqube-a27b49327ffe7e55a5ec9c94d3c2a30b0c8e7433.zip |
SONAR-9755 rename HealthChecker#check to checkNode
5 files changed, 17 insertions, 16 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/health/HealthChecker.java b/server/sonar-server/src/main/java/org/sonar/server/health/HealthChecker.java index 48d1f94a273..2dccef66743 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/health/HealthChecker.java +++ b/server/sonar-server/src/main/java/org/sonar/server/health/HealthChecker.java @@ -21,7 +21,8 @@ package org.sonar.server.health; public interface HealthChecker { /** - * Perform a check of the health of SonarQube, either as a standalone node or as a cluster. + * Perform a check of the health of the current SonarQube node, either as a standalone node or as a member + * of a cluster. */ - Health check(); + Health checkNode(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/health/HealthCheckerImpl.java b/server/sonar-server/src/main/java/org/sonar/server/health/HealthCheckerImpl.java index e45e8cd599c..f10e890d277 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/health/HealthCheckerImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/health/HealthCheckerImpl.java @@ -38,7 +38,7 @@ public class HealthCheckerImpl implements HealthChecker { } @Override - public Health check() { + public Health checkNode() { return healthChecks.stream().map(HealthCheck::check) .reduce(Health.GREEN, HealthReducer.INSTANCE); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/HealthAction.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/HealthAction.java index 24487852997..f94cd0c40eb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/HealthAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/HealthAction.java @@ -53,7 +53,7 @@ public class HealthAction implements SystemWsAction { @Override public void handle(Request request, Response response) throws Exception { - Health check = healthChecker.check(); + Health check = healthChecker.checkNode(); WsSystem.HealthResponse.Builder responseBuilder = WsSystem.HealthResponse.newBuilder() .setHealth(WsSystem.Health.valueOf(check.getStatus().name())); WsSystem.Cause.Builder causeBuilder = WsSystem.Cause.newBuilder(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java index ae91caeee7e..e206098d74e 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java @@ -43,21 +43,21 @@ public class HealthCheckerImplTest { public void check_returns_green_status_without_any_cause_when_there_is_no_HealthCheck() { HealthCheckerImpl underTest = new HealthCheckerImpl(); - assertThat(underTest.check()).isEqualTo(Health.GREEN); + assertThat(underTest.checkNode()).isEqualTo(Health.GREEN); } @Test - public void checks_returns_GREEN_status_if_only_GREEN_statuses_returned_by_HealthChecks() { + public void checkNode_returns_GREEN_status_if_only_GREEN_statuses_returned_by_HealthChecks() { List<Health.Status> statuses = IntStream.range(1, 1 + random.nextInt(20)).mapToObj(i -> GREEN).collect(Collectors.toList()); HealthCheckerImpl underTest = newHealthCheckerImpl(statuses.stream()); - assertThat(underTest.check().getStatus()) + assertThat(underTest.checkNode().getStatus()) .describedAs("%s should have been computed from %s statuses", GREEN, statuses) .isEqualTo(GREEN); } @Test - public void checks_returns_YELLOW_status_if_only_GREEN_and_at_least_one_YELLOW_statuses_returned_by_HealthChecks() { + public void checkNode_returns_YELLOW_status_if_only_GREEN_and_at_least_one_YELLOW_statuses_returned_by_HealthChecks() { List<Health.Status> statuses = new ArrayList<>(); Stream.concat( IntStream.range(0, 1 + random.nextInt(20)).mapToObj(i -> YELLOW), // at least 1 YELLOW @@ -65,13 +65,13 @@ public class HealthCheckerImplTest { Collections.shuffle(statuses); HealthCheckerImpl underTest = newHealthCheckerImpl(statuses.stream()); - assertThat(underTest.check().getStatus()) + assertThat(underTest.checkNode().getStatus()) .describedAs("%s should have been computed from %s statuses", YELLOW, statuses) .isEqualTo(YELLOW); } @Test - public void checks_returns_RED_status_if_at_least_one_RED_status_returned_by_HealthChecks() { + public void checkNode_returns_RED_status_if_at_least_one_RED_status_returned_by_HealthChecks() { List<Health.Status> statuses = new ArrayList<>(); Stream.of( IntStream.range(0, 1 + random.nextInt(20)).mapToObj(i -> RED), // at least 1 RED @@ -82,13 +82,13 @@ public class HealthCheckerImplTest { Collections.shuffle(statuses); HealthCheckerImpl underTest = newHealthCheckerImpl(statuses.stream()); - assertThat(underTest.check().getStatus()) + assertThat(underTest.checkNode().getStatus()) .describedAs("%s should have been computed from %s statuses", RED, statuses) .isEqualTo(RED); } @Test - public void checks_returns_causes_of_all_HealthChecks_whichever_their_status() { + public void checkNode_returns_causes_of_all_HealthChecks_whichever_their_status() { HealthCheck[] healthChecks = IntStream.range(0, 1 + random.nextInt(20)) .mapToObj(s -> new StaticHealthCheck(IntStream.range(0, random.nextInt(3)).mapToObj(i -> RandomStringUtils.randomAlphanumeric(3)).toArray(String[]::new))) .map(HealthCheck.class::cast) @@ -97,7 +97,7 @@ public class HealthCheckerImplTest { HealthCheckerImpl underTest = new HealthCheckerImpl(healthChecks); - assertThat(underTest.check().getCauses()).containsOnly(expected); + assertThat(underTest.checkNode().getCauses()).containsOnly(expected); } private HealthCheckerImpl newHealthCheckerImpl(Stream<Health.Status> statuses) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java index cb45a2d029d..63c94dff67e 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java @@ -55,7 +55,7 @@ public class HealthActionTest { @Test public void verify_example() { - when(mockedHealthChecker.check()).thenReturn( + when(mockedHealthChecker.checkNode()).thenReturn( newHealthCheckBuilder() .setStatus(Health.Status.YELLOW) .addCause("Elasticsearch status is YELLOW") @@ -67,13 +67,13 @@ public class HealthActionTest { } @Test - public void request_returns_status_and_causes_from_HealthChecker_check_method() { + public void request_returns_status_and_causes_from_HealthChecker_checkNode_method() { Health.Status randomStatus = Health.Status.values()[new Random().nextInt(Health.Status.values().length)]; Health.Builder builder = newHealthCheckBuilder() .setStatus(randomStatus); IntStream.range(0, new Random().nextInt(5)).mapToObj(i -> RandomStringUtils.randomAlphanumeric(3)).forEach(builder::addCause); Health health = builder.build(); - when(mockedHealthChecker.check()).thenReturn(health); + when(mockedHealthChecker.checkNode()).thenReturn(health); TestRequest request = underTest.newRequest(); WsSystem.HealthResponse healthResponse = request.executeProtobuf(WsSystem.HealthResponse.class); |