From 25d033177ee5bb3a991a38e054f3bcf4011b9762 Mon Sep 17 00:00:00 2001 From: Gal Paikin Date: Mon, 30 Mar 2020 14:29:46 +0200 Subject: [PATCH] Fix flaky test in CreateMergePatchSet ChangeIT#createMergePatchSet was flaky. For some reason, even though the patchset was created, after the second creation (e.g previously line 3245) one of the followings happened around 50% of the times: 1. changeInfo.revisions contained 3 revisions, instead of 2. 2. changeInfo.currentRevision was null. Another finding was that when I removed the flag CURRENT_COMMIT, none of those bugs occurred. One theory is that something is really wrong with creating a merge patchset with the same parent: The change in "dev" is both a parent and a grandparent of the change in line 3245. This should be investigated further, but this change only fixes the flaky test. Change-Id: Iff2bec4f74163f3634fbbc3dfbe996382a7c91e6 --- .../acceptance/api/change/ChangeIT.java | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java b/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java index 50aaa27c98..fd681d8275 100644 --- a/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java +++ b/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java @@ -3238,13 +3238,33 @@ public class ChangeIT extends AbstractDaemonTest { assertThat(changeInfo.revisions.get(changeInfo.currentRevision).commit.message) .contains(subject); + } - // No subject: reuse message from previous patchset. + @Test + public void createMergePatchSet_SubjectCarriesOverByDefault() throws Exception { + RevCommit initialHead = projectOperations.project(project).getHead("master"); + createBranch("dev"); + + // create a change for master + PushOneCommit.Result result = createChange(); + String changeId = result.getChangeId(); + String subject = result.getChange().change().getSubject(); + + // push a commit into dev branch + testRepo.reset(initialHead); + PushOneCommit.Result pushResult = + pushFactory.create(user.newIdent(), testRepo).to("refs/heads/dev"); + pushResult.assertOkStatus(); + MergeInput mergeInput = new MergeInput(); + mergeInput.source = "dev"; + MergePatchSetInput in = new MergePatchSetInput(); + in.merge = mergeInput; in.subject = null; + + // Ensure subject carries over gApi.changes().id(changeId).createMergePatchSet(in); - changeInfo = gApi.changes().id(changeId).get(ALL_REVISIONS, CURRENT_COMMIT, CURRENT_REVISION); - assertThat(changeInfo.revisions.get(changeInfo.currentRevision).commit.message) - .contains(subject); + ChangeInfo changeInfo = gApi.changes().id(changeId).get(); + assertThat(changeInfo.subject).isEqualTo(subject); } @Test