use of com.google.gerrit.reviewdb.client.Change in project gerrit by GerritCodeReview.
the class ChangeRebuilderIT method rebuilderRespectsReadOnlyInNoteDbChangeState.
@Test
public void rebuilderRespectsReadOnlyInNoteDbChangeState() throws Exception {
TestTimeUtil.resetWithClockStep(1, SECONDS);
PushOneCommit.Result r = createChange();
PatchSet.Id psId1 = r.getPatchSetId();
Change.Id id = psId1.getParentKey();
checker.rebuildAndCheckChanges(id);
setNotesMigration(true, true);
ReviewDb db = getUnwrappedDb();
Change c = db.changes().get(id);
NoteDbChangeState state = NoteDbChangeState.parse(c);
Timestamp until = new Timestamp(TimeUtil.nowMs() + MILLISECONDS.convert(1, DAYS));
state = state.withReadOnlyUntil(until);
c.setNoteDbState(state.toString());
db.changes().update(Collections.singleton(c));
try {
rebuilderWrapper.rebuild(db, id);
assert_().fail("expected rebuild to fail");
} catch (OrmRuntimeException e) {
assertThat(e.getMessage()).contains("read-only until");
}
TestTimeUtil.setClock(new Timestamp(until.getTime() + MILLISECONDS.convert(1, SECONDS)));
rebuilderWrapper.rebuild(db, id);
}
use of com.google.gerrit.reviewdb.client.Change in project gerrit by GerritCodeReview.
the class NoteDbPrimaryIT method migrateToNoteDbFailsRebuildingOnceAndRetries.
@Test
public void migrateToNoteDbFailsRebuildingOnceAndRetries() throws Exception {
Change.Id id = createChange().getChange().getId();
Change c = db.changes().get(id);
c.setNoteDbState("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef");
db.changes().update(Collections.singleton(c));
rebuilderWrapper.failNextUpdate();
migrator = newMigrator(RetryerBuilder.<NoteDbChangeState>newBuilder().retryIfException().withStopStrategy(StopStrategies.neverStop()).build());
migrator.migrateToNoteDbPrimary(id);
assertNoteDbPrimary(id);
}
use of com.google.gerrit.reviewdb.client.Change in project gerrit by GerritCodeReview.
the class NoteDbPrimaryIT method migrateToNoteDbWithRebuildingFirst.
@Test
public void migrateToNoteDbWithRebuildingFirst() throws Exception {
PushOneCommit.Result r = createChange();
Change.Id id = r.getChange().getId();
Change c = db.changes().get(id);
c.setNoteDbState("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef");
db.changes().update(Collections.singleton(c));
testMigrateToNoteDb(id);
}
use of com.google.gerrit.reviewdb.client.Change in project gerrit by GerritCodeReview.
the class NoteDbPrimaryIT method migrateToNoteDbMissingOldState.
@Test
public void migrateToNoteDbMissingOldState() throws Exception {
PushOneCommit.Result r = createChange();
Change.Id id = r.getChange().getId();
Change c = db.changes().get(id);
c.setNoteDbState(null);
db.changes().update(Collections.singleton(c));
exception.expect(OrmRuntimeException.class);
exception.expectMessage("no note_db_state");
migrator.migrateToNoteDbPrimary(id);
}
use of com.google.gerrit.reviewdb.client.Change in project gerrit by GerritCodeReview.
the class NoteDbPrimaryIT method migrateToNoteDbAlreadyReadOnly.
@Test
public void migrateToNoteDbAlreadyReadOnly() throws Exception {
PushOneCommit.Result r = createChange();
Change.Id id = r.getChange().getId();
Change c = db.changes().get(id);
NoteDbChangeState state = NoteDbChangeState.parse(c);
Timestamp until = new Timestamp(TimeUtil.nowMs() + MILLISECONDS.convert(1, DAYS));
state = state.withReadOnlyUntil(until);
c.setNoteDbState(state.toString());
db.changes().update(Collections.singleton(c));
exception.expect(OrmRuntimeException.class);
exception.expectMessage("read-only until " + until);
migrator.migrateToNoteDbPrimary(id);
}
Aggregations