Log project deletion in sharedref_log
Fix issue whereby project deletions were not logged in the
sharedref_log, due to the fact that the ProjectdDeleted listener was
instantiated with a bare SharedRefDB, rather than the wrapper.
Bug: Issue 11296
Change-Id: Ifd05d28d98abb3d10511cfa87dee86226fd8ff11
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/ProjectDeletedSharedDbCleanup.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/ProjectDeletedSharedDbCleanup.java
index 7f58d39..78e1cea 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/ProjectDeletedSharedDbCleanup.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/ProjectDeletedSharedDbCleanup.java
@@ -17,19 +17,19 @@
import com.google.common.flogger.FluentLogger;
import com.google.gerrit.extensions.events.ProjectDeletedListener;
import com.google.inject.Inject;
-import com.googlesource.gerrit.plugins.multisite.validation.dfsrefdb.SharedRefDatabase;
+import com.googlesource.gerrit.plugins.multisite.SharedRefDatabaseWrapper;
import java.io.IOException;
public class ProjectDeletedSharedDbCleanup implements ProjectDeletedListener {
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
- private final SharedRefDatabase sharedDb;
+ private final SharedRefDatabaseWrapper sharedDb;
private final ValidationMetrics validationMetrics;
@Inject
public ProjectDeletedSharedDbCleanup(
- SharedRefDatabase sharedDb, ValidationMetrics validationMetrics) {
+ SharedRefDatabaseWrapper sharedDb, ValidationMetrics validationMetrics) {
this.sharedDb = sharedDb;
this.validationMetrics = validationMetrics;
}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/dfsrefdb/zookeeper/ZkSharedRefDatabaseTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/dfsrefdb/zookeeper/ZkSharedRefDatabaseTest.java
index e0415a6..a786180 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/dfsrefdb/zookeeper/ZkSharedRefDatabaseTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/dfsrefdb/zookeeper/ZkSharedRefDatabaseTest.java
@@ -19,6 +19,8 @@
import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.events.ProjectDeletedListener;
+import com.googlesource.gerrit.plugins.multisite.SharedRefDatabaseWrapper;
+import com.googlesource.gerrit.plugins.multisite.validation.DisabledSharedRefLogger;
import com.googlesource.gerrit.plugins.multisite.validation.ProjectDeletedSharedDbCleanup;
import com.googlesource.gerrit.plugins.multisite.validation.ValidationMetrics;
import com.googlesource.gerrit.plugins.multisite.validation.ZkConnectionConfig;
@@ -38,7 +40,7 @@
@Rule public TestName nameRule = new TestName();
ZookeeperTestContainerSupport zookeeperContainer;
- ZkSharedRefDatabase zkSharedRefDatabase;
+ SharedRefDatabaseWrapper zkSharedRefDatabase;
SharedRefEnforcement refEnforcement;
ValidationMetrics mockValidationMetrics;
@@ -52,11 +54,13 @@
int NUMBER_OF_RETRIES = 5;
zkSharedRefDatabase =
- new ZkSharedRefDatabase(
- zookeeperContainer.getCurator(),
- new ZkConnectionConfig(
- new RetryNTimes(NUMBER_OF_RETRIES, SLEEP_BETWEEN_RETRIES_MS),
- TRANSACTION_LOCK_TIMEOUT));
+ new SharedRefDatabaseWrapper(
+ new ZkSharedRefDatabase(
+ zookeeperContainer.getCurator(),
+ new ZkConnectionConfig(
+ new RetryNTimes(NUMBER_OF_RETRIES, SLEEP_BETWEEN_RETRIES_MS),
+ TRANSACTION_LOCK_TIMEOUT)),
+ new DisabledSharedRefLogger());
mockValidationMetrics = mock(ValidationMetrics.class);
}