use of com.google.gerrit.acceptance.ReindexGroupsAtStartup.ReindexGroupsAtStartupModule in project gerrit by GerritCodeReview.
the class GerritServer method startInMemory.
private static GerritServer startInMemory(Description desc, Path site, Config baseConfig, Daemon daemon, @Nullable InMemoryRepositoryManager inMemoryRepoManager) throws Exception {
Config cfg = desc.buildConfig(baseConfig);
daemon.setReplica(ReplicaUtil.isReplica(baseConfig) || ReplicaUtil.isReplica(cfg));
mergeTestConfig(cfg);
// Set the log4j configuration to an invalid one to prevent system logs
// from getting configured and creating log files.
System.setProperty(SystemLog.LOG4J_CONFIGURATION, "invalidConfiguration");
cfg.setBoolean("httpd", null, "requestLog", false);
cfg.setBoolean("sshd", null, "requestLog", false);
cfg.setBoolean("index", "lucene", "testInmemory", true);
cfg.setBoolean("index", null, "onlineUpgrade", false);
cfg.setString("gitweb", null, "cgi", "");
cfg.setString("accountPatchReviewDb", null, "url", JdbcAccountPatchReviewStore.TEST_IN_MEMORY_URL);
String configuredIndexBackend = cfg.getString("index", null, "type");
IndexType indexType;
if (configuredIndexBackend != null) {
// Explicitly configured index backend from gerrit.config trumps any other ways to configure
// index backends so that Reindex tests can be explicit about the backend they want to test
// against.
indexType = new IndexType(configuredIndexBackend);
} else {
// Allow configuring the index backend based on sys/env variables so that integration tests
// can be run against different index backends.
indexType = IndexType.fromEnvironment().orElse(new IndexType("fake"));
}
if (indexType.isLucene()) {
daemon.setIndexModule(LuceneIndexModule.singleVersionAllLatest(0, ReplicaUtil.isReplica(baseConfig), AutoFlush.ENABLED));
} else {
daemon.setIndexModule(FakeIndexModule.latestVersion(false));
}
daemon.setEnableHttpd(desc.httpd());
daemon.setInMemory(true);
daemon.setDatabaseForTesting(ImmutableList.of(new InMemoryTestingDatabaseModule(cfg, site, inMemoryRepoManager), new AbstractModule() {
@Override
protected void configure() {
bind(GerritRuntime.class).toInstance(GerritRuntime.DAEMON);
}
}, new ConfigExperimentFeaturesModule()));
daemon.addAdditionalSysModuleForTesting(new ReindexProjectsAtStartupModule(), new ReindexGroupsAtStartupModule());
daemon.start();
return new GerritServer(desc, null, createTestInjector(daemon), daemon, null);
}
use of com.google.gerrit.acceptance.ReindexGroupsAtStartup.ReindexGroupsAtStartupModule in project gerrit by GerritCodeReview.
the class GerritServer method startOnDisk.
private static GerritServer startOnDisk(Description desc, Path site, Daemon daemon, CyclicBarrier serverStarted, String[] additionalArgs) throws Exception {
requireNonNull(site);
daemon.addAdditionalSysModuleForTesting(new ReindexProjectsAtStartupModule(), new ReindexGroupsAtStartupModule());
ExecutorService daemonService = Executors.newSingleThreadExecutor();
String[] args = Stream.concat(Stream.of("-d", site.toString(), "--headless", "--console-log", "--show-stack-trace"), Arrays.stream(additionalArgs)).toArray(String[]::new);
@SuppressWarnings("unused") Future<?> possiblyIgnoredError = daemonService.submit(() -> {
int rc = daemon.main(args);
if (rc != 0) {
System.err.println("Failed to start Gerrit daemon");
serverStarted.reset();
}
return null;
});
try {
serverStarted.await();
} catch (BrokenBarrierException e) {
daemon.stop();
throw new StartupException("Failed to start Gerrit daemon; see log", e);
}
System.out.println("Gerrit Server Started");
return new GerritServer(desc, site, createTestInjector(daemon), daemon, daemonService);
}
Aggregations