Honour container.replica option Use the GerritIsReplica annotation to get information about gerrit being a read-only installation so that both container.replica and the legacy configuration are honoured. Change-Id: I820f9a9e6094ff682b02acfbb9bf1dec6b65fa3b
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 2242463..3e5306c 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/healthcheck/HealthCheckConfig.java +++ b/src/main/java/com/googlesource/gerrit/plugins/healthcheck/HealthCheckConfig.java
@@ -24,7 +24,7 @@ import com.google.gerrit.extensions.annotations.PluginName; import com.google.gerrit.server.config.AllProjectsName; import com.google.gerrit.server.config.AllUsersName; -import com.google.gerrit.server.config.GerritServerConfig; +import com.google.gerrit.server.config.GerritIsReplica; import com.google.gerrit.server.config.PluginConfigFactory; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -62,11 +62,11 @@ @PluginName String pluginName, AllProjectsName allProjectsName, AllUsersName allUsersName, - @GerritServerConfig Config gerritConfig) { + @GerritIsReplica boolean isReplica) { config = configFactory.getGlobalPluginConfig(pluginName); this.allProjectsName = allProjectsName; this.allUsersName = allUsersName; - isReplica = gerritConfig.getBoolean("container", "slave", false); + this.isReplica = isReplica; } @VisibleForTesting
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 ef5dc8e..16c6739 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/healthcheck/HealthCheckIT.java +++ b/src/test/java/com/googlesource/gerrit/plugins/healthcheck/HealthCheckIT.java
@@ -84,7 +84,7 @@ } @Test - @GerritConfig(name = "container.slave", value = "true") + @GerritConfig(name = "container.replica", value = "true") public void shouldReturnJGitCheckForReplicaWhenAuthenticated() throws Exception { RestResponse resp = getHealthCheckStatus(); resp.assertOK(); @@ -92,7 +92,7 @@ } @Test - @GerritConfig(name = "container.slave", value = "true") + @GerritConfig(name = "container.replica", value = "true") public void shouldReturnJGitCheckForReplicaAnonymously() throws Exception { RestResponse resp = getHealthCheckStatusAnonymously(); resp.assertOK(); @@ -135,8 +135,8 @@ } @Test - @GerritConfig(name = "container.slave", value = "true") - public void shouldReturnQueryChangesAsDisabledForSlave() throws Exception { + @GerritConfig(name = "container.replica", value = "true") + public void shouldReturnQueryChangesAsDisabledForReplica() throws Exception { RestResponse resp = getHealthCheckStatus(); resp.assertOK();