Merge changes from topic 'draft-ref-sharding'

* changes:
  Shard refs/draft-comments/* by change instead of account ID
  Move method for parsing ref parts (CD/ABCD/...) to RefNames
  AccountTest: Convert to Truth
  Move ChangeNoteUtil#changeRefName to RefNames
This commit is contained in:
Dave Borowitz
2016-05-04 13:33:33 +00:00
committed by Gerrit Code Review
20 changed files with 233 additions and 186 deletions

View File

@@ -15,8 +15,8 @@
package com.google.gerrit.server.notedb;
import static com.google.common.truth.Truth.assertThat;
import static com.google.gerrit.reviewdb.client.RefNames.changeMetaRef;
import static com.google.gerrit.reviewdb.client.RefNames.refsDraftComments;
import static com.google.gerrit.server.notedb.ChangeNoteUtil.changeRefName;
import static com.google.gerrit.server.notedb.ReviewerStateInternal.CC;
import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
import static com.google.gerrit.testutil.TestChanges.incrementPatchSet;
@@ -526,7 +526,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
@Test
public void emptyChangeUpdate() throws Exception {
Change c = newChange();
Ref initial = repo.exactRef(changeRefName(c.getId()));
Ref initial = repo.exactRef(changeMetaRef(c.getId()));
assertThat(initial).isNotNull();
// Empty update doesn't create a new commit.
@@ -534,7 +534,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit();
assertThat(update.getResult()).isNull();
Ref updated = repo.exactRef(changeRefName(c.getId()));
Ref updated = repo.exactRef(changeMetaRef(c.getId()));
assertThat(updated.getObjectId()).isEqualTo(initial.getObjectId());
}
@@ -1930,8 +1930,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.putComment(comment);
update.commit();
assertThat(repo.exactRef(changeRefName(c.getId()))).isNotNull();
String draftRef = refsDraftComments(otherUser.getAccountId(), c.getId());
assertThat(repo.exactRef(changeMetaRef(c.getId()))).isNotNull();
String draftRef = refsDraftComments(c.getId(), otherUser.getAccountId());
assertThat(exactRefAllUsers(draftRef)).isNull();
}
@@ -1953,7 +1953,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.putComment(draft);
update.commit();
String draftRef = refsDraftComments(otherUser.getAccountId(), c.getId());
String draftRef = refsDraftComments(c.getId(), otherUser.getAccountId());
ObjectId old = exactRefAllUsers(draftRef);
assertThat(old).isNotNull();
@@ -2127,7 +2127,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.putComment(comment2);
update.commit();
String refName = refsDraftComments(otherUserId, c.getId());
String refName = refsDraftComments(c.getId(), otherUserId);
ObjectId oldDraftId = exactRefAllUsers(refName);
update = newUpdate(c, otherUser);

View File

@@ -20,12 +20,12 @@ import com.google.common.base.Joiner;
import com.google.common.collect.Iterables;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.reviewdb.server.ReviewDbUtil;
import com.google.gerrit.server.PatchLineCommentsUtil;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.notedb.ChangeBundle;
import com.google.gerrit.server.notedb.ChangeNoteUtil;
import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.notedb.ChangeRebuilder;
import com.google.gerrit.server.schema.DisabledChangesReviewDbWrapper;
@@ -118,8 +118,7 @@ public class NoteDbChecker {
public void assertNoChangeRef(Project.NameKey project, Change.Id changeId)
throws Exception {
try (Repository repo = repoManager.openRepository(project)) {
assertThat(repo.exactRef(ChangeNoteUtil.changeRefName(changeId)))
.isNull();
assertThat(repo.exactRef(RefNames.changeMetaRef(changeId))).isNull();
}
}