Merge branch 'stable-3.0' into stable-3.1

* stable-3.0:
  Do not assume ES is running on localhost in tests
  Simplify creation of Elasticsearch containers in tests
  Add debug logs for automatic account creation case
  Elasticsearch: Unharcode localhost for container's

Change-Id: I73ca4d522346712d75b154115f1ece4638951641
This commit is contained in:
Luca Milanesio
2020-04-02 13:05:19 +01:00
14 changed files with 71 additions and 136 deletions

View File

@@ -14,7 +14,6 @@
package com.google.gerrit.elasticsearch;
import com.google.gerrit.elasticsearch.ElasticTestUtils.ElasticNodeInfo;
import com.google.gerrit.server.query.project.AbstractQueryProjectsTest;
import com.google.gerrit.testing.ConfigSuite;
import com.google.gerrit.testing.InMemoryModule;
@@ -31,18 +30,14 @@ public class ElasticV6QueryProjectsTest extends AbstractQueryProjectsTest {
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;
if (container == null) {
// Only start Elasticsearch once
container = ElasticContainer.createAndStart(ElasticVersion.V6_8);
}
container = ElasticContainer.createAndStart(ElasticVersion.V6_8);
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
}
@AfterClass
@@ -63,7 +58,7 @@ public class ElasticV6QueryProjectsTest extends AbstractQueryProjectsTest {
Config elasticsearchConfig = new Config(config);
InMemoryModule.setDefaults(elasticsearchConfig);
String indicesPrefix = testName.getSanitizedMethodName();
ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix);
ElasticTestUtils.configure(elasticsearchConfig, container, indicesPrefix);
return Guice.createInjector(new InMemoryModule(elasticsearchConfig));
}
}