Search in sources :

Example 6 with ChangeIndexedCounter

use of com.google.gerrit.acceptance.ChangeIndexedCounter in project gerrit by GerritCodeReview.

the class IndexChangesIT method indexVisibleChange.

@Test
public void indexVisibleChange() throws Exception {
    ChangeIndexedCounter changeIndexedCounter = new ChangeIndexedCounter();
    try (Registration registration = extensionRegistry.newRegistration().add(changeIndexedCounter)) {
        String changeId = createChange().getChangeId();
        IndexChanges.Input in = new IndexChanges.Input();
        in.changes = ImmutableSet.of(changeId);
        changeIndexedCounter.clear();
        adminRestSession.post("/config/server/index.changes", in).assertOK();
        assertThat(changeIndexedCounter.getCount(info(changeId))).isEqualTo(1);
    }
}
Also used : Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) IndexChanges(com.google.gerrit.server.restapi.config.IndexChanges) ChangeIndexedCounter(com.google.gerrit.acceptance.ChangeIndexedCounter) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 7 with ChangeIndexedCounter

use of com.google.gerrit.acceptance.ChangeIndexedCounter in project gerrit by GerritCodeReview.

the class AbstractIndexTests method indexProject.

@Test
@GerritConfig(name = "index.autoReindexIfStale", value = "false")
public void indexProject() throws Exception {
    ChangeIndexedCounter changeIndexedCounter = new ChangeIndexedCounter();
    try (Registration registration = extensionRegistry.newRegistration().add(changeIndexedCounter)) {
        PushOneCommit.Result change = createChange("first change", "test1.txt", "test1");
        String changeId = change.getChangeId();
        ChangeInfo changeInfo = gApi.changes().id(changeId).get();
        disableChangeIndexWrites();
        amendChange(changeId, "second test", "test2.txt", "test2");
        assertChangeQuery(change.getChange(), false);
        enableChangeIndexWrites();
        changeIndexedCounter.clear();
        String cmd = Joiner.on(" ").join("gerrit", "index", "changes-in-project", project.get());
        adminSshSession.exec(cmd);
        adminSshSession.assertSuccess();
        boolean indexing = true;
        while (indexing) {
            String out = adminSshSession.exec("gerrit show-queue --wide");
            adminSshSession.assertSuccess();
            indexing = out.contains("Index all changes of project " + project.get());
        }
        changeIndexedCounter.assertReindexOf(changeInfo, 1);
        assertChangeQuery(change.getChange(), true);
    }
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) ChangeIndexedCounter(com.google.gerrit.acceptance.ChangeIndexedCounter) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)7 ChangeIndexedCounter (com.google.gerrit.acceptance.ChangeIndexedCounter)7 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)7 Test (org.junit.Test)7 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)4 IndexChanges (com.google.gerrit.server.restapi.config.IndexChanges)4 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)3 GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)2 ImmutableSet (com.google.common.collect.ImmutableSet)1