Search in sources :

Example 1 with MEMBERS

use of com.google.gerrit.extensions.client.ListGroupsOption.MEMBERS in project gerrit by GerritCodeReview.

the class AbstractReindexTests method reindexFromScratch.

@Test
public void reindexFromScratch() throws Exception {
    setUpChange();
    MoreFiles.deleteRecursively(sitePaths.index_dir, RecursiveDeleteOption.ALLOW_INSECURE);
    Files.createDirectory(sitePaths.index_dir);
    assertServerStartupFails();
    runGerrit("reindex", "-d", sitePaths.site_path.toString(), "--show-stack-trace");
    assertReady(ChangeSchemaDefinitions.INSTANCE.getLatest().getVersion());
    try (ServerContext ctx = startServer()) {
        GerritApi gApi = ctx.getInjector().getInstance(GerritApi.class);
        // Query change index
        assertThat(gApi.changes().query("message:Test").get().stream().map(c -> c.changeId)).containsExactly(changeId);
        // Query account index
        assertThat(gApi.accounts().query("admin").get().stream().map(a -> a._accountId)).containsExactly(admin.id().get());
        // Query group index
        assertThat(gApi.groups().query("Group").withOption(MEMBERS).get().stream().flatMap(g -> g.members.stream()).map(a -> a._accountId)).containsExactly(admin.id().get());
        // Query project index
        assertThat(gApi.projects().query(project.get()).get().stream().map(p -> p.name)).containsExactly(project.get());
    }
}
Also used : IndexDefinition(com.google.gerrit.index.IndexDefinition) Key(com.google.inject.Key) UpgradeAttempt(com.google.gerrit.acceptance.pgm.IndexUpgradeController.UpgradeAttempt) Config(org.eclipse.jgit.lib.Config) Change(com.google.gerrit.entities.Change) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) StandaloneSiteTest(com.google.gerrit.acceptance.StandaloneSiteTest) MEMBERS(com.google.gerrit.extensions.client.ListGroupsOption.MEMBERS) ImmutableSet(com.google.common.collect.ImmutableSet) Truth.assertWithMessage(com.google.common.truth.Truth.assertWithMessage) Files(java.nio.file.Files) Collection(java.util.Collection) Set(java.util.Set) Test(org.junit.Test) RecursiveDeleteOption(com.google.common.io.RecursiveDeleteOption) GerritIndexStatus(com.google.gerrit.server.index.GerritIndexStatus) Truth.assertThat(com.google.common.truth.Truth.assertThat) GerritLauncher(com.google.gerrit.launcher.GerritLauncher) NoHttpd(com.google.gerrit.acceptance.NoHttpd) Injector(com.google.inject.Injector) Consumer(java.util.function.Consumer) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) Provider(com.google.inject.Provider) FileBasedConfig(org.eclipse.jgit.storage.file.FileBasedConfig) MoreFiles(com.google.common.io.MoreFiles) Project(com.google.gerrit.entities.Project) InternalChangeQuery(com.google.gerrit.server.query.change.InternalChangeQuery) ChangeIndexCollection(com.google.gerrit.server.index.change.ChangeIndexCollection) FS(org.eclipse.jgit.util.FS) GerritApi(com.google.gerrit.extensions.api.GerritApi) TypeLiteral(com.google.inject.TypeLiteral) StreamSubject.streams(com.google.common.truth.StreamSubject.streams) ChangeSchemaDefinitions(com.google.gerrit.server.index.change.ChangeSchemaDefinitions) GerritApi(com.google.gerrit.extensions.api.GerritApi) StandaloneSiteTest(com.google.gerrit.acceptance.StandaloneSiteTest) Test(org.junit.Test)

Aggregations

ImmutableMap.toImmutableMap (com.google.common.collect.ImmutableMap.toImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 MoreFiles (com.google.common.io.MoreFiles)1 RecursiveDeleteOption (com.google.common.io.RecursiveDeleteOption)1 StreamSubject.streams (com.google.common.truth.StreamSubject.streams)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 Truth.assertWithMessage (com.google.common.truth.Truth.assertWithMessage)1 Truth8.assertThat (com.google.common.truth.Truth8.assertThat)1 NoHttpd (com.google.gerrit.acceptance.NoHttpd)1 StandaloneSiteTest (com.google.gerrit.acceptance.StandaloneSiteTest)1 UpgradeAttempt (com.google.gerrit.acceptance.pgm.IndexUpgradeController.UpgradeAttempt)1 Change (com.google.gerrit.entities.Change)1 Project (com.google.gerrit.entities.Project)1 GerritApi (com.google.gerrit.extensions.api.GerritApi)1 MEMBERS (com.google.gerrit.extensions.client.ListGroupsOption.MEMBERS)1 ChangeInput (com.google.gerrit.extensions.common.ChangeInput)1 IndexDefinition (com.google.gerrit.index.IndexDefinition)1 GerritLauncher (com.google.gerrit.launcher.GerritLauncher)1 GerritIndexStatus (com.google.gerrit.server.index.GerritIndexStatus)1 ChangeIndexCollection (com.google.gerrit.server.index.change.ChangeIndexCollection)1