Merge branch 'stable-2.16' into stable-3.0

* stable-2.16:
  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

Change-Id: I7046d6cf87282cc2b5a8dda6110cb3854b18bab0
This commit is contained in:
Luca Milanesio
2020-04-02 12:38:57 +01:00
14 changed files with 69 additions and 168 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,20 +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().getHostName(), container.getHttpHost().getPort());
}
@AfterClass
@@ -65,8 +58,7 @@ public class ElasticV6QueryProjectsTest extends AbstractQueryProjectsTest {
Config elasticsearchConfig = new Config(config);
InMemoryModule.setDefaults(elasticsearchConfig);
String indicesPrefix = getSanitizedMethodName();
ElasticTestUtils.configure(
elasticsearchConfig, nodeInfo.hostname, nodeInfo.port, indicesPrefix);
ElasticTestUtils.configure(elasticsearchConfig, container, indicesPrefix);
return Guice.createInjector(new InMemoryModule(elasticsearchConfig));
}
}