Notedb: Fix wrong patch set id on upload new patch set

ReceiveCommit with notedb enabled site uses erroneously old patch set
id in ChangeUpdate on upload of new patch set. This bug was hidden
because no tests were enabled that targeting Notedb backend during push
operation. Fix this by enabling standard push tests also for Notedb
configuration.

Test Plan: When approval provided during push operation by passing
-l parameter to magic branch, verify that the approval is referencing
the right patch set. That means, pushing a change with %l=Code-Review+1
and uploading a subsequent patch set with %l=Code-Review+2 produces the
following commits on meta branch:

Uploaded patch set 1.

Patch-set: 1
Label: Code-Review=+1

Uploaded patch set 2.

Patch-set: 2
Label: Code-Review=+2

Without this change the last two lines are:

Patch-set: 1
Label: Code-Review=+2

and as result the test: testPushForMasterWithApprovals() was failing
because CRVW+2 was referencing wrong patch set (1 instead of 2).

Change-Id: I231e736a3d5f44555b1c2e4bdb5ef43be035c624
This commit is contained in:
David Ostrovsky 2014-09-23 22:39:00 +02:00 committed by Dave Borowitz
parent 88e33ac9f1
commit 5bba6faf32
2 changed files with 9 additions and 0 deletions

View File

@ -24,17 +24,25 @@ import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.LabelInfo;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.notedb.NotesMigration;
import com.google.gerrit.testutil.ConfigSuite;
import com.google.gwtorm.server.OrmException;
import com.jcraft.jsch.JSchException;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Config;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
public abstract class AbstractPushForReview extends AbstractDaemonTest {
@ConfigSuite.Config
public static Config noteDbEnabled() {
return NotesMigration.allEnabledConfig();
}
protected enum Protocol {
SSH, HTTP
}

View File

@ -2045,6 +2045,7 @@ public class ReceiveCommits {
recipients.remove(me);
ChangeUpdate update = updateFactory.create(changeCtl, newPatchSet.getCreatedOn());
update.setPatchSetId(newPatchSet.getId());
db.changes().beginTransaction(change.getId());
try {
change = db.changes().get(change.getId());