From 108ad65a7664c25f3c6ecfb5019ae09c5e5c2b1b Mon Sep 17 00:00:00 2001 From: Marco Miller Date: Thu, 19 Jul 2018 12:23:22 -0400 Subject: [PATCH] GerritServer: save gerrit.config before site init Do so as already done in 2.15 and master versions. Fix ElasticReindexIT so it passes also with this change. Contrary to Lucene, configuring the Elasticsearch index type currently assumes uninitialized indices -in Elasticsearch. Thus fix the test so it first asserts that assumption, then reindexes or initializes indices offline. The test then keeps testing as currently the case also for ReindexIT, i.e., through their common parent test class methods. Bug: Issue 8799 Change-Id: Ie52ea03a781c89fb3caf0f965f6fca1fb6c6a478 --- .../google/gerrit/acceptance/GerritServer.java | 17 +++++++++-------- .../gerrit/acceptance/pgm/ElasticReindexIT.java | 7 +++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/GerritServer.java b/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/GerritServer.java index 1d7ea103fd..bb3cab86fa 100644 --- a/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/GerritServer.java +++ b/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/GerritServer.java @@ -185,6 +185,15 @@ public class GerritServer implements AutoCloseable { checkArgument(!desc.memory(), "can't initialize site path for in-memory test: %s", desc); Config cfg = desc.buildConfig(baseConfig); Map pluginConfigs = desc.buildPluginConfigs(); + + MergeableFileBasedConfig gerritConfig = + new MergeableFileBasedConfig( + site.resolve("etc").resolve("gerrit.config").toFile(), FS.DETECTED); + gerritConfig.load(); + gerritConfig.merge(cfg); + mergeTestConfig(gerritConfig); + gerritConfig.save(); + Init init = new Init(); int rc = init.main( @@ -195,14 +204,6 @@ public class GerritServer implements AutoCloseable { throw new RuntimeException("Couldn't initialize site"); } - MergeableFileBasedConfig gerritConfig = - new MergeableFileBasedConfig( - site.resolve("etc").resolve("gerrit.config").toFile(), FS.DETECTED); - gerritConfig.load(); - gerritConfig.merge(cfg); - mergeTestConfig(gerritConfig); - gerritConfig.save(); - for (String pluginName : pluginConfigs.keySet()) { MergeableFileBasedConfig pluginCfg = new MergeableFileBasedConfig( diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/pgm/ElasticReindexIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/pgm/ElasticReindexIT.java index b560c5f8cf..c4900de40a 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/pgm/ElasticReindexIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/pgm/ElasticReindexIT.java @@ -23,6 +23,7 @@ import com.google.inject.Injector; import java.util.UUID; import org.eclipse.jgit.lib.Config; import org.junit.After; +import org.junit.Before; public class ElasticReindexIT extends AbstractReindexTests { private static ElasticContainer container; @@ -62,6 +63,12 @@ public class ElasticReindexIT extends AbstractReindexTests { ElasticTestUtils.createAllIndexes(injector); } + @Before + public void reindexFirstSinceElastic() throws Exception { + assertServerStartupFails(); + runGerrit("reindex", "-d", sitePaths.site_path.toString(), "--show-stack-trace"); + } + @After public void stopElasticServer() { if (container != null) {