Merge "Merge branch 'stable-3.2' into master"
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationTasksStorage.java b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationTasksStorage.java
index 0e0f787..cf34073 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationTasksStorage.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationTasksStorage.java
@@ -64,8 +64,6 @@
public class ReplicationTasksStorage {
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
- private boolean disableDeleteForTesting;
-
public static class ReplicateRefUpdate {
public static Optional<ReplicateRefUpdate> createOptionally(Path file) {
try {
@@ -125,11 +123,6 @@
return new Task(r).create();
}
- @VisibleForTesting
- public void disableDeleteForTesting(boolean deleteDisabled) {
- this.disableDeleteForTesting = deleteDisabled;
- }
-
public synchronized void start(UriUpdates uriUpdates) {
for (ReplicateRefUpdate update : uriUpdates.getReplicateRefUpdates()) {
new Task(update).start();
@@ -249,11 +242,6 @@
}
public void finish() {
- if (disableDeleteForTesting) {
- logger.atFine().log("DELETE %s %s DISABLED", running, updateLog());
- return;
- }
-
try {
logger.atFine().log("DELETE %s %s", running, updateLog());
Files.delete(running);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationFanoutIT.java b/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationFanoutIT.java
index f06b933..c32a55d 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationFanoutIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationFanoutIT.java
@@ -86,7 +86,6 @@
storagePath = pluginDataDir.resolve("ref-updates");
tasksStorage = plugin.getSysInjector().getInstance(ReplicationTasksStorage.class);
cleanupReplicationTasks();
- tasksStorage.disableDeleteForTesting(true);
}
@After
@@ -156,13 +155,13 @@
@Test
public void shouldCreateIndividualReplicationTasksForEveryRemoteUrlPair() throws Exception {
List<String> replicaSuffixes = Arrays.asList("replica1", "replica2");
- createTestProject(project + "replica1");
- createTestProject(project + "replica2");
- setReplicationDestination("foo1", replicaSuffixes, ALL_PROJECTS);
- setReplicationDestination("foo2", replicaSuffixes, ALL_PROJECTS);
- config.setInt("remote", "foo1", "replicationDelay", TEST_REPLICATION_DELAY * 100);
- config.setInt("remote", "foo2", "replicationDelay", TEST_REPLICATION_DELAY * 100);
+ FileBasedConfig dest1 = setReplicationDestination("foo1", replicaSuffixes, ALL_PROJECTS);
+ FileBasedConfig dest2 = setReplicationDestination("foo2", replicaSuffixes, ALL_PROJECTS);
+ dest1.setInt("remote", null, "replicationDelay", TEST_REPLICATION_DELAY * 100);
+ dest2.setInt("remote", null, "replicationDelay", TEST_REPLICATION_DELAY * 100);
+ dest1.save();
+ dest2.save();
reloadConfig();
createChange();
@@ -191,7 +190,7 @@
setReplicationDestination(remoteName, Arrays.asList(replicaSuffix), project);
}
- private void setReplicationDestination(
+ private FileBasedConfig setReplicationDestination(
String remoteName, List<String> replicaSuffixes, Optional<String> allProjects)
throws IOException {
FileBasedConfig remoteConfig =
@@ -200,6 +199,7 @@
FS.DETECTED);
setReplicationDestination(remoteConfig, replicaSuffixes, allProjects);
+ return remoteConfig;
}
private void setAutoReload() throws IOException {
diff --git a/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationIT.java b/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationIT.java
index 4fb0387..9a81488 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationIT.java
@@ -76,6 +76,11 @@
Duration.ofSeconds(
(TEST_REPLICATION_DELAY + TEST_REPLICATION_RETRY * 60) * TEST_REPLICATION_MAX_RETRIES
+ 10);
+ private static final int TEST_PROJECT_CREATION_SECONDS = 10;
+
+ private static final Duration TEST_NEW_PROJECT_TIMEOUT =
+ Duration.ofSeconds(
+ (TEST_REPLICATION_DELAY + TEST_REPLICATION_RETRY * 60) + TEST_PROJECT_CREATION_SECONDS);
@Inject private SitePaths sitePaths;
@Inject private ProjectOperations projectOperations;
@@ -108,7 +113,6 @@
tasksStorage = plugin.getSysInjector().getInstance(ReplicationTasksStorage.class);
destinationCollection = plugin.getSysInjector().getInstance(DestinationsCollection.class);
cleanupReplicationTasks();
- tasksStorage.disableDeleteForTesting(true);
}
@Test
@@ -120,7 +124,9 @@
assertThat(listIncompleteTasks("refs/meta/config")).hasSize(1);
- waitUntil(() -> nonEmptyProjectExists(Project.nameKey(sourceProject + "replica.git")));
+ WaitUtil.waitUntil(
+ () -> nonEmptyProjectExists(Project.nameKey(sourceProject + "replica.git")),
+ TEST_NEW_PROJECT_TIMEOUT);
ProjectInfo replicaProject = gApi.projects().name(sourceProject + "replica").get();
assertThat(replicaProject).isNotNull();
@@ -338,8 +344,6 @@
}
private void replicateBranchDeletion(boolean mirror) throws Exception {
- tasksStorage.disableDeleteForTesting(false);
-
setReplicationDestination("foo", "replica", ALL_PROJECTS, mirror);
reloadConfig();
@@ -445,7 +449,6 @@
@Test
public void shouldCleanupTasksAfterNewProjectReplication() throws Exception {
- tasksStorage.disableDeleteForTesting(false);
setReplicationDestination("task_cleanup_project", "replica", ALL_PROJECTS);
config.setInt("remote", "task_cleanup_project", "replicationRetry", 0);
config.save();
@@ -459,7 +462,6 @@
@Test
public void shouldCleanupBothTasksAndLocksAfterNewProjectReplication() throws Exception {
- tasksStorage.disableDeleteForTesting(false);
setReplicationDestination("task_cleanup_locks_project", "replica", ALL_PROJECTS);
config.setInt("remote", "task_cleanup_locks_project", "replicationRetry", 0);
config.save();
@@ -477,7 +479,6 @@
String projectName = "task_cleanup_locks_project_cancelled";
String remoteDestination = "http://invalidurl:9090/";
URIish urish = new URIish(remoteDestination + projectName + ".git");
- tasksStorage.disableDeleteForTesting(false);
setReplicationDestination(projectName, "replica", Optional.of(projectName));
// replace correct urls with invalid one to trigger retry
@@ -524,7 +525,6 @@
String changeRef = createChange().getPatchSet().refName();
- tasksStorage.disableDeleteForTesting(false);
changeReplicationTasksForRemote(tasksStorage.listWaiting().stream(), changeRef, remote1)
.forEach(
(update) -> {
@@ -535,7 +535,6 @@
} catch (URISyntaxException e) {
}
});
- tasksStorage.disableDeleteForTesting(true);
setReplicationDestination(remote1, suffix1, ALL_PROJECTS);
setReplicationDestination(remote2, suffix2, ALL_PROJECTS);