Use nio transport in x-pack tests (elastic/x-pack-elasticsearch#2159)

This commit is related to elastic/elasticsearch#25986. It updates x-pack
to use the randomized transport work in elasticsearch.

Original commit: elastic/x-pack-elasticsearch@eba2c0f815
This commit is contained in:
Tim Brooks 2017-08-02 11:29:53 -05:00 committed by GitHub
parent bf92450fc4
commit dd899956e2
4 changed files with 14 additions and 19 deletions

View File

@ -31,7 +31,6 @@ import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.NodeConfigurationSource;
import org.elasticsearch.test.TestCluster;
import org.elasticsearch.test.discovery.TestZenDiscovery;
import org.elasticsearch.transport.MockTcpTransportPlugin;
import org.elasticsearch.tribe.TribePlugin;
import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.XPackSettings;
@ -62,7 +61,7 @@ public abstract class TribeTransportTestCase extends ESIntegTestCase {
protected final Settings nodeSettings(int nodeOrdinal) {
final Settings.Builder builder = Settings.builder()
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
.put("transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME);
.put("transport.type", getTestTransportType());
List<String> enabledFeatures = enabledFeatures();
builder.put(XPackSettings.SECURITY_ENABLED.getKey(), enabledFeatures.contains(XPackPlugin.SECURITY));
builder.put(XPackSettings.MONITORING_ENABLED.getKey(), enabledFeatures.contains(XPackPlugin.MONITORING));
@ -178,8 +177,8 @@ public abstract class TribeTransportTestCase extends ESIntegTestCase {
Settings merged = Settings.builder()
.put("tribe.t1.cluster.name", internalCluster().getClusterName())
.put("tribe.t2.cluster.name", cluster2.getClusterName())
.put("tribe.t1.transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
.put("tribe.t2.transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
.put("tribe.t1.transport.type", getTestTransportType())
.put("tribe.t2.transport.type", getTestTransportType())
.put("tribe.blocks.write", false)
.put(tribe1Defaults.build())
.put(tribe2Defaults.build())
@ -195,11 +194,11 @@ public abstract class TribeTransportTestCase extends ESIntegTestCase {
.put("tribe.t1." + MachineLearning.AUTODETECT_PROCESS.getKey(), false)
.put("tribe.t2." + MachineLearning.AUTODETECT_PROCESS.getKey(), false)
.put("node.name", "tribe_node") // make sure we can identify threads from this node
.put("transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
.put("transport.type", getTestTransportType())
.build();
final List<Class<? extends Plugin>> mockPlugins = Arrays.asList(MockTribePlugin.class, TribeAwareTestZenDiscoveryPlugin.class,
MockTcpTransportPlugin.class, XPackPlugin.class);
getTestTransportPlugin(), XPackPlugin.class);
final Node tribeNode = new MockNode(merged, mockPlugins).start();
Client tribeClient = tribeNode.client();

View File

@ -162,8 +162,7 @@ public class SecuritySettingsSource extends ClusterDiscoveryConfiguration.Unicas
@Override
public Collection<Class<? extends Plugin>> nodePlugins() {
return Arrays.asList(xpackPluginClass(),
Netty4Plugin.class, ReindexPlugin.class, CommonAnalysisPlugin.class);
return Arrays.asList(xpackPluginClass(), Netty4Plugin.class, ReindexPlugin.class, CommonAnalysisPlugin.class);
}
@Override

View File

@ -8,12 +8,12 @@ package org.elasticsearch.xpack;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.transport.MockTcpTransportPlugin;
import org.elasticsearch.transport.nio.NioTransportPlugin;
import java.util.Arrays;
import java.util.Collection;
import static org.elasticsearch.test.ESTestCase.getTestTransportPlugin;
/**
* TransportClient.Builder that installs the XPackPlugin by default.
*/
@ -26,7 +26,6 @@ public class TestXPackTransportClient extends TransportClient {
}
public TestXPackTransportClient(Settings settings, Collection<Class<? extends Plugin>> plugins) {
super(settings, Settings.EMPTY, addPlugins(plugins, XPackPlugin.class, NioTransportPlugin.class, MockTcpTransportPlugin.class),
null);
super(settings, Settings.EMPTY, addPlugins(plugins, XPackPlugin.class, getTestTransportPlugin()), null);
}
}

View File

@ -33,7 +33,6 @@ import org.elasticsearch.test.SecurityIntegTestCase;
import org.elasticsearch.test.SecuritySettingsSource;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.MockTcpTransportPlugin;
import org.elasticsearch.transport.TransportInfo;
import org.elasticsearch.transport.TransportMessage;
import org.elasticsearch.transport.TransportRequest;
@ -145,7 +144,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
.put(MachineLearning.AUTODETECT_PROCESS.getKey(), false)
.put(XPackSettings.SECURITY_ENABLED.getKey(), useSecurity);
if (useSecurity == false && builder.get(NetworkModule.TRANSPORT_TYPE_KEY) == null) {
builder.put(NetworkModule.TRANSPORT_TYPE_KEY, MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME);
builder.put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType());
}
return builder.build();
}
@ -159,7 +158,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
.put(XPackSettings.SECURITY_ENABLED.getKey(), false)
.put(super.transportClientSettings());
if (builder.get(NetworkModule.TRANSPORT_TYPE_KEY) == null) {
builder.put(NetworkModule.TRANSPORT_TYPE_KEY, MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME);
builder.put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType());
}
return builder.build();
}
@ -176,7 +175,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
Set<Class<? extends Plugin>> mockPlugins = new HashSet<>(getMockPlugins());
if (useSecurity == false) {
mockPlugins.add(MockTcpTransportPlugin.class);
mockPlugins.add(getTestTransportPlugin());
}
remoteCluster = new InternalTestCluster(randomLong(), createTempDir(), false, true, numNodes, numNodes, cluster2Name,
cluster2SettingsSource, 0, false, SECOND_CLUSTER_NODE_PREFIX, mockPlugins,
@ -197,8 +196,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
cluster2SettingsSource.addClientSSLSettings(builder, "xpack.security.audit.index.client.");
}
if (useSecurity == false && builder.get(NetworkModule.TRANSPORT_TYPE_KEY) == null) {
builder.put("xpack.security.audit.index.client." + NetworkModule.TRANSPORT_TYPE_KEY,
MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME);
builder.put("xpack.security.audit.index.client." + NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType());
}
remoteSettings = builder.build();
}
@ -306,7 +304,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
@Override
List<Class<? extends Plugin>> remoteTransportClientPlugins() {
return Arrays.asList(XPackPlugin.class, MockTcpTransportPlugin.class);
return Arrays.asList(XPackPlugin.class, getTestTransportPlugin());
}
};
auditor.start(true);