Search in sources :

Example 1 with ChangeIndex

use of com.google.gerrit.server.index.change.ChangeIndex in project gerrit by GerritCodeReview.

the class ChangeIT method deleteChangeUpdatesIndex.

@Test
public void deleteChangeUpdatesIndex() throws Exception {
    PushOneCommit.Result changeResult = createChange();
    String changeId = changeResult.getChangeId();
    Change.Id id = changeResult.getChange().getId();
    ChangeIndex idx = changeIndexCollection.getSearchIndex();
    Optional<ChangeData> result = idx.get(id, IndexedChangeQuery.createOptions(indexConfig, 0, 1, ImmutableSet.of()));
    assertThat(result).isPresent();
    gApi.changes().id(changeId).delete();
    result = idx.get(id, IndexedChangeQuery.createOptions(indexConfig, 0, 1, ImmutableSet.of()));
    assertThat(result).isEmpty();
}
Also used : ChangeIndex(com.google.gerrit.server.index.change.ChangeIndex) Change(com.google.gerrit.entities.Change) ChangeData(com.google.gerrit.server.query.change.ChangeData) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 2 with ChangeIndex

use of com.google.gerrit.server.index.change.ChangeIndex in project gerrit by GerritCodeReview.

the class AbstractDaemonTest method disableChangeIndex.

protected AutoCloseable disableChangeIndex() {
    disableChangeIndexWrites();
    ChangeIndex maybeDisabledSearchIndex = changeIndexes.getSearchIndex();
    if (!(maybeDisabledSearchIndex instanceof DisabledChangeIndex)) {
        changeIndexes.setSearchIndex(new DisabledChangeIndex(maybeDisabledSearchIndex), false);
    }
    return () -> {
        enableChangeIndexWrites();
        ChangeIndex maybeEnabledSearchIndex = changeIndexes.getSearchIndex();
        if (maybeEnabledSearchIndex instanceof DisabledChangeIndex) {
            changeIndexes.setSearchIndex(((DisabledChangeIndex) maybeEnabledSearchIndex).unwrap(), false);
        }
    };
}
Also used : ChangeIndex(com.google.gerrit.server.index.change.ChangeIndex)

Aggregations

ChangeIndex (com.google.gerrit.server.index.change.ChangeIndex)2 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)1 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)1 Change (com.google.gerrit.entities.Change)1 ChangeData (com.google.gerrit.server.query.change.ChangeData)1 Test (org.junit.Test)1