Merge branch 'stable-2.15' * stable-2.15: AbstractElasticIndex: Make type field protected ElasticReindexIT: Add tests against Elasticsearch version 6 Elasticsearch: Add tests for queries against version 6 Elasticsearch: Add support for V6 / one index type Change-Id: I245bf98456a1a088470d3249ad29a7c58e8f92b8
diff --git a/java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java b/java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java index 453712a..0ccd820 100644 --- a/java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java +++ b/java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java
@@ -25,6 +25,7 @@ import com.google.common.collect.Lists; import com.google.common.flogger.FluentLogger; import com.google.common.io.CharStreams; +import com.google.gerrit.elasticsearch.ElasticMapping.MappingProperties; import com.google.gerrit.elasticsearch.builders.QueryBuilder; import com.google.gerrit.elasticsearch.builders.SearchSourceBuilder; import com.google.gerrit.elasticsearch.bulk.DeleteRequest; @@ -75,6 +76,7 @@ private static final FluentLogger logger = FluentLogger.forEnclosingClass(); protected static final String BULK = "_bulk"; + protected static final String MAPPINGS = "mappings"; protected static final String ORDER = "order"; protected static final String SEARCH = "_search"; @@ -105,6 +107,7 @@ private final SitePaths sitePaths; private final String indexNameRaw; + protected final String type; protected final ElasticRestClientProvider client; protected final String indexName; protected final Gson gson; @@ -123,6 +126,7 @@ this.indexName = cfg.getIndexName(indexName, schema.getVersion()); this.indexNameRaw = indexName; this.client = client; + this.type = client.adapter().getType(indexName); } @Override @@ -142,7 +146,7 @@ @Override public void delete(K id) throws IOException { - String uri = getURI(indexNameRaw, BULK); + String uri = getURI(type, BULK); Response response = postRequest(getDeleteActions(id), uri, getRefreshParam()); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { @@ -181,8 +185,20 @@ protected abstract String getId(V v); + protected String getMappingsForSingleType(String candidateType, MappingProperties properties) { + return getMappingsFor(client.adapter().getType(candidateType), properties); + } + + protected String getMappingsFor(String type, MappingProperties properties) { + JsonObject mappingType = new JsonObject(); + mappingType.add(type, gson.toJsonTree(properties)); + JsonObject mappings = new JsonObject(); + mappings.add(MAPPINGS, gson.toJsonTree(mappingType)); + return gson.toJson(mappings); + } + protected String delete(String type, K id) { - return new DeleteRequest(id.toString(), indexName, type).toString(); + return new DeleteRequest(id.toString(), indexName, type, client.adapter()).toString(); } protected abstract V fromDocument(JsonObject doc, Set<String> fields);
diff --git a/java/com/google/gerrit/elasticsearch/ElasticAccountIndex.java b/java/com/google/gerrit/elasticsearch/ElasticAccountIndex.java index c212a8b..58f4fb9 100644 --- a/java/com/google/gerrit/elasticsearch/ElasticAccountIndex.java +++ b/java/com/google/gerrit/elasticsearch/ElasticAccountIndex.java
@@ -16,7 +16,6 @@ import static com.google.gerrit.server.index.account.AccountField.ID; -import com.google.common.collect.ImmutableMap; import com.google.gerrit.elasticsearch.ElasticMapping.MappingProperties; import com.google.gerrit.elasticsearch.bulk.BulkRequest; import com.google.gerrit.elasticsearch.bulk.IndexRequest; @@ -76,9 +75,10 @@ @Override public void replace(AccountState as) throws IOException { BulkRequest bulk = - new IndexRequest(getId(as), indexName, ACCOUNTS).add(new UpdateRequest<>(schema, as)); + new IndexRequest(getId(as), indexName, type, client.adapter()) + .add(new UpdateRequest<>(schema, as)); - String uri = getURI(ACCOUNTS, BULK); + String uri = getURI(type, BULK); Response response = postRequest(bulk, uri, getRefreshParam()); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { @@ -99,13 +99,12 @@ @Override protected String getDeleteActions(Account.Id a) { - return delete(ACCOUNTS, a); + return delete(type, a); } @Override protected String getMappings() { - ImmutableMap<String, AccountMapping> mappings = ImmutableMap.of("mappings", mapping); - return gson.toJson(mappings); + return getMappingsForSingleType(ACCOUNTS, mapping.accounts); } @Override
diff --git a/java/com/google/gerrit/elasticsearch/ElasticChangeIndex.java b/java/com/google/gerrit/elasticsearch/ElasticChangeIndex.java index ccf15d7..1ec8d2b 100644 --- a/java/com/google/gerrit/elasticsearch/ElasticChangeIndex.java +++ b/java/com/google/gerrit/elasticsearch/ElasticChangeIndex.java
@@ -76,11 +76,13 @@ class ElasticChangeIndex extends AbstractElasticIndex<Change.Id, ChangeData> implements ChangeIndex { static class ChangeMapping { + MappingProperties changes; MappingProperties openChanges; MappingProperties closedChanges; ChangeMapping(Schema<ChangeData> schema, ElasticQueryAdapter adapter) { MappingProperties mapping = ElasticMapping.createMapping(schema, adapter); + this.changes = mapping; this.openChanges = mapping; this.closedChanges = mapping; } @@ -127,12 +129,15 @@ throw new IOException(e); } + ElasticQueryAdapter adapter = client.adapter(); BulkRequest bulk = - new IndexRequest(getId(cd), indexName, insertIndex) - .add(new UpdateRequest<>(schema, cd)) - .add(new DeleteRequest(cd.getId().toString(), indexName, deleteIndex)); + new IndexRequest(getId(cd), indexName, adapter.getType(insertIndex), adapter) + .add(new UpdateRequest<>(schema, cd)); + if (!adapter.usePostV5Type()) { + bulk.add(new DeleteRequest(cd.getId().toString(), indexName, deleteIndex, adapter)); + } - String uri = getURI(CHANGES, BULK); + String uri = getURI(type, BULK); Response response = postRequest(bulk, uri, getRefreshParam()); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { @@ -147,11 +152,18 @@ throws QueryParseException { Set<Change.Status> statuses = ChangeIndexRewriter.getPossibleStatus(p); List<String> indexes = Lists.newArrayListWithCapacity(2); - if (!Sets.intersection(statuses, OPEN_STATUSES).isEmpty()) { - indexes.add(OPEN_CHANGES); - } - if (!Sets.intersection(statuses, CLOSED_STATUSES).isEmpty()) { - indexes.add(CLOSED_CHANGES); + if (client.adapter().usePostV5Type()) { + if (!Sets.intersection(statuses, OPEN_STATUSES).isEmpty() + || !Sets.intersection(statuses, CLOSED_STATUSES).isEmpty()) { + indexes.add(ElasticQueryAdapter.POST_V5_TYPE); + } + } else { + if (!Sets.intersection(statuses, OPEN_STATUSES).isEmpty()) { + indexes.add(OPEN_CHANGES); + } + if (!Sets.intersection(statuses, CLOSED_STATUSES).isEmpty()) { + indexes.add(CLOSED_CHANGES); + } } QueryOptions filteredOpts = opts.filterFields(IndexUtils::changeFields); @@ -175,12 +187,18 @@ @Override protected String getDeleteActions(Id c) { + if (client.adapter().usePostV5Type()) { + return delete(ElasticQueryAdapter.POST_V5_TYPE, c); + } return delete(OPEN_CHANGES, c) + delete(CLOSED_CHANGES, c); } @Override protected String getMappings() { - return gson.toJson(ImmutableMap.of("mappings", mapping)); + if (client.adapter().usePostV5Type()) { + return getMappingsFor(ElasticQueryAdapter.POST_V5_TYPE, mapping.changes); + } + return gson.toJson(ImmutableMap.of(MAPPINGS, mapping)); } @Override
diff --git a/java/com/google/gerrit/elasticsearch/ElasticGroupIndex.java b/java/com/google/gerrit/elasticsearch/ElasticGroupIndex.java index d2de01e..cf1a4ed 100644 --- a/java/com/google/gerrit/elasticsearch/ElasticGroupIndex.java +++ b/java/com/google/gerrit/elasticsearch/ElasticGroupIndex.java
@@ -14,7 +14,6 @@ package com.google.gerrit.elasticsearch; -import com.google.common.collect.ImmutableMap; import com.google.gerrit.elasticsearch.ElasticMapping.MappingProperties; import com.google.gerrit.elasticsearch.bulk.BulkRequest; import com.google.gerrit.elasticsearch.bulk.IndexRequest; @@ -74,9 +73,10 @@ @Override public void replace(InternalGroup group) throws IOException { BulkRequest bulk = - new IndexRequest(getId(group), indexName, GROUPS).add(new UpdateRequest<>(schema, group)); + new IndexRequest(getId(group), indexName, type, client.adapter()) + .add(new UpdateRequest<>(schema, group)); - String uri = getURI(GROUPS, BULK); + String uri = getURI(type, BULK); Response response = postRequest(bulk, uri, getRefreshParam()); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { @@ -96,13 +96,12 @@ @Override protected String getDeleteActions(AccountGroup.UUID g) { - return delete(GROUPS, g); + return delete(type, g); } @Override protected String getMappings() { - ImmutableMap<String, GroupMapping> mappings = ImmutableMap.of("mappings", mapping); - return gson.toJson(mappings); + return getMappingsForSingleType(GROUPS, mapping.groups); } @Override
diff --git a/java/com/google/gerrit/elasticsearch/ElasticProjectIndex.java b/java/com/google/gerrit/elasticsearch/ElasticProjectIndex.java index dfb1c5d..623f62c 100644 --- a/java/com/google/gerrit/elasticsearch/ElasticProjectIndex.java +++ b/java/com/google/gerrit/elasticsearch/ElasticProjectIndex.java
@@ -14,7 +14,6 @@ package com.google.gerrit.elasticsearch; -import com.google.common.collect.ImmutableMap; import com.google.gerrit.elasticsearch.ElasticMapping.MappingProperties; import com.google.gerrit.elasticsearch.bulk.BulkRequest; import com.google.gerrit.elasticsearch.bulk.IndexRequest; @@ -74,10 +73,10 @@ @Override public void replace(ProjectData projectState) throws IOException { BulkRequest bulk = - new IndexRequest(projectState.getProject().getName(), indexName, PROJECTS) + new IndexRequest(projectState.getProject().getName(), indexName, type, client.adapter()) .add(new UpdateRequest<>(schema, projectState)); - String uri = getURI(PROJECTS, BULK); + String uri = getURI(type, BULK); Response response = postRequest(bulk, uri, getRefreshParam()); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { @@ -92,19 +91,17 @@ public DataSource<ProjectData> getSource(Predicate<ProjectData> p, QueryOptions opts) throws QueryParseException { JsonArray sortArray = getSortArray(ProjectField.NAME.getName()); - return new ElasticQuerySource( - p, opts.filterFields(IndexUtils::projectFields), PROJECTS, sortArray); + return new ElasticQuerySource(p, opts.filterFields(IndexUtils::projectFields), type, sortArray); } @Override protected String getDeleteActions(Project.NameKey nameKey) { - return delete(PROJECTS, nameKey); + return delete(type, nameKey); } @Override protected String getMappings() { - ImmutableMap<String, ProjectMapping> mappings = ImmutableMap.of("mappings", mapping); - return gson.toJson(mappings); + return getMappingsForSingleType(PROJECTS, mapping.projects); } @Override
diff --git a/java/com/google/gerrit/elasticsearch/ElasticQueryAdapter.java b/java/com/google/gerrit/elasticsearch/ElasticQueryAdapter.java index b6cbf2f..3201289 100644 --- a/java/com/google/gerrit/elasticsearch/ElasticQueryAdapter.java +++ b/java/com/google/gerrit/elasticsearch/ElasticQueryAdapter.java
@@ -17,7 +17,11 @@ import com.google.gson.JsonObject; public class ElasticQueryAdapter { + static final String POST_V5_TYPE = "_doc"; + private final boolean ignoreUnmapped; + private final boolean usePostV5Type; + private final String searchFilteringName; private final String indicesExistParam; private final String exactFieldType; @@ -27,6 +31,8 @@ ElasticQueryAdapter(ElasticVersion version) { this.ignoreUnmapped = version == ElasticVersion.V2_4; + this.usePostV5Type = version == ElasticVersion.V6_2; + switch (version) { case V5_6: case V6_2: @@ -55,6 +61,12 @@ } } + public void setType(JsonObject properties, String type) { + if (!usePostV5Type) { + properties.addProperty("_type", type); + } + } + public String searchFilteringName() { return searchFilteringName; } @@ -78,4 +90,12 @@ String rawFieldsKey() { return rawFieldsKey; } + + boolean usePostV5Type() { + return usePostV5Type; + } + + String getType(String preV6Type) { + return usePostV5Type() ? POST_V5_TYPE : preV6Type; + } }
diff --git a/java/com/google/gerrit/elasticsearch/bulk/ActionRequest.java b/java/com/google/gerrit/elasticsearch/bulk/ActionRequest.java index c7757b2..7392d09 100644 --- a/java/com/google/gerrit/elasticsearch/bulk/ActionRequest.java +++ b/java/com/google/gerrit/elasticsearch/bulk/ActionRequest.java
@@ -14,6 +14,7 @@ package com.google.gerrit.elasticsearch.bulk; +import com.google.gerrit.elasticsearch.ElasticQueryAdapter; import com.google.gson.JsonObject; abstract class ActionRequest extends BulkRequest { @@ -22,12 +23,15 @@ private final String id; private final String index; private final String type; + private final ElasticQueryAdapter adapter; - protected ActionRequest(String action, String id, String index, String type) { + protected ActionRequest( + String action, String id, String index, String type, ElasticQueryAdapter adapter) { this.action = action; this.id = id; this.index = index; this.type = type; + this.adapter = adapter; } @Override @@ -35,7 +39,7 @@ JsonObject properties = new JsonObject(); properties.addProperty("_id", id); properties.addProperty("_index", index); - properties.addProperty("_type", type); + adapter.setType(properties, type); JsonObject jsonAction = new JsonObject(); jsonAction.add(action, properties);
diff --git a/java/com/google/gerrit/elasticsearch/bulk/DeleteRequest.java b/java/com/google/gerrit/elasticsearch/bulk/DeleteRequest.java index 7d549ca..570d5a0 100644 --- a/java/com/google/gerrit/elasticsearch/bulk/DeleteRequest.java +++ b/java/com/google/gerrit/elasticsearch/bulk/DeleteRequest.java
@@ -14,9 +14,11 @@ package com.google.gerrit.elasticsearch.bulk; +import com.google.gerrit.elasticsearch.ElasticQueryAdapter; + public class DeleteRequest extends ActionRequest { - public DeleteRequest(String id, String index, String type) { - super("delete", id, index, type); + public DeleteRequest(String id, String index, String type, ElasticQueryAdapter adapter) { + super("delete", id, index, type, adapter); } }
diff --git a/java/com/google/gerrit/elasticsearch/bulk/IndexRequest.java b/java/com/google/gerrit/elasticsearch/bulk/IndexRequest.java index b131501..c571a0e 100644 --- a/java/com/google/gerrit/elasticsearch/bulk/IndexRequest.java +++ b/java/com/google/gerrit/elasticsearch/bulk/IndexRequest.java
@@ -14,9 +14,11 @@ package com.google.gerrit.elasticsearch.bulk; +import com.google.gerrit.elasticsearch.ElasticQueryAdapter; + public class IndexRequest extends ActionRequest { - public IndexRequest(String id, String index, String type) { - super("index", id, index, type); + public IndexRequest(String id, String index, String type, ElasticQueryAdapter adapter) { + super("index", id, index, type, adapter); } }
diff --git a/javatests/com/google/gerrit/elasticsearch/ElasticContainer.java b/javatests/com/google/gerrit/elasticsearch/ElasticContainer.java index a7a23c3..c78f7c0 100644 --- a/javatests/com/google/gerrit/elasticsearch/ElasticContainer.java +++ b/javatests/com/google/gerrit/elasticsearch/ElasticContainer.java
@@ -47,7 +47,7 @@ case V5_6: return "elasticsearch:5.6.9-alpine"; case V6_2: - return "docker.elastic.co/elasticsearch/elasticsearch:6.2.4"; + return "docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.4"; } throw new IllegalStateException("No tests for version: " + version.name()); }
diff --git a/javatests/com/google/gerrit/elasticsearch/ElasticV6QueryAccountsTest.java b/javatests/com/google/gerrit/elasticsearch/ElasticV6QueryAccountsTest.java new file mode 100644 index 0000000..db710f6 --- /dev/null +++ b/javatests/com/google/gerrit/elasticsearch/ElasticV6QueryAccountsTest.java
@@ -0,0 +1,73 @@ +// Copyright (C) 2018 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.gerrit.elasticsearch; + +import com.google.gerrit.elasticsearch.ElasticTestUtils.ElasticNodeInfo; +import com.google.gerrit.server.query.account.AbstractQueryAccountsTest; +import com.google.gerrit.testing.ConfigSuite; +import com.google.gerrit.testing.InMemoryModule; +import com.google.gerrit.testing.IndexConfig; +import com.google.inject.Guice; +import com.google.inject.Injector; +import org.eclipse.jgit.lib.Config; +import org.junit.AfterClass; +import org.junit.BeforeClass; + +public class ElasticV6QueryAccountsTest extends AbstractQueryAccountsTest { + @ConfigSuite.Default + public static Config defaultConfig() { + return IndexConfig.createForElasticsearch(); + } + + private static ElasticNodeInfo nodeInfo; + private static ElasticContainer<?> container; + + @BeforeClass + public static void startIndexService() { + if (nodeInfo != null) { + // do not start Elasticsearch twice + return; + } + + container = ElasticContainer.createAndStart(ElasticVersion.V6_2); + nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort()); + } + + @AfterClass + public static void stopElasticsearchServer() { + if (container != null) { + container.stop(); + } + } + + private String testName() { + return testName.getMethodName().toLowerCase() + "_"; + } + + @Override + protected void initAfterLifecycleStart() throws Exception { + super.initAfterLifecycleStart(); + ElasticTestUtils.createAllIndexes(injector); + } + + @Override + protected Injector createInjector() { + Config elasticsearchConfig = new Config(config); + InMemoryModule.setDefaults(elasticsearchConfig); + String indicesPrefix = testName(); + ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix); + return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration)); + } +}
diff --git a/javatests/com/google/gerrit/elasticsearch/ElasticV6QueryChangesTest.java b/javatests/com/google/gerrit/elasticsearch/ElasticV6QueryChangesTest.java new file mode 100644 index 0000000..043de4e --- /dev/null +++ b/javatests/com/google/gerrit/elasticsearch/ElasticV6QueryChangesTest.java
@@ -0,0 +1,73 @@ +// Copyright (C) 2018 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.gerrit.elasticsearch; + +import com.google.gerrit.elasticsearch.ElasticTestUtils.ElasticNodeInfo; +import com.google.gerrit.server.query.change.AbstractQueryChangesTest; +import com.google.gerrit.testing.ConfigSuite; +import com.google.gerrit.testing.InMemoryModule; +import com.google.gerrit.testing.IndexConfig; +import com.google.inject.Guice; +import com.google.inject.Injector; +import org.eclipse.jgit.lib.Config; +import org.junit.AfterClass; +import org.junit.BeforeClass; + +public class ElasticV6QueryChangesTest extends AbstractQueryChangesTest { + @ConfigSuite.Default + public static Config defaultConfig() { + return IndexConfig.createForElasticsearch(); + } + + private static ElasticNodeInfo nodeInfo; + private static ElasticContainer<?> container; + + @BeforeClass + public static void startIndexService() { + if (nodeInfo != null) { + // do not start Elasticsearch twice + return; + } + + container = ElasticContainer.createAndStart(ElasticVersion.V6_2); + nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort()); + } + + @AfterClass + public static void stopElasticsearchServer() { + if (container != null) { + container.stop(); + } + } + + private String testName() { + return testName.getMethodName().toLowerCase() + "_"; + } + + @Override + protected void initAfterLifecycleStart() throws Exception { + super.initAfterLifecycleStart(); + ElasticTestUtils.createAllIndexes(injector); + } + + @Override + protected Injector createInjector() { + Config elasticsearchConfig = new Config(config); + InMemoryModule.setDefaults(elasticsearchConfig); + String indicesPrefix = testName(); + ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix); + return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration)); + } +}
diff --git a/javatests/com/google/gerrit/elasticsearch/ElasticV6QueryGroupsTest.java b/javatests/com/google/gerrit/elasticsearch/ElasticV6QueryGroupsTest.java new file mode 100644 index 0000000..b126c9d --- /dev/null +++ b/javatests/com/google/gerrit/elasticsearch/ElasticV6QueryGroupsTest.java
@@ -0,0 +1,73 @@ +// Copyright (C) 2018 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.gerrit.elasticsearch; + +import com.google.gerrit.elasticsearch.ElasticTestUtils.ElasticNodeInfo; +import com.google.gerrit.server.query.group.AbstractQueryGroupsTest; +import com.google.gerrit.testing.ConfigSuite; +import com.google.gerrit.testing.InMemoryModule; +import com.google.gerrit.testing.IndexConfig; +import com.google.inject.Guice; +import com.google.inject.Injector; +import org.eclipse.jgit.lib.Config; +import org.junit.AfterClass; +import org.junit.BeforeClass; + +public class ElasticV6QueryGroupsTest extends AbstractQueryGroupsTest { + @ConfigSuite.Default + public static Config defaultConfig() { + return IndexConfig.createForElasticsearch(); + } + + private static ElasticNodeInfo nodeInfo; + private static ElasticContainer<?> container; + + @BeforeClass + public static void startIndexService() { + if (nodeInfo != null) { + // do not start Elasticsearch twice + return; + } + + container = ElasticContainer.createAndStart(ElasticVersion.V6_2); + nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort()); + } + + @AfterClass + public static void stopElasticsearchServer() { + if (container != null) { + container.stop(); + } + } + + private String testName() { + return testName.getMethodName().toLowerCase() + "_"; + } + + @Override + protected void initAfterLifecycleStart() throws Exception { + super.initAfterLifecycleStart(); + ElasticTestUtils.createAllIndexes(injector); + } + + @Override + protected Injector createInjector() { + Config elasticsearchConfig = new Config(config); + InMemoryModule.setDefaults(elasticsearchConfig); + String indicesPrefix = testName(); + ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix); + return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration)); + } +}