Search in sources :

Example 71 with PatchSet

use of com.google.gerrit.reviewdb.client.PatchSet in project gerrit by GerritCodeReview.

the class ConsistencyCheckerIT method patchSetObjectAndRefMissingWithFix.

@Test
public void patchSetObjectAndRefMissingWithFix() throws Exception {
    String rev = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
    ChangeControl ctl = insertChange();
    PatchSet ps = insertMissingPatchSet(ctl, rev);
    ctl = reload(ctl);
    String refName = ps.getId().toRefName();
    assertProblems(ctl, new FixInput(), problem("Ref missing: " + refName), problem("Object missing: patch set 2: " + rev));
}
Also used : ChangeControl(com.google.gerrit.server.project.ChangeControl) TestChanges.newPatchSet(com.google.gerrit.testutil.TestChanges.newPatchSet) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) FixInput(com.google.gerrit.extensions.api.changes.FixInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 72 with PatchSet

use of com.google.gerrit.reviewdb.client.PatchSet in project gerrit by GerritCodeReview.

the class ConsistencyCheckerIT method patchSetMultipleObjectsMissingWithDeletingPatchSets.

@Test
public void patchSetMultipleObjectsMissingWithDeletingPatchSets() throws Exception {
    ChangeControl ctl = insertChange();
    PatchSet ps1 = psUtil.current(db, ctl.getNotes());
    String rev2 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
    PatchSet ps2 = insertMissingPatchSet(ctl, rev2);
    ctl = incrementPatchSet(reload(ctl));
    PatchSet ps3 = psUtil.current(db, ctl.getNotes());
    String rev4 = "c0ffeeeec0ffeeeec0ffeeeec0ffeeeec0ffeeee";
    PatchSet ps4 = insertMissingPatchSet(ctl, rev4);
    ctl = reload(ctl);
    FixInput fix = new FixInput();
    fix.deletePatchSetIfCommitMissing = true;
    assertProblems(ctl, fix, problem("Ref missing: " + ps2.getId().toRefName()), problem("Object missing: patch set 2: " + rev2, FIXED, "Deleted patch set"), problem("Ref missing: " + ps4.getId().toRefName()), problem("Object missing: patch set 4: " + rev4, FIXED, "Deleted patch set"));
    ctl = reload(ctl);
    assertThat(ctl.getChange().currentPatchSetId().get()).isEqualTo(3);
    assertThat(psUtil.get(db, ctl.getNotes(), ps1.getId())).isNotNull();
    assertThat(psUtil.get(db, ctl.getNotes(), ps2.getId())).isNull();
    assertThat(psUtil.get(db, ctl.getNotes(), ps3.getId())).isNotNull();
    assertThat(psUtil.get(db, ctl.getNotes(), ps4.getId())).isNull();
}
Also used : ChangeControl(com.google.gerrit.server.project.ChangeControl) TestChanges.newPatchSet(com.google.gerrit.testutil.TestChanges.newPatchSet) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) FixInput(com.google.gerrit.extensions.api.changes.FixInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 73 with PatchSet

use of com.google.gerrit.reviewdb.client.PatchSet in project gerrit by GerritCodeReview.

the class ConsistencyCheckerIT method onlyPatchSetObjectMissingWithFix.

@Test
public void onlyPatchSetObjectMissingWithFix() throws Exception {
    Change c = TestChanges.newChange(project, admin.getId(), sequences.nextChangeId());
    PatchSet.Id psId = c.currentPatchSetId();
    String rev = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
    PatchSet ps = newPatchSet(psId, rev, adminId);
    if (notesMigration.changePrimaryStorage() == PrimaryStorage.REVIEW_DB) {
        db.changes().insert(singleton(c));
        db.patchSets().insert(singleton(ps));
    }
    addNoteDbCommit(c.getId(), "Create change\n" + "\n" + "Patch-set: 1\n" + "Branch: " + c.getDest().get() + "\n" + "Change-id: " + c.getKey().get() + "\n" + "Subject: Bogus subject\n" + "Commit: " + rev + "\n" + "Groups: " + rev + "\n");
    indexer.index(db, c.getProject(), c.getId());
    IdentifiedUser user = userFactory.create(admin.getId());
    ChangeControl ctl = changeControlFactory.controlFor(db, c.getProject(), c.getId(), user);
    FixInput fix = new FixInput();
    fix.deletePatchSetIfCommitMissing = true;
    assertProblems(ctl, fix, problem("Ref missing: " + ps.getId().toRefName()), problem("Object missing: patch set 1: " + rev, FIX_FAILED, "Cannot delete patch set; no patch sets would remain"));
    ctl = reload(ctl);
    assertThat(ctl.getChange().currentPatchSetId().get()).isEqualTo(1);
    assertThat(psUtil.current(db, ctl.getNotes())).isNotNull();
}
Also used : ChangeControl(com.google.gerrit.server.project.ChangeControl) TestChanges.newPatchSet(com.google.gerrit.testutil.TestChanges.newPatchSet) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) Change(com.google.gerrit.reviewdb.client.Change) FixInput(com.google.gerrit.extensions.api.changes.FixInput) IdentifiedUser(com.google.gerrit.server.IdentifiedUser) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 74 with PatchSet

use of com.google.gerrit.reviewdb.client.PatchSet in project gerrit by GerritCodeReview.

the class ConsistencyCheckerIT method patchSetObjectAndRefMissing.

// No test for ref existing but object missing; InMemoryRepository won't let
// us do such a thing.
@Test
public void patchSetObjectAndRefMissing() throws Exception {
    String rev = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
    ChangeControl ctl = insertChange();
    PatchSet ps = insertMissingPatchSet(ctl, rev);
    ctl = reload(ctl);
    assertProblems(ctl, null, problem("Ref missing: " + ps.getId().toRefName()), problem("Object missing: patch set 2: deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"));
}
Also used : ChangeControl(com.google.gerrit.server.project.ChangeControl) TestChanges.newPatchSet(com.google.gerrit.testutil.TestChanges.newPatchSet) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 75 with PatchSet

use of com.google.gerrit.reviewdb.client.PatchSet in project gerrit by GerritCodeReview.

the class ConsistencyCheckerIT method patchSetObjectAndRefMissingWithDeletingPatchSet.

@Test
public void patchSetObjectAndRefMissingWithDeletingPatchSet() throws Exception {
    ChangeControl ctl = insertChange();
    PatchSet ps1 = psUtil.current(db, ctl.getNotes());
    String rev2 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
    PatchSet ps2 = insertMissingPatchSet(ctl, rev2);
    ctl = reload(ctl);
    FixInput fix = new FixInput();
    fix.deletePatchSetIfCommitMissing = true;
    assertProblems(ctl, fix, problem("Ref missing: " + ps2.getId().toRefName()), problem("Object missing: patch set 2: " + rev2, FIXED, "Deleted patch set"));
    ctl = reload(ctl);
    assertThat(ctl.getChange().currentPatchSetId().get()).isEqualTo(1);
    assertThat(psUtil.get(db, ctl.getNotes(), ps1.getId())).isNotNull();
    assertThat(psUtil.get(db, ctl.getNotes(), ps2.getId())).isNull();
}
Also used : ChangeControl(com.google.gerrit.server.project.ChangeControl) TestChanges.newPatchSet(com.google.gerrit.testutil.TestChanges.newPatchSet) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) FixInput(com.google.gerrit.extensions.api.changes.FixInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

PatchSet (com.google.gerrit.reviewdb.client.PatchSet)124 Change (com.google.gerrit.reviewdb.client.Change)51 Test (org.junit.Test)44 ObjectId (org.eclipse.jgit.lib.ObjectId)35 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)27 RevCommit (org.eclipse.jgit.revwalk.RevCommit)26 Repository (org.eclipse.jgit.lib.Repository)21 RevId (com.google.gerrit.reviewdb.client.RevId)20 ChangeControl (com.google.gerrit.server.project.ChangeControl)20 ChangeData (com.google.gerrit.server.query.change.ChangeData)19 OrmException (com.google.gwtorm.server.OrmException)19 Timestamp (java.sql.Timestamp)18 RevWalk (org.eclipse.jgit.revwalk.RevWalk)15 Project (com.google.gerrit.reviewdb.client.Project)14 PatchSetApproval (com.google.gerrit.reviewdb.client.PatchSetApproval)11 TestChanges.newPatchSet (com.google.gerrit.testutil.TestChanges.newPatchSet)11 IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)11 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)10 Account (com.google.gerrit.reviewdb.client.Account)10