Merge branch 'stable-2.16' into stable-3.0
* stable-2.16: Elasticsearch: Unharcode localhost for container's Change-Id: Id798846df3bc48b4266cec545b2ad607a1a4a06b
This commit is contained in:
@@ -25,16 +25,19 @@ import org.eclipse.jgit.lib.Config;
|
||||
|
||||
public final class ElasticTestUtils {
|
||||
public static class ElasticNodeInfo {
|
||||
public final String hostname;
|
||||
public final int port;
|
||||
|
||||
public ElasticNodeInfo(int port) {
|
||||
public ElasticNodeInfo(String hostname, int port) {
|
||||
this.hostname = hostname;
|
||||
this.port = port;
|
||||
}
|
||||
}
|
||||
|
||||
public static void configure(Config config, int port, String prefix, ElasticVersion version) {
|
||||
public static void configure(
|
||||
Config config, String hostname, int port, String prefix, ElasticVersion version) {
|
||||
config.setEnum("index", null, "type", IndexType.ELASTICSEARCH);
|
||||
config.setString("elasticsearch", null, "server", "http://localhost:" + port);
|
||||
config.setString("elasticsearch", null, "server", "http://" + hostname + ":" + port);
|
||||
config.setString("elasticsearch", null, "prefix", prefix);
|
||||
config.setInt("index", null, "maxLimit", 10000);
|
||||
String password = version == ElasticVersion.V5_6 ? "changeme" : null;
|
||||
@@ -43,8 +46,8 @@ public final class ElasticTestUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void configure(Config config, int port, String prefix) {
|
||||
configure(config, port, prefix, null);
|
||||
public static void configure(Config config, String hostname, int port, String prefix) {
|
||||
configure(config, hostname, port, prefix, null);
|
||||
}
|
||||
|
||||
public static void createAllIndexes(Injector injector) {
|
||||
@@ -56,12 +59,13 @@ public final class ElasticTestUtils {
|
||||
}
|
||||
|
||||
public static Config getConfig(ElasticVersion version) {
|
||||
ElasticNodeInfo elasticNodeInfo;
|
||||
ElasticContainer container = ElasticContainer.createAndStart(version);
|
||||
elasticNodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
|
||||
ElasticNodeInfo elasticNodeInfo =
|
||||
new ElasticNodeInfo(
|
||||
container.getHttpHost().getHostName(), container.getHttpHost().getPort());
|
||||
String indicesPrefix = UUID.randomUUID().toString();
|
||||
Config cfg = new Config();
|
||||
configure(cfg, elasticNodeInfo.port, indicesPrefix, version);
|
||||
configure(cfg, elasticNodeInfo.hostname, elasticNodeInfo.port, indicesPrefix, version);
|
||||
return cfg;
|
||||
}
|
||||
|
||||
|
@@ -42,7 +42,9 @@ public class ElasticV5QueryAccountsTest extends AbstractQueryAccountsTest {
|
||||
}
|
||||
|
||||
container = ElasticContainer.createAndStart(ElasticVersion.V5_6);
|
||||
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
|
||||
nodeInfo =
|
||||
new ElasticNodeInfo(
|
||||
container.getHttpHost().getHostName(), container.getHttpHost().getPort());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@@ -64,7 +66,7 @@ public class ElasticV5QueryAccountsTest extends AbstractQueryAccountsTest {
|
||||
InMemoryModule.setDefaults(elasticsearchConfig);
|
||||
String indicesPrefix = getSanitizedMethodName();
|
||||
ElasticTestUtils.configure(
|
||||
elasticsearchConfig, nodeInfo.port, indicesPrefix, ElasticVersion.V5_6);
|
||||
elasticsearchConfig, nodeInfo.hostname, nodeInfo.port, indicesPrefix, ElasticVersion.V5_6);
|
||||
return Guice.createInjector(new InMemoryModule(elasticsearchConfig));
|
||||
}
|
||||
}
|
||||
|
@@ -42,7 +42,9 @@ public class ElasticV5QueryChangesTest extends AbstractQueryChangesTest {
|
||||
}
|
||||
|
||||
container = ElasticContainer.createAndStart(ElasticVersion.V5_6);
|
||||
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
|
||||
nodeInfo =
|
||||
new ElasticNodeInfo(
|
||||
container.getHttpHost().getHostName(), container.getHttpHost().getPort());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@@ -64,7 +66,7 @@ public class ElasticV5QueryChangesTest extends AbstractQueryChangesTest {
|
||||
InMemoryModule.setDefaults(elasticsearchConfig);
|
||||
String indicesPrefix = getSanitizedMethodName();
|
||||
ElasticTestUtils.configure(
|
||||
elasticsearchConfig, nodeInfo.port, indicesPrefix, ElasticVersion.V5_6);
|
||||
elasticsearchConfig, nodeInfo.hostname, nodeInfo.port, indicesPrefix, ElasticVersion.V5_6);
|
||||
return Guice.createInjector(new InMemoryModule(elasticsearchConfig));
|
||||
}
|
||||
}
|
||||
|
@@ -42,7 +42,9 @@ public class ElasticV5QueryGroupsTest extends AbstractQueryGroupsTest {
|
||||
}
|
||||
|
||||
container = ElasticContainer.createAndStart(ElasticVersion.V5_6);
|
||||
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
|
||||
nodeInfo =
|
||||
new ElasticNodeInfo(
|
||||
container.getHttpHost().getHostName(), container.getHttpHost().getPort());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@@ -64,7 +66,7 @@ public class ElasticV5QueryGroupsTest extends AbstractQueryGroupsTest {
|
||||
InMemoryModule.setDefaults(elasticsearchConfig);
|
||||
String indicesPrefix = getSanitizedMethodName();
|
||||
ElasticTestUtils.configure(
|
||||
elasticsearchConfig, nodeInfo.port, indicesPrefix, ElasticVersion.V5_6);
|
||||
elasticsearchConfig, nodeInfo.hostname, nodeInfo.port, indicesPrefix, ElasticVersion.V5_6);
|
||||
return Guice.createInjector(new InMemoryModule(elasticsearchConfig));
|
||||
}
|
||||
}
|
||||
|
@@ -42,7 +42,9 @@ public class ElasticV5QueryProjectsTest extends AbstractQueryProjectsTest {
|
||||
}
|
||||
|
||||
container = ElasticContainer.createAndStart(ElasticVersion.V5_6);
|
||||
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
|
||||
nodeInfo =
|
||||
new ElasticNodeInfo(
|
||||
container.getHttpHost().getHostName(), container.getHttpHost().getPort());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@@ -64,7 +66,7 @@ public class ElasticV5QueryProjectsTest extends AbstractQueryProjectsTest {
|
||||
InMemoryModule.setDefaults(elasticsearchConfig);
|
||||
String indicesPrefix = getSanitizedMethodName();
|
||||
ElasticTestUtils.configure(
|
||||
elasticsearchConfig, nodeInfo.port, indicesPrefix, ElasticVersion.V5_6);
|
||||
elasticsearchConfig, nodeInfo.hostname, nodeInfo.port, indicesPrefix, ElasticVersion.V5_6);
|
||||
return Guice.createInjector(new InMemoryModule(elasticsearchConfig));
|
||||
}
|
||||
}
|
||||
|
@@ -42,7 +42,9 @@ public class ElasticV6QueryAccountsTest extends AbstractQueryAccountsTest {
|
||||
}
|
||||
|
||||
container = ElasticContainer.createAndStart(ElasticVersion.V6_8);
|
||||
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
|
||||
nodeInfo =
|
||||
new ElasticNodeInfo(
|
||||
container.getHttpHost().getHostName(), container.getHttpHost().getPort());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@@ -63,7 +65,8 @@ public class ElasticV6QueryAccountsTest extends AbstractQueryAccountsTest {
|
||||
Config elasticsearchConfig = new Config(config);
|
||||
InMemoryModule.setDefaults(elasticsearchConfig);
|
||||
String indicesPrefix = getSanitizedMethodName();
|
||||
ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix);
|
||||
ElasticTestUtils.configure(
|
||||
elasticsearchConfig, nodeInfo.hostname, nodeInfo.port, indicesPrefix);
|
||||
return Guice.createInjector(new InMemoryModule(elasticsearchConfig));
|
||||
}
|
||||
}
|
||||
|
@@ -48,7 +48,9 @@ public class ElasticV6QueryChangesTest extends AbstractQueryChangesTest {
|
||||
}
|
||||
|
||||
container = ElasticContainer.createAndStart(ElasticVersion.V6_8);
|
||||
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
|
||||
nodeInfo =
|
||||
new ElasticNodeInfo(
|
||||
container.getHttpHost().getHostName(), container.getHttpHost().getPort());
|
||||
client = HttpAsyncClients.createDefault();
|
||||
client.start();
|
||||
}
|
||||
@@ -81,7 +83,8 @@ public class ElasticV6QueryChangesTest extends AbstractQueryChangesTest {
|
||||
Config elasticsearchConfig = new Config(config);
|
||||
InMemoryModule.setDefaults(elasticsearchConfig);
|
||||
String indicesPrefix = getSanitizedMethodName();
|
||||
ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix);
|
||||
ElasticTestUtils.configure(
|
||||
elasticsearchConfig, nodeInfo.hostname, nodeInfo.port, indicesPrefix);
|
||||
return Guice.createInjector(new InMemoryModule(elasticsearchConfig));
|
||||
}
|
||||
}
|
||||
|
@@ -42,7 +42,9 @@ public class ElasticV6QueryGroupsTest extends AbstractQueryGroupsTest {
|
||||
}
|
||||
|
||||
container = ElasticContainer.createAndStart(ElasticVersion.V6_8);
|
||||
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
|
||||
nodeInfo =
|
||||
new ElasticNodeInfo(
|
||||
container.getHttpHost().getHostName(), container.getHttpHost().getPort());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@@ -63,7 +65,8 @@ public class ElasticV6QueryGroupsTest extends AbstractQueryGroupsTest {
|
||||
Config elasticsearchConfig = new Config(config);
|
||||
InMemoryModule.setDefaults(elasticsearchConfig);
|
||||
String indicesPrefix = getSanitizedMethodName();
|
||||
ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix);
|
||||
ElasticTestUtils.configure(
|
||||
elasticsearchConfig, nodeInfo.hostname, nodeInfo.port, indicesPrefix);
|
||||
return Guice.createInjector(new InMemoryModule(elasticsearchConfig));
|
||||
}
|
||||
}
|
||||
|
@@ -42,7 +42,9 @@ public class ElasticV6QueryProjectsTest extends AbstractQueryProjectsTest {
|
||||
}
|
||||
|
||||
container = ElasticContainer.createAndStart(ElasticVersion.V6_8);
|
||||
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
|
||||
nodeInfo =
|
||||
new ElasticNodeInfo(
|
||||
container.getHttpHost().getHostName(), container.getHttpHost().getPort());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@@ -63,7 +65,8 @@ public class ElasticV6QueryProjectsTest extends AbstractQueryProjectsTest {
|
||||
Config elasticsearchConfig = new Config(config);
|
||||
InMemoryModule.setDefaults(elasticsearchConfig);
|
||||
String indicesPrefix = getSanitizedMethodName();
|
||||
ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix);
|
||||
ElasticTestUtils.configure(
|
||||
elasticsearchConfig, nodeInfo.hostname, nodeInfo.port, indicesPrefix);
|
||||
return Guice.createInjector(new InMemoryModule(elasticsearchConfig));
|
||||
}
|
||||
}
|
||||
|
@@ -42,7 +42,9 @@ public class ElasticV7QueryAccountsTest extends AbstractQueryAccountsTest {
|
||||
}
|
||||
|
||||
container = ElasticContainer.createAndStart(ElasticVersion.V7_6);
|
||||
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
|
||||
nodeInfo =
|
||||
new ElasticNodeInfo(
|
||||
container.getHttpHost().getHostName(), container.getHttpHost().getPort());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@@ -63,7 +65,8 @@ public class ElasticV7QueryAccountsTest extends AbstractQueryAccountsTest {
|
||||
Config elasticsearchConfig = new Config(config);
|
||||
InMemoryModule.setDefaults(elasticsearchConfig);
|
||||
String indicesPrefix = getSanitizedMethodName();
|
||||
ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix);
|
||||
ElasticTestUtils.configure(
|
||||
elasticsearchConfig, nodeInfo.hostname, nodeInfo.port, indicesPrefix);
|
||||
return Guice.createInjector(new InMemoryModule(elasticsearchConfig));
|
||||
}
|
||||
}
|
||||
|
@@ -48,7 +48,9 @@ public class ElasticV7QueryChangesTest extends AbstractQueryChangesTest {
|
||||
}
|
||||
|
||||
container = ElasticContainer.createAndStart(ElasticVersion.V7_6);
|
||||
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
|
||||
nodeInfo =
|
||||
new ElasticNodeInfo(
|
||||
container.getHttpHost().getHostName(), container.getHttpHost().getPort());
|
||||
client = HttpAsyncClients.createDefault();
|
||||
client.start();
|
||||
}
|
||||
@@ -81,7 +83,8 @@ public class ElasticV7QueryChangesTest extends AbstractQueryChangesTest {
|
||||
Config elasticsearchConfig = new Config(config);
|
||||
InMemoryModule.setDefaults(elasticsearchConfig);
|
||||
String indicesPrefix = getSanitizedMethodName();
|
||||
ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix);
|
||||
ElasticTestUtils.configure(
|
||||
elasticsearchConfig, nodeInfo.hostname, nodeInfo.port, indicesPrefix);
|
||||
return Guice.createInjector(new InMemoryModule(elasticsearchConfig));
|
||||
}
|
||||
}
|
||||
|
@@ -42,7 +42,9 @@ public class ElasticV7QueryGroupsTest extends AbstractQueryGroupsTest {
|
||||
}
|
||||
|
||||
container = ElasticContainer.createAndStart(ElasticVersion.V7_6);
|
||||
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
|
||||
nodeInfo =
|
||||
new ElasticNodeInfo(
|
||||
container.getHttpHost().getHostName(), container.getHttpHost().getPort());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@@ -63,7 +65,8 @@ public class ElasticV7QueryGroupsTest extends AbstractQueryGroupsTest {
|
||||
Config elasticsearchConfig = new Config(config);
|
||||
InMemoryModule.setDefaults(elasticsearchConfig);
|
||||
String indicesPrefix = getSanitizedMethodName();
|
||||
ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix);
|
||||
ElasticTestUtils.configure(
|
||||
elasticsearchConfig, nodeInfo.hostname, nodeInfo.port, indicesPrefix);
|
||||
return Guice.createInjector(new InMemoryModule(elasticsearchConfig));
|
||||
}
|
||||
}
|
||||
|
@@ -42,7 +42,9 @@ public class ElasticV7QueryProjectsTest extends AbstractQueryProjectsTest {
|
||||
}
|
||||
|
||||
container = ElasticContainer.createAndStart(ElasticVersion.V7_6);
|
||||
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
|
||||
nodeInfo =
|
||||
new ElasticNodeInfo(
|
||||
container.getHttpHost().getHostName(), container.getHttpHost().getPort());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@@ -63,7 +65,8 @@ public class ElasticV7QueryProjectsTest extends AbstractQueryProjectsTest {
|
||||
Config elasticsearchConfig = new Config(config);
|
||||
InMemoryModule.setDefaults(elasticsearchConfig);
|
||||
String indicesPrefix = getSanitizedMethodName();
|
||||
ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix);
|
||||
ElasticTestUtils.configure(
|
||||
elasticsearchConfig, nodeInfo.hostname, nodeInfo.port, indicesPrefix);
|
||||
return Guice.createInjector(new InMemoryModule(elasticsearchConfig));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user