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;
}
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)));
}
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);
}
}
Aggregations