Search in sources :

Example 1 with GerritIndexStatus

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

the class Init method beforeInit.

@Override
protected boolean beforeInit(SiteInit init) throws Exception {
    indexStatus = new GerritIndexStatus(init.site);
    ErrorLogFile.errorOnlyConsole();
    if (!skipPlugins) {
        final List<PluginData> plugins = InitPlugins.listPluginsAndRemoveTempFiles(init.site, pluginsDistribution);
        ConsoleUI ui = ConsoleUI.getInstance(false);
        if (installAllPlugins && !nullOrEmpty(installPlugins)) {
            ui.message("Cannot use --install-plugin together with --install-all-plugins.\n");
            return true;
        }
        verifyInstallPluginList(ui, plugins);
        if (listPlugins) {
            if (!plugins.isEmpty()) {
                ui.message("Available plugins:\n");
                for (PluginData plugin : plugins) {
                    ui.message(" * %s version %s\n", plugin.name, plugin.version);
                }
            } else {
                ui.message("No plugins found.\n");
            }
            return true;
        }
    }
    return false;
}
Also used : PluginData(com.google.gerrit.common.PluginData) ConsoleUI(com.google.gerrit.pgm.init.api.ConsoleUI) GerritIndexStatus(com.google.gerrit.server.index.GerritIndexStatus)

Example 2 with GerritIndexStatus

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

the class AbstractReindexTests method assertReady.

private void assertReady(int expectedReady) throws Exception {
    Set<Integer> allVersions = ChangeSchemaDefinitions.INSTANCE.getSchemas().keySet();
    GerritIndexStatus status = new GerritIndexStatus(sitePaths);
    assertWithMessage("ready state for index versions").that(allVersions.stream().collect(toImmutableMap(v -> v, v -> status.getReady(CHANGES, v)))).isEqualTo(allVersions.stream().collect(toImmutableMap(v -> v, v -> v == expectedReady)));
}
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) GerritIndexStatus(com.google.gerrit.server.index.GerritIndexStatus)

Example 3 with GerritIndexStatus

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

the class AbstractReindexTests method onlineUpgradeChanges.

@Test
public void onlineUpgradeChanges() throws Exception {
    int prevVersion = ChangeSchemaDefinitions.INSTANCE.getPrevious().getVersion();
    int currVersion = ChangeSchemaDefinitions.INSTANCE.getLatest().getVersion();
    // Before storing any changes, switch back to the previous version.
    GerritIndexStatus status = new GerritIndexStatus(sitePaths);
    status.setReady(CHANGES, currVersion, false);
    status.setReady(CHANGES, prevVersion, true);
    status.save();
    assertReady(prevVersion);
    setOnlineUpgradeConfig(false);
    setUpChange();
    setOnlineUpgradeConfig(true);
    IndexUpgradeController u = new IndexUpgradeController(1);
    try (ServerContext ctx = startServer(u.module())) {
        assertSearchVersion(ctx, prevVersion);
        assertWriteVersions(ctx, prevVersion, currVersion);
        // Updating and searching old schema version works.
        Provider<InternalChangeQuery> queryProvider = ctx.getInjector().getProvider(InternalChangeQuery.class);
        assertThat(queryProvider.get().byKey(Change.key(changeId))).hasSize(1);
        assertThat(queryProvider.get().byTopicOpen("topic1")).isEmpty();
        GerritApi gApi = ctx.getInjector().getInstance(GerritApi.class);
        gApi.changes().id(changeId).topic("topic1");
        assertThat(queryProvider.get().byTopicOpen("topic1")).hasSize(1);
        u.runUpgrades();
        assertThat(u.getStartedAttempts()).containsExactly(UpgradeAttempt.create(CHANGES, prevVersion, currVersion));
        assertThat(u.getSucceededAttempts()).containsExactly(UpgradeAttempt.create(CHANGES, prevVersion, currVersion));
        assertThat(u.getFailedAttempts()).isEmpty();
        assertReady(currVersion);
        assertSearchVersion(ctx, currVersion);
        assertWriteVersions(ctx, currVersion);
        // Updating and searching new schema version works.
        assertThat(queryProvider.get().byTopicOpen("topic1")).hasSize(1);
        assertThat(queryProvider.get().byTopicOpen("topic2")).isEmpty();
        gApi.changes().id(changeId).topic("topic2");
        assertThat(queryProvider.get().byTopicOpen("topic1")).isEmpty();
        assertThat(queryProvider.get().byTopicOpen("topic2")).hasSize(1);
    }
}
Also used : InternalChangeQuery(com.google.gerrit.server.query.change.InternalChangeQuery) GerritApi(com.google.gerrit.extensions.api.GerritApi) GerritIndexStatus(com.google.gerrit.server.index.GerritIndexStatus) StandaloneSiteTest(com.google.gerrit.acceptance.StandaloneSiteTest) Test(org.junit.Test)

Aggregations

GerritIndexStatus (com.google.gerrit.server.index.GerritIndexStatus)3 StandaloneSiteTest (com.google.gerrit.acceptance.StandaloneSiteTest)2 GerritApi (com.google.gerrit.extensions.api.GerritApi)2 InternalChangeQuery (com.google.gerrit.server.query.change.InternalChangeQuery)2 Test (org.junit.Test)2 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 UpgradeAttempt (com.google.gerrit.acceptance.pgm.IndexUpgradeController.UpgradeAttempt)1 PluginData (com.google.gerrit.common.PluginData)1 Change (com.google.gerrit.entities.Change)1 Project (com.google.gerrit.entities.Project)1 MEMBERS (com.google.gerrit.extensions.client.ListGroupsOption.MEMBERS)1 ChangeInput (com.google.gerrit.extensions.common.ChangeInput)1