ReplicationFanoutIT: Fix invalid replicationDelay setting
Setting config values for a remote in replication.config vs the remote's
own config file results in the replication.config values being ignored.
Fix this by setting the values in each remote's config file.
This test had delays added to avoid any flakiness, but the delays
weren't working because of this issue. While the test generally passes,
the delay makes it safer from races.
Change-Id: I4de52425d9b22237c055bfd39f1b852d63d75d2c
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..858fd60 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationFanoutIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationFanoutIT.java
@@ -156,13 +156,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 +191,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 +200,7 @@
FS.DETECTED);
setReplicationDestination(remoteConfig, replicaSuffixes, allProjects);
+ return remoteConfig;
}
private void setAutoReload() throws IOException {