From ae5b963e976ead356fbb61673dbb77c28030e001 Mon Sep 17 00:00:00 2001 From: Igor Motov Date: Thu, 16 Jun 2011 23:03:29 -0400 Subject: [PATCH] Specify a unique cluster name for all Integration tests --- .../test/integration/AbstractNodesTests.java | 6 +++++- .../transport/ClientTransportTwoNodesSearchTests.java | 7 ++++++- .../client/transport/DiscoveryTransportClientTests.java | 6 +++++- .../transport/TransportClientDocumentActionsTests.java | 9 +++++++-- .../TransportClientMoreLikeThisActionTests.java | 9 +++++++-- .../TransportClientSniffDocumentActionsTests.java | 9 +++++++-- .../elasticsearch/hadoop/gateway/HdfsGatewayTests.java | 2 ++ .../script/groovy/GroovyScriptSearchTests.java | 6 +++++- .../script/javascript/JavaScriptScriptSearchTests.java | 6 +++++- .../script/python/PythonScriptSearchTests.java | 6 +++++- .../test/SimpleAttachmentIntegrationTests.java | 5 ++++- .../memcached/test/AbstractMemcachedActionsTests.java | 5 ++++- .../org/elasticsearch/thrift/test/SimpleThriftTests.java | 5 ++++- 13 files changed, 66 insertions(+), 15 deletions(-) diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/AbstractNodesTests.java b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/AbstractNodesTests.java index ec0280f6c3e..0956cebbe71 100644 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/AbstractNodesTests.java +++ b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/AbstractNodesTests.java @@ -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 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()); diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/ClientTransportTwoNodesSearchTests.java b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/ClientTransportTwoNodesSearchTests.java index a2948fb2d25..f35c3341cd4 100644 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/ClientTransportTwoNodesSearchTests.java +++ b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/ClientTransportTwoNodesSearchTests.java @@ -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; } diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/DiscoveryTransportClientTests.java b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/DiscoveryTransportClientTests.java index fb2db2a8041..b210866c79a 100644 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/DiscoveryTransportClientTests.java +++ b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/DiscoveryTransportClientTests.java @@ -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(); diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientDocumentActionsTests.java b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientDocumentActionsTests.java index 97935f16e3d..11d6b9c0d31 100644 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientDocumentActionsTests.java +++ b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientDocumentActionsTests.java @@ -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; } diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientMoreLikeThisActionTests.java b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientMoreLikeThisActionTests.java index 10b5e30abd1..120877e3295 100644 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientMoreLikeThisActionTests.java +++ b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientMoreLikeThisActionTests.java @@ -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; } diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientSniffDocumentActionsTests.java b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientSniffDocumentActionsTests.java index f6909dbb511..b88ed6bba80 100644 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientSniffDocumentActionsTests.java +++ b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientSniffDocumentActionsTests.java @@ -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; } diff --git a/plugins/hadoop/src/test/java/org/elasticsearch/hadoop/gateway/HdfsGatewayTests.java b/plugins/hadoop/src/test/java/org/elasticsearch/hadoop/gateway/HdfsGatewayTests.java index 914f2f5b81a..1c23bb2f263 100644 --- a/plugins/hadoop/src/test/java/org/elasticsearch/hadoop/gateway/HdfsGatewayTests.java +++ b/plugins/hadoop/src/test/java/org/elasticsearch/hadoop/gateway/HdfsGatewayTests.java @@ -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") diff --git a/plugins/lang/groovy/src/test/java/org/elasticsearch/script/groovy/GroovyScriptSearchTests.java b/plugins/lang/groovy/src/test/java/org/elasticsearch/script/groovy/GroovyScriptSearchTests.java index 04b12fe66bd..36ce7848075 100644 --- a/plugins/lang/groovy/src/test/java/org/elasticsearch/script/groovy/GroovyScriptSearchTests.java +++ b/plugins/lang/groovy/src/test/java/org/elasticsearch/script/groovy/GroovyScriptSearchTests.java @@ -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(); } diff --git a/plugins/lang/javascript/src/test/java/org/elasticsearch/script/javascript/JavaScriptScriptSearchTests.java b/plugins/lang/javascript/src/test/java/org/elasticsearch/script/javascript/JavaScriptScriptSearchTests.java index 023130a7abc..91d208de858 100644 --- a/plugins/lang/javascript/src/test/java/org/elasticsearch/script/javascript/JavaScriptScriptSearchTests.java +++ b/plugins/lang/javascript/src/test/java/org/elasticsearch/script/javascript/JavaScriptScriptSearchTests.java @@ -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(); } diff --git a/plugins/lang/python/src/test/java/org/elasticsearch/script/python/PythonScriptSearchTests.java b/plugins/lang/python/src/test/java/org/elasticsearch/script/python/PythonScriptSearchTests.java index fc394a42e13..f0af0192e1f 100644 --- a/plugins/lang/python/src/test/java/org/elasticsearch/script/python/PythonScriptSearchTests.java +++ b/plugins/lang/python/src/test/java/org/elasticsearch/script/python/PythonScriptSearchTests.java @@ -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(); } diff --git a/plugins/mapper/attachments/src/test/java/org/elasticsearch/plugin/mapper/attachments/test/SimpleAttachmentIntegrationTests.java b/plugins/mapper/attachments/src/test/java/org/elasticsearch/plugin/mapper/attachments/test/SimpleAttachmentIntegrationTests.java index e7d97ca2388..2b217f44fe0 100644 --- a/plugins/mapper/attachments/src/test/java/org/elasticsearch/plugin/mapper/attachments/test/SimpleAttachmentIntegrationTests.java +++ b/plugins/mapper/attachments/src/test/java/org/elasticsearch/plugin/mapper/attachments/test/SimpleAttachmentIntegrationTests.java @@ -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() { diff --git a/plugins/transport/memcached/src/test/java/org/elasticsearch/memcached/test/AbstractMemcachedActionsTests.java b/plugins/transport/memcached/src/test/java/org/elasticsearch/memcached/test/AbstractMemcachedActionsTests.java index 2cd809f1919..ea08c82083e 100644 --- a/plugins/transport/memcached/src/test/java/org/elasticsearch/memcached/test/AbstractMemcachedActionsTests.java +++ b/plugins/transport/memcached/src/test/java/org/elasticsearch/memcached/test/AbstractMemcachedActionsTests.java @@ -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(); } diff --git a/plugins/transport/thrift/src/test/java/org/elasticsearch/thrift/test/SimpleThriftTests.java b/plugins/transport/thrift/src/test/java/org/elasticsearch/thrift/test/SimpleThriftTests.java index a238f860951..a23c65215d7 100644 --- a/plugins/transport/thrift/src/test/java/org/elasticsearch/thrift/test/SimpleThriftTests.java +++ b/plugins/transport/thrift/src/test/java/org/elasticsearch/thrift/test/SimpleThriftTests.java @@ -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);