Merge branch 'stable-2.16'
* stable-2.16:
Auth: check the ability to authenticate users
Change-Id: I81c7c6c8ae23cc428f484b969f80de2231b27dac
diff --git a/README.md b/README.md
index fe38bc8..f5af98a 100644
--- a/README.md
+++ b/README.md
@@ -37,16 +37,17 @@
- ts: epoch timestamp in millis of the test
- elapsed: elapsed time in millis to perform the check
+- querychanges: check that Gerrit can query changes
- reviewdb: check that Gerrit can connect and query ReviewDb
- projectslist: check that Gerrit can list projects
-- jgit: check that Gerrit can access repositories
+- jgit: check that Gerrit can access repositories
Each check returns a JSON payload with the following information:
- ts: epoch timestamp in millis of the individual check
- elapsed: elapsed time in millis to complete the check
- result: result of the health check
-
+
- passed: the check passed successfully
- failed: the check failed with an error
- timeout: the check took too long and timed out
@@ -59,9 +60,15 @@
200 OK
Content-Type: application/json
+)]}'
{
"ts": 139402910202,
"elapsed": 100,
+ "querychanges": {
+ "ts": 139402910202,
+ "elapsed": 20,
+ "result": "passed"
+ },
"reviewdb": {
"ts": 139402910202,
"elapsed": 50,
@@ -88,9 +95,15 @@
500 ERROR
Content-Type: application/json
+)]}'
{
"ts": 139402910202,
"elapsed": 100,
+ "querychanges": {
+ "ts": 139402910202,
+ "elapsed": 20,
+ "result": "passed"
+ },
"reviewdb": {
"ts": 139402910202,
"elapsed": 50,
@@ -117,4 +130,4 @@
Some additional metrics are also produced to give extra insights on their result about results and latency of healthcheck
sub component, such as jgit, reviewdb, etc.
-More information can be found in the [config.md](resources/Documentation/config.md) file.
\ No newline at end of file
+More information can be found in the [config.md](resources/Documentation/config.md) file.
diff --git a/src/main/java/com/googlesource/gerrit/plugins/healthcheck/HealthCheckSubsystemsModule.java b/src/main/java/com/googlesource/gerrit/plugins/healthcheck/HealthCheckSubsystemsModule.java
index 6426fa1..a7eb01a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/healthcheck/HealthCheckSubsystemsModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/healthcheck/HealthCheckSubsystemsModule.java
@@ -22,13 +22,11 @@
import com.googlesource.gerrit.plugins.healthcheck.check.JGitHealthCheck;
import com.googlesource.gerrit.plugins.healthcheck.check.ProjectsListHealthCheck;
import com.googlesource.gerrit.plugins.healthcheck.check.QueryChangesHealthCheck;
-import com.googlesource.gerrit.plugins.healthcheck.check.ReviewDbHealthCheck;
public class HealthCheckSubsystemsModule extends AbstractModule {
@Override
protected void configure() {
- bindChecker(ReviewDbHealthCheck.class);
bindChecker(JGitHealthCheck.class);
bindChecker(ProjectsListHealthCheck.class);
bindChecker(QueryChangesHealthCheck.class);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/healthcheck/check/HealthCheckNames.java b/src/main/java/com/googlesource/gerrit/plugins/healthcheck/check/HealthCheckNames.java
index b160fc4..143d2b1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/healthcheck/check/HealthCheckNames.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/healthcheck/check/HealthCheckNames.java
@@ -15,7 +15,6 @@
package com.googlesource.gerrit.plugins.healthcheck.check;
public interface HealthCheckNames {
- String REVIEWDB = "reviewdb";
String JGIT = "jgit";
String PROJECTSLIST = "projectslist";
String QUERYCHANGES = "querychanges";
diff --git a/src/main/java/com/googlesource/gerrit/plugins/healthcheck/check/ReviewDbHealthCheck.java b/src/main/java/com/googlesource/gerrit/plugins/healthcheck/check/ReviewDbHealthCheck.java
deleted file mode 100644
index 2a184c8..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/healthcheck/check/ReviewDbHealthCheck.java
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (C) 2019 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.googlesource.gerrit.plugins.healthcheck.check;
-
-import static com.googlesource.gerrit.plugins.healthcheck.check.HealthCheckNames.REVIEWDB;
-
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.gerrit.reviewdb.client.CurrentSchemaVersion;
-import com.google.gerrit.reviewdb.server.ReviewDb;
-import com.google.gwtorm.server.SchemaFactory;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.googlesource.gerrit.plugins.healthcheck.HealthCheckConfig;
-
-@Singleton
-public class ReviewDbHealthCheck extends AbstractHealthCheck {
- private final SchemaFactory<ReviewDb> reviewDb;
-
- @Inject
- public ReviewDbHealthCheck(
- ListeningExecutorService executor,
- HealthCheckConfig config,
- SchemaFactory<ReviewDb> reviewDb) {
- super(executor, config, REVIEWDB);
- this.reviewDb = reviewDb;
- }
-
- @Override
- protected Result doCheck() throws Exception {
- try (ReviewDb db = reviewDb.open()) {
- db.schemaVersion().get(new CurrentSchemaVersion.Key());
- return Result.PASSED;
- }
- }
-}
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md
index c150f93..838db79 100644
--- a/src/main/resources/Documentation/config.md
+++ b/src/main/resources/Documentation/config.md
@@ -14,9 +14,9 @@
{
"ts": 139402910202,
"elapsed": 100,
- "reviewdb": {
+ "querychanges": {
"ts": 139402910202,
- "elapsed": 50,
+ "elapsed": 20,
"result": "passed"
},
"projectslist": {
@@ -44,7 +44,7 @@
The following check names are available:
-- `reviewdb` : check connectivity and ability to query ReviewDb
+- `querychanges`: check the ability to query changes
- `jgit` : check connectivity to the filesystem and ability to open a JGit ref and object
- `projectslist` : check the ability to list projects with their descriptions
- `auth`: check the ability to authenticate with username and password
@@ -78,4 +78,4 @@
- `healthcheck.auth.password` : Password to use for authentication
- Default: no password
\ No newline at end of file
+ Default: no password
diff --git a/src/resources/Documentation/config.md b/src/resources/Documentation/config.md
index ea51c10..aa59c29 100644
--- a/src/resources/Documentation/config.md
+++ b/src/resources/Documentation/config.md
@@ -48,9 +48,6 @@
# TYPE plugins_healthcheck_projectslist_latest_measured_latency gauge
plugins_healthcheck_projectslist_latest_measured_latency 5.0
-# HELP plugins_healthcheck_reviewdb_latest_measured_latency Generated from Dropwizard metric import (metric=plugins/healthcheck/reviewdb/latency, type=com.google.gerrit.metrics.dropwizard.CallbackMetricImpl0$1)
-# TYPE plugins_healthcheck_reviewdb_latest_measured_latency gauge
-plugins_healthcheck_reviewdb_latest_measured_latency 3.0
# HELP plugins_healthcheck_jgit_failure_total Generated from Dropwizard metric import (metric=plugins/healthcheck/jgit/failure, type=com.codahale.metrics.Meter)
# TYPE plugins_healthcheck_jgit_failure_total counter
@@ -59,10 +56,6 @@
# HELP plugins_healthcheck_projectslist_failure_total Generated from Dropwizard metric import (metric=plugins/healthcheck/projectslist/failure, type=com.codahale.metrics.Meter)
# TYPE plugins_healthcheck_projectslist_failure_total counter
plugins_healthcheck_projectslist_failure_total 0.0
-
-# HELP plugins_healthcheck_reviewdb_failure_total Generated from Dropwizard metric import (metric=plugins/healthcheck/reviewdb/failure, type=com.codahale.metrics.Meter)
-# TYPE plugins_healthcheck_reviewdb_failure_total counter
-plugins_healthcheck_reviewdb_failure_total 0.0
```
Metrics will be exposed to prometheus by the [metrics-reporter-prometheus](https://gerrit.googlesource.com/plugins/metrics-reporter-prometheus/) plugin.
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 daabc4a..24bfc81 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/healthcheck/HealthCheckIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/healthcheck/HealthCheckIT.java
@@ -18,7 +18,6 @@
import static com.google.common.truth.Truth.assertThat;
import static com.googlesource.gerrit.plugins.healthcheck.check.HealthCheckNames.JGIT;
import static com.googlesource.gerrit.plugins.healthcheck.check.HealthCheckNames.QUERYCHANGES;
-import static com.googlesource.gerrit.plugins.healthcheck.check.HealthCheckNames.REVIEWDB;
import com.google.gerrit.acceptance.LightweightPluginDaemonTest;
import com.google.gerrit.acceptance.RestResponse;
@@ -73,16 +72,6 @@
}
@Test
- public void shouldReturnReviewDbCheck() throws Exception {
- RestResponse resp = getHealthCheckStatus();
- resp.assertOK();
-
- JsonObject respPayload = gson.fromJson(resp.getReader(), JsonObject.class);
-
- assertCheckResult(respPayload, REVIEWDB, "passed");
- }
-
- @Test
public void shouldReturnJGitCheck() throws Exception {
RestResponse resp = getHealthCheckStatus();
resp.assertOK();
diff --git a/src/test/java/com/googlesource/gerrit/plugins/healthcheck/JGitHealthCheckTest.java b/src/test/java/com/googlesource/gerrit/plugins/healthcheck/JGitHealthCheckTest.java
index 1a8ec63..59dfd71 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/healthcheck/JGitHealthCheckTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/healthcheck/JGitHealthCheckTest.java
@@ -67,9 +67,9 @@
@Test
public void shouldBeHealthyWhenJGitIsWorking() {
- JGitHealthCheck reviewDbCheck =
+ JGitHealthCheck check =
new JGitHealthCheck(executor, DEFAULT_CONFIG, getWorkingRepositoryManager());
- assertThat(reviewDbCheck.run().result).isEqualTo(Result.PASSED);
+ assertThat(check.run().result).isEqualTo(Result.PASSED);
}
@Test
diff --git a/src/test/java/com/googlesource/gerrit/plugins/healthcheck/ReviewDbHealthCheckTest.java b/src/test/java/com/googlesource/gerrit/plugins/healthcheck/ReviewDbHealthCheckTest.java
deleted file mode 100644
index 5c85f42..0000000
--- a/src/test/java/com/googlesource/gerrit/plugins/healthcheck/ReviewDbHealthCheckTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (C) 2019 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.googlesource.gerrit.plugins.healthcheck;
-
-import static com.google.common.truth.Truth.assertThat;
-import static com.googlesource.gerrit.plugins.healthcheck.HealthCheckConfig.DEFAULT_CONFIG;
-
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.gerrit.lifecycle.LifecycleManager;
-import com.google.gerrit.reviewdb.server.ReviewDb;
-import com.google.gerrit.testing.DisabledReviewDb;
-import com.google.gerrit.testing.InMemoryDatabase;
-import com.google.gwtorm.server.SchemaFactory;
-import com.google.inject.Guice;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import com.googlesource.gerrit.plugins.healthcheck.check.HealthCheck;
-import com.googlesource.gerrit.plugins.healthcheck.check.ReviewDbHealthCheck;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ReviewDbHealthCheckTest {
- private SchemaFactory<ReviewDb> workingReviewDbFactory;
- @Inject private ListeningExecutorService executor;
-
- @Before
- public void setUp() throws Exception {
- Injector testInjector = Guice.createInjector(new HealthCheckModule());
- testInjector.injectMembers(this);
-
- workingReviewDbFactory = InMemoryDatabase.newDatabase(new LifecycleManager()).create();
- }
-
- @Test
- public void shouldBeHealthyWhenReviewDbIsWorking() {
- ReviewDbHealthCheck reviewDbCheck =
- new ReviewDbHealthCheck(executor, DEFAULT_CONFIG, workingReviewDbFactory);
- assertThat(reviewDbCheck.run().result).isEqualTo(HealthCheck.Result.PASSED);
- }
-
- @Test
- public void shouldBeUnhealthyWhenReviewDbIsFailing() {
- ReviewDbHealthCheck reviewDbCheck =
- new ReviewDbHealthCheck(executor, DEFAULT_CONFIG, getFailingReviewDbProvider());
- assertThat(reviewDbCheck.run().result).isEqualTo(HealthCheck.Result.FAILED);
- }
-
- private SchemaFactory<ReviewDb> getFailingReviewDbProvider() {
- return new SchemaFactory<ReviewDb>() {
- @Override
- public ReviewDb open() {
- return new DisabledReviewDb();
- }
- };
- }
-}