Make indexes available during init invoked by tests

Tests do site initialization, but during this site initialization the
indexes were not available. Due to this SchemaCreator had to do a null
check on the search index when indexing new groups.

Add the necessary Guice bindings to make the indexes available during
init that is triggered by tests and ensure that the indexes are
properly started before and stopped after the site initialization.

Change-Id: Id2bd2157239f39395e594438fe877253a4906704
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2017-01-25 15:39:21 +01:00
parent 4a4db8cfbe
commit c3fe0838cc
6 changed files with 55 additions and 21 deletions

View File

@@ -57,6 +57,7 @@ import com.google.gerrit.server.config.AllUsersName;
import com.google.gerrit.server.config.AllUsersNameProvider;
import com.google.gerrit.server.config.SitePaths;
import com.google.gerrit.server.git.ProjectConfig;
import com.google.gerrit.server.index.SingleVersionModule.SingleVersionListener;
import com.google.gerrit.server.query.change.InternalChangeQuery;
import com.google.gerrit.server.schema.SchemaCreator;
import com.google.gerrit.server.util.RequestContext;
@@ -240,6 +241,7 @@ public class RefControlTest {
@Inject private CapabilityCollection.Factory capabilityCollectionFactory;
@Inject private CapabilityControl.Factory capabilityControlFactory;
@Inject private SchemaCreator schemaCreator;
@Inject private SingleVersionListener singleVersionListener;
@Inject private InMemoryDatabase schemaFactory;
@Inject private ThreadLocalRequestContext requestContext;
@Inject private Provider<InternalChangeQuery> queryProvider;
@@ -317,7 +319,12 @@ public class RefControlTest {
}
db = schemaFactory.open();
schemaCreator.create(db);
singleVersionListener.start();
try {
schemaCreator.create(db);
} finally {
singleVersionListener.stop();
}
Cache<SectionSortCache.EntryKey, SectionSortCache.EntryVal> c =
CacheBuilder.newBuilder().build();