Merge branch 'stable-3.3' * stable-3.3: Consume scheduled replication events Add gerrit CI validation Change-Id: I48d482a037aaa926db2a62c1ca14082de9dbd907
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replicationstatus/EventHandler.java b/src/main/java/com/googlesource/gerrit/plugins/replicationstatus/EventHandler.java index 28ed600..a2e708f 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replicationstatus/EventHandler.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replicationstatus/EventHandler.java
@@ -25,8 +25,8 @@ import com.google.gerrit.server.events.RefEvent; import com.google.inject.Inject; import com.google.inject.name.Named; -import com.googlesource.gerrit.plugins.replication.RefReplicatedEvent; -import com.googlesource.gerrit.plugins.replication.ReplicationScheduledEvent; +import com.googlesource.gerrit.plugins.replication.events.RefReplicatedEvent; +import com.googlesource.gerrit.plugins.replication.events.ReplicationScheduledEvent; class EventHandler implements EventListener { private final Cache<ReplicationStatus.Key, ReplicationStatus> replicationStatusCache; @@ -46,10 +46,10 @@ if (shouldConsume(event)) { if (event instanceof RefReplicatedEvent) { RefReplicatedEvent replEvent = (RefReplicatedEvent) event; - putCacheEntry(replEvent, replEvent.targetNode, replEvent.status); + putCacheEntry(replEvent, replEvent.targetUri, replEvent.status); } else if (event instanceof ReplicationScheduledEvent) { ReplicationScheduledEvent replEvent = (ReplicationScheduledEvent) event; - putCacheEntry(replEvent, replEvent.targetNode, SCHEDULED.name()); + putCacheEntry(replEvent, replEvent.targetUri, SCHEDULED.name()); } } }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/replicationstatus/ReplicationStatusIT.java b/src/test/java/com/googlesource/gerrit/plugins/replicationstatus/ReplicationStatusIT.java index e27fd78..2dc81f1 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/replicationstatus/ReplicationStatusIT.java +++ b/src/test/java/com/googlesource/gerrit/plugins/replicationstatus/ReplicationStatusIT.java
@@ -37,13 +37,14 @@ import com.google.gerrit.server.config.SitePaths; import com.google.gson.Gson; import com.google.inject.Inject; -import com.googlesource.gerrit.plugins.replication.RefReplicatedEvent; -import com.googlesource.gerrit.plugins.replication.ReplicationScheduledEvent; +import com.googlesource.gerrit.plugins.replication.events.RefReplicatedEvent; +import com.googlesource.gerrit.plugins.replication.events.ReplicationScheduledEvent; import java.io.IOException; import java.net.URISyntaxException; import java.util.Collections; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.transport.RemoteRefUpdate; +import org.eclipse.jgit.transport.URIish; import org.junit.Before; import org.junit.Test; @@ -216,9 +217,10 @@ String ref, String remote, RefPushResult status, - RemoteRefUpdate.Status refStatus) { + RemoteRefUpdate.Status refStatus) + throws URISyntaxException { RefReplicatedEvent replicatedEvent = - new RefReplicatedEvent(project.get(), ref, remote, status, refStatus); + new RefReplicatedEvent(project.get(), ref, new URIish(remote), status, refStatus); replicatedEvent.instanceId = instanceId; replicatedEvent.eventCreatedOn = when; @@ -226,9 +228,9 @@ } private ReplicationScheduledEvent scheduledEvent( - @Nullable String instanceId, long when, String ref, String remote) { + @Nullable String instanceId, long when, String ref, String remote) throws URISyntaxException { ReplicationScheduledEvent scheduledEvent = - new ReplicationScheduledEvent(project.get(), ref, remote); + new ReplicationScheduledEvent(project.get(), ref, new URIish(remote)); scheduledEvent.instanceId = instanceId; scheduledEvent.eventCreatedOn = when; @@ -236,7 +238,7 @@ } private RefReplicatedEvent successReplicatedEvent( - @Nullable String instanceId, long when, String remoteUrl) { + @Nullable String instanceId, long when, String remoteUrl) throws URISyntaxException { return replicatedEvent( instanceId, @@ -248,7 +250,7 @@ } private RefReplicatedEvent failedReplicatedEvent( - @Nullable String instanceId, long when, String remoteUrl) { + @Nullable String instanceId, long when, String remoteUrl) throws URISyntaxException { return replicatedEvent( instanceId,