ReplicationFanoutIT: Cleanup shouldCreateIndividualReplicationTasksForEveryRemoteUrlPair Remove some dead code, use Integer.MAX_VALUE for the replicationDelay so that tasks stay in the waiting/ area of storage for the entire test, and use a dedicated listWaitingTasks() to show it only depends on tasks in that state. Change-Id: I0035a4edc656ed4833249322c45204124a66e20d
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 c32a55d..30c3a2b 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationFanoutIT.java +++ b/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationFanoutIT.java
@@ -158,18 +158,15 @@ 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.setInt("remote", null, "replicationDelay", Integer.MAX_VALUE); + dest2.setInt("remote", null, "replicationDelay", Integer.MAX_VALUE); dest1.save(); dest2.save(); reloadConfig(); createChange(); - assertThat(listIncompleteTasks("refs/changes/\\d*/\\d*/\\d*")).hasSize(4); - - setReplicationDestination("foo1", replicaSuffixes, ALL_PROJECTS); - setReplicationDestination("foo2", replicaSuffixes, ALL_PROJECTS); + assertThat(listWaitingTasks("refs/changes/\\d*/\\d*/\\d*")).hasSize(4); } private Ref getRef(Repository repo, String branchName) throws IOException { @@ -242,6 +239,13 @@ return projectOperations.newProject().name(name).create(); } + private List<ReplicateRefUpdate> listWaitingTasks(String refRegex) { + Pattern refmaskPattern = Pattern.compile(refRegex); + return tasksStorage.listWaiting().stream() + .filter(task -> refmaskPattern.matcher(task.ref).matches()) + .collect(toList()); + } + @SuppressWarnings( "SynchronizeOnNonFinalField") // tasksStorage is non-final but only set in setUpTestPlugin() private List<ReplicateRefUpdate> listIncompleteTasks(String refRegex) {