Specify a unique cluster name for all Integration tests
This commit is contained in:
parent
5540fbf7ab
commit
ae5b963e97
|
@ -22,6 +22,7 @@ package org.elasticsearch.test.integration;
|
|||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.network.NetworkUtils;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.node.Node;
|
||||
|
@ -41,7 +42,10 @@ public abstract class AbstractNodesTests {
|
|||
|
||||
private Map<String, Client> clients = newHashMap();
|
||||
|
||||
private Settings defaultSettings = ImmutableSettings.Builder.EMPTY_SETTINGS;
|
||||
private Settings defaultSettings = ImmutableSettings
|
||||
.settingsBuilder()
|
||||
.put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName())
|
||||
.build();
|
||||
|
||||
public void putDefaultSettings(Settings.Builder settings) {
|
||||
putDefaultSettings(settings.build());
|
||||
|
|
|
@ -21,6 +21,8 @@ package org.elasticsearch.test.integration.client.transport;
|
|||
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.client.transport.TransportClient;
|
||||
import org.elasticsearch.common.network.NetworkUtils;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.node.internal.InternalNode;
|
||||
import org.elasticsearch.test.integration.search.basic.TransportTwoNodesSearchTests;
|
||||
|
@ -33,7 +35,10 @@ public class ClientTransportTwoNodesSearchTests extends TransportTwoNodesSearchT
|
|||
|
||||
@Override protected Client getClient() {
|
||||
TransportAddress server1Address = ((InternalNode) node("server1")).injector().getInstance(TransportService.class).boundAddress().publishAddress();
|
||||
TransportClient client = new TransportClient();
|
||||
TransportClient client = new TransportClient(ImmutableSettings
|
||||
.settingsBuilder()
|
||||
.put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName())
|
||||
.build());
|
||||
client.addTransportAddress(server1Address);
|
||||
return client;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.elasticsearch.test.integration.client.transport;
|
||||
|
||||
import org.elasticsearch.client.transport.TransportClient;
|
||||
import org.elasticsearch.common.network.NetworkUtils;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.test.integration.AbstractNodesTests;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
|
@ -44,7 +45,10 @@ public class DiscoveryTransportClientTests extends AbstractNodesTests {
|
|||
|
||||
public void testWithDiscovery() throws Exception {
|
||||
startNode("server1");
|
||||
client = new TransportClient(ImmutableSettings.settingsBuilder().put("discovery.enabled", true).build());
|
||||
client = new TransportClient(ImmutableSettings.settingsBuilder()
|
||||
.put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName())
|
||||
.put("discovery.enabled", true)
|
||||
.build());
|
||||
// wait a bit so nodes will be discovered
|
||||
Thread.sleep(1000);
|
||||
client.admin().indices().create(createIndexRequest("test")).actionGet();
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.test.integration.client.transport;
|
|||
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.client.transport.TransportClient;
|
||||
import org.elasticsearch.common.network.NetworkUtils;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.node.internal.InternalNode;
|
||||
import org.elasticsearch.test.integration.document.DocumentActionsTests;
|
||||
|
@ -35,14 +36,18 @@ public class TransportClientDocumentActionsTests extends DocumentActionsTests {
|
|||
|
||||
@Override protected Client getClient1() {
|
||||
TransportAddress server1Address = ((InternalNode) node("server1")).injector().getInstance(TransportService.class).boundAddress().publishAddress();
|
||||
TransportClient client = new TransportClient(settingsBuilder().put("client.transport.sniff", false).build());
|
||||
TransportClient client = new TransportClient(settingsBuilder()
|
||||
.put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName())
|
||||
.put("client.transport.sniff", false).build());
|
||||
client.addTransportAddress(server1Address);
|
||||
return client;
|
||||
}
|
||||
|
||||
@Override protected Client getClient2() {
|
||||
TransportAddress server2Address = ((InternalNode) node("server2")).injector().getInstance(TransportService.class).boundAddress().publishAddress();
|
||||
TransportClient client = new TransportClient(settingsBuilder().put("client.transport.sniff", false).build());
|
||||
TransportClient client = new TransportClient(settingsBuilder()
|
||||
.put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName())
|
||||
.put("client.transport.sniff", false).build());
|
||||
client.addTransportAddress(server2Address);
|
||||
return client;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.test.integration.client.transport;
|
|||
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.client.transport.TransportClient;
|
||||
import org.elasticsearch.common.network.NetworkUtils;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.node.internal.InternalNode;
|
||||
import org.elasticsearch.test.integration.document.MoreLikeThisActionTests;
|
||||
|
@ -35,14 +36,18 @@ public class TransportClientMoreLikeThisActionTests extends MoreLikeThisActionTe
|
|||
|
||||
@Override protected Client getClient1() {
|
||||
TransportAddress server1Address = ((InternalNode) node("server1")).injector().getInstance(TransportService.class).boundAddress().publishAddress();
|
||||
TransportClient client = new TransportClient(settingsBuilder().put("discovery.enabled", false).build());
|
||||
TransportClient client = new TransportClient(settingsBuilder()
|
||||
.put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName())
|
||||
.put("discovery.enabled", false).build());
|
||||
client.addTransportAddress(server1Address);
|
||||
return client;
|
||||
}
|
||||
|
||||
@Override protected Client getClient2() {
|
||||
TransportAddress server1Address = ((InternalNode) node("server2")).injector().getInstance(TransportService.class).boundAddress().publishAddress();
|
||||
TransportClient client = new TransportClient(settingsBuilder().put("discovery.enabled", false).build());
|
||||
TransportClient client = new TransportClient(settingsBuilder()
|
||||
.put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName())
|
||||
.put("discovery.enabled", false).build());
|
||||
client.addTransportAddress(server1Address);
|
||||
return client;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.test.integration.client.transport;
|
|||
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.client.transport.TransportClient;
|
||||
import org.elasticsearch.common.network.NetworkUtils;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.node.internal.InternalNode;
|
||||
import org.elasticsearch.test.integration.document.DocumentActionsTests;
|
||||
|
@ -35,14 +36,18 @@ public class TransportClientSniffDocumentActionsTests extends DocumentActionsTes
|
|||
|
||||
@Override protected Client getClient1() {
|
||||
TransportAddress server1Address = ((InternalNode) node("server1")).injector().getInstance(TransportService.class).boundAddress().publishAddress();
|
||||
TransportClient client = new TransportClient(settingsBuilder().put("client.transport.sniff", true).build());
|
||||
TransportClient client = new TransportClient(settingsBuilder()
|
||||
.put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName())
|
||||
.put("client.transport.sniff", true).build());
|
||||
client.addTransportAddress(server1Address);
|
||||
return client;
|
||||
}
|
||||
|
||||
@Override protected Client getClient2() {
|
||||
TransportAddress server2Address = ((InternalNode) node("server2")).injector().getInstance(TransportService.class).boundAddress().publishAddress();
|
||||
TransportClient client = new TransportClient(settingsBuilder().put("client.transport.sniff", true).build());
|
||||
TransportClient client = new TransportClient(settingsBuilder()
|
||||
.put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName())
|
||||
.put("client.transport.sniff", true).build());
|
||||
client.addTransportAddress(server2Address);
|
||||
return client;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.action.get.GetResponse;
|
|||
import org.elasticsearch.client.Requests;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.network.NetworkUtils;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.gateway.Gateway;
|
||||
import org.elasticsearch.indices.IndexAlreadyExistsException;
|
||||
|
@ -63,6 +64,7 @@ public class HdfsGatewayTests {
|
|||
|
||||
private Node buildNode() {
|
||||
Settings settings = settingsBuilder()
|
||||
.put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName())
|
||||
.put("gateway.type", "hdfs")
|
||||
.put("gateway.hdfs.uri", "file:///")
|
||||
// .put("gateway.hdfs.uri", "hdfs://training-vm.local:8022")
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.elasticsearch.action.search.SearchType;
|
|||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.network.NetworkUtils;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.node.Node;
|
||||
import org.elasticsearch.node.NodeBuilder;
|
||||
|
@ -55,7 +56,10 @@ public class GroovyScriptSearchTests {
|
|||
private Client client;
|
||||
|
||||
@BeforeMethod public void createNodes() throws Exception {
|
||||
node = NodeBuilder.nodeBuilder().settings(ImmutableSettings.settingsBuilder().put("gateway.type", "none").put("number_of_shards", 1)).node();
|
||||
node = NodeBuilder.nodeBuilder().settings(ImmutableSettings.settingsBuilder()
|
||||
.put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress())
|
||||
.put("gateway.type", "none")
|
||||
.put("number_of_shards", 1)).node();
|
||||
client = node.client();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.elasticsearch.action.search.SearchType;
|
|||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.network.NetworkUtils;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.node.Node;
|
||||
import org.elasticsearch.node.NodeBuilder;
|
||||
|
@ -55,7 +56,10 @@ public class JavaScriptScriptSearchTests {
|
|||
private Client client;
|
||||
|
||||
@BeforeMethod public void createNodes() throws Exception {
|
||||
node = NodeBuilder.nodeBuilder().settings(ImmutableSettings.settingsBuilder().put("gateway.type", "none").put("number_of_shards", 1)).node();
|
||||
node = NodeBuilder.nodeBuilder().settings(ImmutableSettings.settingsBuilder()
|
||||
.put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress())
|
||||
.put("gateway.type", "none")
|
||||
.put("number_of_shards", 1)).node();
|
||||
client = node.client();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.elasticsearch.action.search.SearchType;
|
|||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.network.NetworkUtils;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.node.Node;
|
||||
import org.elasticsearch.node.NodeBuilder;
|
||||
|
@ -56,7 +57,10 @@ public class PythonScriptSearchTests {
|
|||
private Client client;
|
||||
|
||||
@BeforeMethod public void createNodes() throws Exception {
|
||||
node = NodeBuilder.nodeBuilder().settings(ImmutableSettings.settingsBuilder().put("gateway.type", "none").put("number_of_shards", 1)).node();
|
||||
node = NodeBuilder.nodeBuilder().settings(ImmutableSettings.settingsBuilder()
|
||||
.put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress())
|
||||
.put("gateway.type", "none")
|
||||
.put("number_of_shards", 1)).node();
|
||||
client = node.client();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
|||
import org.elasticsearch.action.count.CountResponse;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.network.NetworkUtils;
|
||||
import org.elasticsearch.node.Node;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
|
@ -51,7 +52,9 @@ public class SimpleAttachmentIntegrationTests {
|
|||
private Node node;
|
||||
|
||||
@BeforeClass public void setupServer() {
|
||||
node = nodeBuilder().local(true).settings(settingsBuilder().put("gateway.type", "none")).node();
|
||||
node = nodeBuilder().local(true).settings(settingsBuilder()
|
||||
.put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress())
|
||||
.put("gateway.type", "none")).node();
|
||||
}
|
||||
|
||||
@AfterClass public void closeServer() {
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.memcached.test;
|
|||
|
||||
import net.spy.memcached.MemcachedClient;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.common.network.NetworkUtils;
|
||||
import org.elasticsearch.node.Node;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
|
@ -48,7 +49,9 @@ public abstract class AbstractMemcachedActionsTests {
|
|||
|
||||
@BeforeMethod
|
||||
public void setup() throws IOException {
|
||||
node = nodeBuilder().settings(settingsBuilder().put("gateway.type", "none")).node();
|
||||
node = nodeBuilder().settings(settingsBuilder()
|
||||
.put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress())
|
||||
.put("gateway.type", "none")).node();
|
||||
memcachedClient = createMemcachedClient();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.thrift.protocol.TProtocol;
|
|||
import org.apache.thrift.transport.TSocket;
|
||||
import org.apache.thrift.transport.TTransport;
|
||||
import org.apache.thrift.transport.TTransportException;
|
||||
import org.elasticsearch.common.network.NetworkUtils;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.node.Node;
|
||||
|
@ -57,7 +58,9 @@ public class SimpleThriftTests {
|
|||
private Rest.Client client;
|
||||
|
||||
@BeforeMethod public void setup() throws IOException, TTransportException {
|
||||
node = nodeBuilder().settings(settingsBuilder().put("gateway.type", "none")).node();
|
||||
node = nodeBuilder().settings(settingsBuilder()
|
||||
.put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress())
|
||||
.put("gateway.type", "none")).node();
|
||||
transport = new TSocket("localhost", 9500);
|
||||
TProtocol protocol = new TBinaryProtocol(transport);
|
||||
client = new Rest.Client(protocol);
|
||||
|
|
Loading…
Reference in New Issue