Don't retain uninteresting flag for transaction end
We want to keep traversing beyond the merge transaction to check for
missing events.
Solves: Jira GER-1613
Change-Id: I3d4ca666f61df5e30117b5d7f0062949d0289d4f
diff --git a/src/main/java/com/googlesource/gerrit/plugins/eventseiffel/parsing/UnprocessedCommitsWalker.java b/src/main/java/com/googlesource/gerrit/plugins/eventseiffel/parsing/UnprocessedCommitsWalker.java
index aad049f..fb46d82 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/eventseiffel/parsing/UnprocessedCommitsWalker.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/eventseiffel/parsing/UnprocessedCommitsWalker.java
@@ -297,7 +297,7 @@
}
if (transactionEnd != null
&& eventHub.getExistingId(eventKey.copy(transactionEnd)).isEmpty()) {
- rw.resetRetain(RevFlag.UNINTERESTING, hasScsEventFlag);
+ rw.resetRetain(hasScsEventFlag);
transactionEnd.remove(RevFlag.UNINTERESTING);
rw.markStart(transactionEnd);
rw.sort(RevSort.TOPO);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/eventseiffel/listeners/GerritEventListenersIT.java b/src/test/java/com/googlesource/gerrit/plugins/eventseiffel/listeners/GerritEventListenersIT.java
index f3cede7..ab53d14 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/eventseiffel/listeners/GerritEventListenersIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/eventseiffel/listeners/GerritEventListenersIT.java
@@ -91,7 +91,7 @@
}
@Test
- public void patchSetSubmittedResultsInEvent() throws Exception {
+ public void patchSetSubmittedResultsInEvent_parentHandled() throws Exception {
markMasterAsHandled(SCC);
PushOneCommit.Result res = createChange();
SourceChangeEventKey sccKey = toSccKey(res);
@@ -101,12 +101,56 @@
merge(res);
EventKey scsKey = sccKey.copy(SCS);
EiffelEvent scsEvent = publisher.getPublished(scsKey);
- assertNotNull("Publisher did not find SCS event", sccEvent);
+ assertNotNull("Publisher did not find SCS event", scsEvent);
assertEquals(EventKey.fromEvent(scsEvent), scsKey);
assertScsLinks(Lists.newArrayList(scsParentEventId), sccEvent.meta.id, scsEvent.links);
}
@Test
+ public void patchSetSubmittedResultsInEvents_parentNotHandled() throws Exception {
+ UUID masterSccEventId = markMasterAsHandled(SCC);
+ RevCommit previousMaster = getMaster();
+
+ TestEventListenerConfigProvider.disable();
+
+ PushOneCommit.Result res1 = createChange();
+ SourceChangeEventKey sccKey1 = toSccKey(res1);
+ merge(res1);
+
+ TestEventListenerConfigProvider.enable();
+
+ PushOneCommit.Result res2 = createChange();
+ SourceChangeEventKey sccKey2 = toSccKey(res2);
+
+ EiffelEvent sccEvent1 = publisher.getPublished(sccKey1);
+ assertNotNull("Publisher did not find SCC event1", sccEvent1);
+ assertSccLinks(Lists.newArrayList(masterSccEventId), sccEvent1.links);
+
+ EiffelEvent sccEvent2 = publisher.getPublished(sccKey2);
+ assertNotNull("Publisher did not find SCC event2", sccEvent2);
+ assertSccLinks(Lists.newArrayList(sccEvent1.meta.id), sccEvent2.links);
+
+ merge(res2);
+
+ EiffelEvent masterScsEvent =
+ publisher.getPublished(
+ SourceChangeEventKey.scsKey(project.get(), "master", previousMaster));
+ assertNotNull("Publisher did not find SCS event for master", masterScsEvent);
+
+ EventKey scsKey1 = sccKey1.copy(SCS);
+ EiffelEvent scsEvent1 = publisher.getPublished(scsKey1);
+ assertNotNull("Publisher did not find SCS event", scsEvent1);
+ assertEquals(EventKey.fromEvent(scsEvent1), scsKey1);
+ assertScsLinks(Lists.newArrayList(masterScsEvent.meta.id), sccEvent1.meta.id, scsEvent1.links);
+
+ EventKey scsKey2 = sccKey2.copy(SCS);
+ EiffelEvent scsEvent2 = publisher.getPublished(scsKey2);
+ assertNotNull("Publisher did not find SCS event", scsEvent2);
+ assertEquals(EventKey.fromEvent(scsEvent2), scsKey2);
+ assertScsLinks(Lists.newArrayList(scsEvent1.meta.id), sccEvent2.meta.id, scsEvent2.links);
+ }
+
+ @Test
public void patchSetSubmittedForMetaDoesntResultsInEvent() throws Exception {
PushOneCommit.Result res = createMetaConfigChange();
SourceChangeEventKey sccKey = toSccKey(res);
@@ -219,12 +263,18 @@
}
private UUID markMasterAsHandled(EiffelEventType as) throws Exception {
- git().fetch().setRefSpecs(new RefSpec(RefNames.REFS_HEADS + "master:FETCH_HEAD")).call();
- RevCommit originMaster = getHead(repo(), "FETCH_HEAD");
+ RevCommit originMaster = getMaster();
SourceChangeEventKey scc = SourceChangeEventKey.sccKey(project.get(), "master", originMaster);
return markAsHandled(as.equals(SCS) ? scc.copy(SCS) : scc, originMaster);
}
+ private RevCommit getMaster()
+ throws GitAPIException, InvalidRemoteException, TransportException, Exception {
+ git().fetch().setRefSpecs(new RefSpec(RefNames.REFS_HEADS + "master:FETCH_HEAD")).call();
+ RevCommit originMaster = getHead(repo(), "FETCH_HEAD");
+ return originMaster;
+ }
+
public static class TestEventListenerConfigProvider implements Provider<EventListenersConfig> {
private static boolean enabled;
private static String[] refPatterns;
@@ -251,6 +301,10 @@
enabled = false;
}
+ static void enable() {
+ enabled = true;
+ }
+
@Override
public EventListenersConfig get() {
return new EventListenersConfig(