Search in sources :

Example 1 with OneOffRequestContext

use of com.google.gerrit.server.util.OneOffRequestContext in project gerrit by GerritCodeReview.

the class GerritServer method checkNoteDbState.

private void checkNoteDbState() throws Exception {
    NoteDbMode mode = NoteDbMode.get();
    if (mode != NoteDbMode.CHECK && mode != NoteDbMode.PRIMARY) {
        return;
    }
    NoteDbChecker checker = testInjector.getInstance(NoteDbChecker.class);
    OneOffRequestContext oneOffRequestContext = testInjector.getInstance(OneOffRequestContext.class);
    try (ManualRequestContext ctx = oneOffRequestContext.open()) {
        if (mode == NoteDbMode.CHECK) {
            checker.rebuildAndCheckAllChanges();
        } else if (mode == NoteDbMode.PRIMARY) {
            checker.assertNoReviewDbChanges(desc.testDescription());
        }
    }
}
Also used : NoteDbChecker(com.google.gerrit.testutil.NoteDbChecker) ManualRequestContext(com.google.gerrit.server.util.ManualRequestContext) NoteDbMode(com.google.gerrit.testutil.NoteDbMode) OneOffRequestContext(com.google.gerrit.server.util.OneOffRequestContext)

Aggregations

ManualRequestContext (com.google.gerrit.server.util.ManualRequestContext)1 OneOffRequestContext (com.google.gerrit.server.util.OneOffRequestContext)1 NoteDbChecker (com.google.gerrit.testutil.NoteDbChecker)1 NoteDbMode (com.google.gerrit.testutil.NoteDbMode)1