Fix ConsistencyCheckerIT in NoteDbMode.CHECK
Mostly this amounts to skipping the tests that are explicitly testing impossible conditions under NoteDb, like a missing repo. These cases are already handled analogously (i.e. skipped with a warning) in the live migration path. In one case we need to slightly massage a Change that we are manually inserting into ReviewDb to make it match NoteDb. Change-Id: Ieaeaf8e75b66be52d04ce2fc1e7a8ce767f39dff
This commit is contained in:
@@ -54,6 +54,7 @@ import com.google.gerrit.server.update.BatchUpdateOp;
|
|||||||
import com.google.gerrit.server.update.ChangeContext;
|
import com.google.gerrit.server.update.ChangeContext;
|
||||||
import com.google.gerrit.server.update.RepoContext;
|
import com.google.gerrit.server.update.RepoContext;
|
||||||
import com.google.gerrit.testutil.InMemoryRepositoryManager;
|
import com.google.gerrit.testutil.InMemoryRepositoryManager;
|
||||||
|
import com.google.gerrit.testutil.NoteDbMode;
|
||||||
import com.google.gerrit.testutil.TestChanges;
|
import com.google.gerrit.testutil.TestChanges;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
@@ -95,6 +96,11 @@ public class ConsistencyCheckerIT extends AbstractDaemonTest {
|
|||||||
private Account.Id adminId;
|
private Account.Id adminId;
|
||||||
private ConsistencyChecker checker;
|
private ConsistencyChecker checker;
|
||||||
|
|
||||||
|
private void assumeNoteDbDisabled() {
|
||||||
|
assume().that(notesMigration.readChanges()).isFalse();
|
||||||
|
assume().that(NoteDbMode.get()).isNotEqualTo(NoteDbMode.CHECK);
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
// Ignore client clone of project; repurpose as server-side TestRepository.
|
// Ignore client clone of project; repurpose as server-side TestRepository.
|
||||||
@@ -128,7 +134,7 @@ public class ConsistencyCheckerIT extends AbstractDaemonTest {
|
|||||||
@Test
|
@Test
|
||||||
public void missingRepo() throws Exception {
|
public void missingRepo() throws Exception {
|
||||||
// NoteDb can't have a change without a repo.
|
// NoteDb can't have a change without a repo.
|
||||||
assume().that(notesMigration.readChanges()).isFalse();
|
assumeNoteDbDisabled();
|
||||||
|
|
||||||
ChangeControl ctl = insertChange();
|
ChangeControl ctl = insertChange();
|
||||||
Project.NameKey name = ctl.getProject().getNameKey();
|
Project.NameKey name = ctl.getProject().getNameKey();
|
||||||
@@ -141,7 +147,7 @@ public class ConsistencyCheckerIT extends AbstractDaemonTest {
|
|||||||
public void invalidRevision() throws Exception {
|
public void invalidRevision() throws Exception {
|
||||||
// NoteDb always parses the revision when inserting a patch set, so we can't
|
// NoteDb always parses the revision when inserting a patch set, so we can't
|
||||||
// create an invalid patch set.
|
// create an invalid patch set.
|
||||||
assume().that(notesMigration.readChanges()).isFalse();
|
assumeNoteDbDisabled();
|
||||||
|
|
||||||
ChangeControl ctl = insertChange();
|
ChangeControl ctl = insertChange();
|
||||||
PatchSet ps =
|
PatchSet ps =
|
||||||
@@ -272,6 +278,10 @@ public class ConsistencyCheckerIT extends AbstractDaemonTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onlyPatchSetObjectMissingWithFix() throws Exception {
|
public void onlyPatchSetObjectMissingWithFix() throws Exception {
|
||||||
Change c = TestChanges.newChange(project, admin.getId(), sequences.nextChangeId());
|
Change c = TestChanges.newChange(project, admin.getId(), sequences.nextChangeId());
|
||||||
|
|
||||||
|
// Set review started, mimicking Schema_153, so tests pass with NoteDbMode.CHECK.
|
||||||
|
c.setReviewStarted(true);
|
||||||
|
|
||||||
PatchSet.Id psId = c.currentPatchSetId();
|
PatchSet.Id psId = c.currentPatchSetId();
|
||||||
String rev = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
|
String rev = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
|
||||||
PatchSet ps = newPatchSet(psId, rev, adminId);
|
PatchSet ps = newPatchSet(psId, rev, adminId);
|
||||||
@@ -321,7 +331,7 @@ public class ConsistencyCheckerIT extends AbstractDaemonTest {
|
|||||||
@Test
|
@Test
|
||||||
public void currentPatchSetMissing() throws Exception {
|
public void currentPatchSetMissing() throws Exception {
|
||||||
// NoteDb can't create a change without a patch set.
|
// NoteDb can't create a change without a patch set.
|
||||||
assume().that(notesMigration.readChanges()).isFalse();
|
assumeNoteDbDisabled();
|
||||||
|
|
||||||
ChangeControl ctl = insertChange();
|
ChangeControl ctl = insertChange();
|
||||||
db.patchSets().deleteKeys(singleton(ctl.getChange().currentPatchSetId()));
|
db.patchSets().deleteKeys(singleton(ctl.getChange().currentPatchSetId()));
|
||||||
|
|||||||
Reference in New Issue
Block a user