summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNasser Grainawi <nasser@codeaurora.org>2021-02-25 12:04:08 -0700
committerNasser Grainawi <nasser@codeaurora.org>2021-02-25 12:04:08 -0700
commit17e8c41d5e7b83c419a52a6f7da0ad3ade514f76 (patch)
treea2dcc84af4f528f8ee76fc5c58f4d164c5c1d5a7
parent2f29ef1c4c7c9893af0638ebc575cbd4b369118c (diff)
parent16d00cdf95a0e04db345512fcd48c8ec3d867449 (diff)
Merge branch 'stable-3.0' into stable-3.1v3.1.16v3.1.15v3.1.14v3.1.13upstream/stable-3.1
* stable-3.0: Call retryDone() when giving up after lock failures Fix issue with task cleanup after retry Change-Id: Id9ce63cd6112b3c8b16f9daafe3a8a982521baa9
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java1
-rw-r--r--src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationStorageIT.java33
2 files changed, 18 insertions, 16 deletions
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
index cbd2899..e63a350 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
@@ -411,6 +411,7 @@ class PushOne implements ProjectRunnable, CanceledWhileRunning, UriUpdates {
pool.reschedule(this, Destination.RetryReason.TRANSPORT_ERROR);
}
} else {
+ retryDone();
repLog.error(
"Giving up after {} '{}' failures during replication to {}",
updateRefRetryCount,
diff --git a/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationStorageIT.java b/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationStorageIT.java
index 88b8f87..67c04b2 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationStorageIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationStorageIT.java
@@ -45,7 +45,8 @@ import org.junit.Test;
name = "replication",
sysModule = "com.googlesource.gerrit.plugins.replication.ReplicationModule")
public class ReplicationStorageIT extends ReplicationDaemon {
- private static final int TEST_TASK_FINISH_SECONDS = 1;
+ protected static final int TEST_TASK_FINISH_SECONDS = 1;
+ protected static final int TEST_REPLICATION_MAX_RETRIES = 1;
protected static final Duration TEST_TASK_FINISH_TIMEOUT =
Duration.ofSeconds(TEST_TASK_FINISH_SECONDS);
protected ReplicationTasksStorage tasksStorage;
@@ -254,6 +255,21 @@ public class ReplicationStorageIT extends ReplicationDaemon {
replicateBranchDeletion(false);
}
+ @Test
+ public void shouldCleanupTasksAfterNewProjectReplication() throws Exception {
+ setReplicationDestination("task_cleanup_project", "replica", ALL_PROJECTS);
+ config.setInt("remote", "task_cleanup_project", "replicationRetry", 0);
+ config.save();
+ reloadConfig();
+ assertThat(tasksStorage.listRunning()).hasSize(0);
+ Project.NameKey sourceProject = createTestProject("task_cleanup_project");
+
+ WaitUtil.waitUntil(
+ () -> nonEmptyProjectExists(Project.nameKey(sourceProject + "replica.git")),
+ TEST_NEW_PROJECT_TIMEOUT);
+ WaitUtil.waitUntil(() -> tasksStorage.listRunning().size() == 0, TEST_TASK_FINISH_TIMEOUT);
+ }
+
private void replicateBranchDeletion(boolean mirror) throws Exception {
setReplicationDestination("foo", "replica", ALL_PROJECTS);
reloadConfig();
@@ -274,21 +290,6 @@ public class ReplicationStorageIT extends ReplicationDaemon {
assertThat(listWaitingReplicationTasks(branchToDelete)).hasSize(1);
}
- @Test
- public void shouldCleanupTasksAfterNewProjectReplication() throws Exception {
- setReplicationDestination("task_cleanup_project", "replica", ALL_PROJECTS);
- config.setInt("remote", "task_cleanup_project", "replicationRetry", 0);
- config.save();
- reloadConfig();
- assertThat(tasksStorage.listRunning()).hasSize(0);
- Project.NameKey sourceProject = createTestProject("task_cleanup_project");
-
- WaitUtil.waitUntil(
- () -> nonEmptyProjectExists(Project.nameKey(sourceProject + "replica.git")),
- TEST_NEW_PROJECT_TIMEOUT);
- WaitUtil.waitUntil(() -> tasksStorage.listRunning().size() == 0, TEST_TASK_FINISH_TIMEOUT);
- }
-
private Stream<ReplicateRefUpdate> waitingChangeReplicationTasksForRemote(
String changeRef, String remote) {
return tasksStorage.listWaiting().stream()