浏览代码

Test: Fix netty multiport tests

Ensuring, that even in local mode, netty is started appropriately.
Alexander Reelsen 11 年之前
父节点
当前提交
37e606819c

+ 1 - 0
docs/reference/modules/transport.asciidoc

@@ -48,6 +48,7 @@ between all nodes. Defaults to `false`.
 It also uses the common
 It also uses the common
 <<modules-network,network settings>>.
 <<modules-network,network settings>>.
 
 
+[float]
 ==== TCP Transport Profiles
 ==== TCP Transport Profiles
 
 
 Elasticsearch allows you to bind to multiple ports on different interfaces by the use of transport profiles. See this example configuration
 Elasticsearch allows you to bind to multiple ports on different interfaces by the use of transport profiles. See this example configuration

+ 9 - 3
src/test/java/org/elasticsearch/test/transport/NettyTransportMultiPortIntegrationTests.java

@@ -26,6 +26,8 @@ import org.elasticsearch.common.transport.InetSocketTransportAddress;
 import org.elasticsearch.test.ElasticsearchIntegrationTest;
 import org.elasticsearch.test.ElasticsearchIntegrationTest;
 import org.elasticsearch.test.junit.annotations.Network;
 import org.elasticsearch.test.junit.annotations.Network;
 import org.elasticsearch.test.junit.annotations.TestLogging;
 import org.elasticsearch.test.junit.annotations.TestLogging;
+import org.elasticsearch.transport.TransportModule;
+import org.elasticsearch.transport.netty.NettyTransport;
 import org.junit.Test;
 import org.junit.Test;
 
 
 import java.util.Locale;
 import java.util.Locale;
@@ -38,17 +40,18 @@ import static org.hamcrest.Matchers.is;
 /**
 /**
  *
  *
  */
  */
-@ClusterScope(scope = Scope.SUITE, numDataNodes = 1)
+@ClusterScope(scope = Scope.SUITE, numDataNodes = 1, enableRandomBenchNodes = false)
 public class NettyTransportMultiPortIntegrationTests extends ElasticsearchIntegrationTest {
 public class NettyTransportMultiPortIntegrationTests extends ElasticsearchIntegrationTest {
 
 
     private final int randomPort = randomIntBetween(1025, 65000);
     private final int randomPort = randomIntBetween(1025, 65000);
-    private final String randomPortRange = String.format(Locale.ROOT, "%s-%s", randomPort, randomPort+100);
+    private final String randomPortRange = String.format(Locale.ROOT, "%s-%s", randomPort, randomPort+10);
 
 
     @Override
     @Override
     protected Settings nodeSettings(int nodeOrdinal) {
     protected Settings nodeSettings(int nodeOrdinal) {
         return settingsBuilder()
         return settingsBuilder()
                 .put(super.nodeSettings(nodeOrdinal))
                 .put(super.nodeSettings(nodeOrdinal))
                 .put("network.host", "127.0.0.1")
                 .put("network.host", "127.0.0.1")
+                .put(TransportModule.TRANSPORT_TYPE_KEY, NettyTransport.class.getName())
                 .put("node.mode", "network")
                 .put("node.mode", "network")
                 .put("transport.profiles.client1.port", randomPortRange)
                 .put("transport.profiles.client1.port", randomPortRange)
                 .put("transport.profiles.client1.reuse_address", true)
                 .put("transport.profiles.client1.reuse_address", true)
@@ -59,7 +62,10 @@ public class NettyTransportMultiPortIntegrationTests extends ElasticsearchIntegr
     @Network
     @Network
     @TestLogging("transport.netty:DEBUG")
     @TestLogging("transport.netty:DEBUG")
     public void testThatTransportClientCanConnect() throws Exception {
     public void testThatTransportClientCanConnect() throws Exception {
-        Settings settings = settingsBuilder().put("cluster.name", internalCluster().getClusterName()).build();
+        Settings settings = settingsBuilder()
+                .put("cluster.name", internalCluster().getClusterName())
+                .put(TransportModule.TRANSPORT_TYPE_KEY, NettyTransport.class.getName())
+                .build();
         try (TransportClient transportClient = new TransportClient(settings)) {
         try (TransportClient transportClient = new TransportClient(settings)) {
             transportClient.addTransportAddress(new InetSocketTransportAddress("localhost", randomPort));
             transportClient.addTransportAddress(new InetSocketTransportAddress("localhost", randomPort));
             ClusterHealthResponse response = transportClient.admin().cluster().prepareHealth().get();
             ClusterHealthResponse response = transportClient.admin().cluster().prepareHealth().get();