Disable changesindex check for gerrit replica Gerrit replicas don't have a changes index hence this check should be automatically disabled if the server is a replica. This was missed in Ibbf77115e801e9fc01ec264b01a656b2a2b29a23. Change-Id: I651c0b08817e7c732c419a0cd3c28fe1e17b31e5
diff --git a/src/main/java/com/googlesource/gerrit/plugins/healthcheck/HealthCheckConfig.java b/src/main/java/com/googlesource/gerrit/plugins/healthcheck/HealthCheckConfig.java index 93cf563..d866586 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/healthcheck/HealthCheckConfig.java +++ b/src/main/java/com/googlesource/gerrit/plugins/healthcheck/HealthCheckConfig.java
@@ -16,11 +16,13 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.googlesource.gerrit.plugins.healthcheck.check.HealthCheckNames.BLOCKEDTHREADS; +import static com.googlesource.gerrit.plugins.healthcheck.check.HealthCheckNames.CHANGES_INDEX; import static com.googlesource.gerrit.plugins.healthcheck.check.HealthCheckNames.QUERYCHANGES; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.MoreObjects; import com.google.common.base.Strings; +import com.google.common.collect.ImmutableSet; import com.google.gerrit.entities.Project; import com.google.gerrit.server.config.AllProjectsName; import com.google.gerrit.server.config.AllUsersName; @@ -28,7 +30,6 @@ import com.google.gerrit.server.config.PluginConfigFactory; import com.google.inject.Inject; import com.google.inject.Singleton; -import java.util.Collections; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -56,7 +57,7 @@ private final boolean isReplica; private static final Set<String> HEALTH_CHECK_DISABLED_FOR_REPLICAS = - Collections.singleton(QUERYCHANGES); + ImmutableSet.of(CHANGES_INDEX, QUERYCHANGES); @Inject public HealthCheckConfig(
diff --git a/src/test/java/com/googlesource/gerrit/plugins/healthcheck/HealthCheckIT.java b/src/test/java/com/googlesource/gerrit/plugins/healthcheck/HealthCheckIT.java index a0c9885..86ce328 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/healthcheck/HealthCheckIT.java +++ b/src/test/java/com/googlesource/gerrit/plugins/healthcheck/HealthCheckIT.java
@@ -150,6 +150,15 @@ } @Test + @GerritConfig(name = "container.replica", value = "true") + public void shouldReturnChangesIndexAsDisabledForReplica() throws Exception { + RestResponse resp = getHealthCheckStatus(); + resp.assertOK(); + + assertCheckResult(getResponseJson(resp), CHANGES_INDEX, "disabled"); + } + + @Test public void shouldReturnQueryChangesMultipleTimesCheck() throws Exception { createChange("refs/for/master"); getHealthCheckStatus();