Use nio transport in test clusters (#25986)
This commit adds the nio transport as an option in place of the mock tcp transport for tests. Each test will only use one transport type. The transport type is decided by a random boolean generated inside of the `ESTestCase` class.
This commit is contained in:
parent
072281d5aa
commit
0f4f49496f
|
@ -42,7 +42,6 @@ import org.elasticsearch.plugins.Plugin;
|
|||
import org.elasticsearch.plugins.PluginsService;
|
||||
import org.elasticsearch.test.transport.MockTransportService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||
import org.elasticsearch.transport.MockTransportClient;
|
||||
import org.elasticsearch.transport.Transport;
|
||||
import org.elasticsearch.transport.TransportException;
|
||||
|
@ -53,7 +52,6 @@ import org.elasticsearch.transport.TransportRequestOptions;
|
|||
import org.elasticsearch.transport.TransportResponse;
|
||||
import org.elasticsearch.transport.TransportResponseHandler;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.transport.nio.NioTransportPlugin;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -82,7 +80,7 @@ public class TransportClientHeadersTests extends AbstractClientHeadersTestCase {
|
|||
transportService = MockTransportService.createNewService(Settings.EMPTY, Version.CURRENT, threadPool, null);
|
||||
transportService.start();
|
||||
transportService.acceptIncomingRequests();
|
||||
String transport = randomTestTransport();
|
||||
String transport = getTestTransportType();
|
||||
TransportClient client = new MockTransportClient(Settings.builder()
|
||||
.put("client.transport.sniff", false)
|
||||
.put("cluster.name", "cluster1")
|
||||
|
@ -99,7 +97,7 @@ public class TransportClientHeadersTests extends AbstractClientHeadersTestCase {
|
|||
}
|
||||
|
||||
public void testWithSniffing() throws Exception {
|
||||
String transport = randomTestTransport();
|
||||
String transport = getTestTransportType();
|
||||
try (TransportClient client = new MockTransportClient(
|
||||
Settings.builder()
|
||||
.put("client.transport.sniff", true)
|
||||
|
|
|
@ -33,10 +33,8 @@ import org.elasticsearch.test.ESIntegTestCase;
|
|||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
import org.elasticsearch.test.ESIntegTestCase.Scope;
|
||||
import org.elasticsearch.test.discovery.TestZenDiscovery;
|
||||
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||
import org.elasticsearch.transport.MockTransportClient;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.transport.nio.NioTransportPlugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
@ -63,11 +61,11 @@ public class TransportClientIT extends ESIntegTestCase {
|
|||
.put(internalCluster().getDefaultSettings())
|
||||
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
|
||||
.put("node.name", "testNodeVersionIsUpdated")
|
||||
.put("transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
|
||||
.put("transport.type", getTestTransportType())
|
||||
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
|
||||
.put(Node.NODE_DATA_SETTING.getKey(), false)
|
||||
.put("cluster.name", "foobar")
|
||||
.build(), Arrays.asList(MockTcpTransportPlugin.class, TestZenDiscovery.TestPlugin.class)).start()) {
|
||||
.build(), Arrays.asList(getTestTransportPlugin(), TestZenDiscovery.TestPlugin.class)).start()) {
|
||||
TransportAddress transportAddress = node.injector().getInstance(TransportService.class).boundAddress().publishAddress();
|
||||
client.addTransportAddress(transportAddress);
|
||||
// since we force transport clients there has to be one node started that we connect to.
|
||||
|
@ -96,7 +94,7 @@ public class TransportClientIT extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
public void testThatTransportClientSettingCannotBeChanged() {
|
||||
String transport = randomTestTransport();
|
||||
String transport = getTestTransportType();
|
||||
Settings baseSettings = Settings.builder()
|
||||
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
|
||||
.put(NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), transport)
|
||||
|
|
|
@ -32,10 +32,8 @@ import org.elasticsearch.env.Environment;
|
|||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
import org.elasticsearch.test.ESIntegTestCase.Scope;
|
||||
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||
import org.elasticsearch.transport.MockTransportClient;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.transport.nio.NioTransportPlugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
@ -52,7 +50,7 @@ public class TransportClientRetryIT extends ESIntegTestCase {
|
|||
addresses[i++] = instance.boundAddress().publishAddress();
|
||||
}
|
||||
|
||||
String transport = randomTestTransport();
|
||||
String transport = getTestTransportType();
|
||||
|
||||
Settings.Builder builder = Settings.builder().put("client.transport.nodes_sampler_interval", "1s")
|
||||
.put("node.name", "transport_client_retry_test")
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.elasticsearch.test.InternalTestCluster;
|
|||
import org.elasticsearch.test.NodeConfigurationSource;
|
||||
import org.elasticsearch.test.transport.MockTransportService;
|
||||
import org.elasticsearch.threadpool.TestThreadPool;
|
||||
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
@ -125,7 +124,7 @@ public class SingleNodeDiscoveryIT extends ESIntegTestCase {
|
|||
.builder()
|
||||
.put("discovery.type", "single-node")
|
||||
.put("http.enabled", false)
|
||||
.put("transport.type", "mock-socket-network")
|
||||
.put("transport.type", getTestTransportType())
|
||||
/*
|
||||
* We align the port ranges of the two as then with zen discovery these two
|
||||
* nodes would find each other.
|
||||
|
@ -152,7 +151,7 @@ public class SingleNodeDiscoveryIT extends ESIntegTestCase {
|
|||
0,
|
||||
false,
|
||||
"other",
|
||||
Collections.singletonList(MockTcpTransportPlugin.class),
|
||||
Collections.singletonList(getTestTransportPlugin()),
|
||||
Function.identity())) {
|
||||
other.beforeTest(random(), 0);
|
||||
final ClusterState first = internalCluster().getInstance(ClusterService.class).state();
|
||||
|
|
|
@ -23,31 +23,22 @@ import org.apache.lucene.util.LuceneTestCase;
|
|||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.bootstrap.BootstrapCheck;
|
||||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.common.UUIDs;
|
||||
import org.elasticsearch.common.network.NetworkModule;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.BoundTransportAddress;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.env.NodeEnvironment;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.InternalTestCluster;
|
||||
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasToString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
@ -62,7 +53,7 @@ public class NodeTests extends ESTestCase {
|
|||
if (name != null) {
|
||||
settings.put(Node.NODE_NAME_SETTING.getKey(), name);
|
||||
}
|
||||
try (Node node = new MockNode(settings.build(), Collections.singleton(MockTcpTransportPlugin.class))) {
|
||||
try (Node node = new MockNode(settings.build(), Collections.singleton(getTestTransportPlugin()))) {
|
||||
final Settings nodeSettings = randomBoolean() ? node.settings() : node.getEnvironment().settings();
|
||||
if (name == null) {
|
||||
assertThat(Node.NODE_NAME_SETTING.get(nodeSettings), equalTo(node.getNodeEnvironment().nodeId().substring(0, 7)));
|
||||
|
@ -97,7 +88,7 @@ public class NodeTests extends ESTestCase {
|
|||
settings.put(Node.NODE_NAME_SETTING.getKey(), name);
|
||||
}
|
||||
AtomicBoolean executed = new AtomicBoolean(false);
|
||||
try (Node node = new MockNode(settings.build(), Arrays.asList(MockTcpTransportPlugin.class, CheckPlugin.class)) {
|
||||
try (Node node = new MockNode(settings.build(), Arrays.asList(getTestTransportPlugin(), CheckPlugin.class)) {
|
||||
@Override
|
||||
protected void validateNodeBeforeAcceptingRequests(Settings settings, BoundTransportAddress boundTransportAddress,
|
||||
List<BootstrapCheck> bootstrapChecks) throws NodeValidationException {
|
||||
|
@ -139,7 +130,7 @@ public class NodeTests extends ESTestCase {
|
|||
public void testNodeAttributes() throws IOException {
|
||||
String attr = randomAlphaOfLength(5);
|
||||
Settings.Builder settings = baseSettings().put(Node.NODE_ATTRIBUTES.getKey() + "test_attr", attr);
|
||||
try (Node node = new MockNode(settings.build(), Collections.singleton(MockTcpTransportPlugin.class))) {
|
||||
try (Node node = new MockNode(settings.build(), Collections.singleton(getTestTransportPlugin()))) {
|
||||
final Settings nodeSettings = randomBoolean() ? node.settings() : node.getEnvironment().settings();
|
||||
assertEquals(attr, Node.NODE_ATTRIBUTES.get(nodeSettings).getAsMap().get("test_attr"));
|
||||
}
|
||||
|
@ -147,7 +138,7 @@ public class NodeTests extends ESTestCase {
|
|||
// leading whitespace not allowed
|
||||
attr = " leading";
|
||||
settings = baseSettings().put(Node.NODE_ATTRIBUTES.getKey() + "test_attr", attr);
|
||||
try (Node node = new MockNode(settings.build(), Collections.singleton(MockTcpTransportPlugin.class))) {
|
||||
try (Node node = new MockNode(settings.build(), Collections.singleton(getTestTransportPlugin()))) {
|
||||
fail("should not allow a node attribute with leading whitespace");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertEquals("node.attr.test_attr cannot have leading or trailing whitespace [ leading]", e.getMessage());
|
||||
|
@ -156,7 +147,7 @@ public class NodeTests extends ESTestCase {
|
|||
// trailing whitespace not allowed
|
||||
attr = "trailing ";
|
||||
settings = baseSettings().put(Node.NODE_ATTRIBUTES.getKey() + "test_attr", attr);
|
||||
try (Node node = new MockNode(settings.build(), Collections.singleton(MockTcpTransportPlugin.class))) {
|
||||
try (Node node = new MockNode(settings.build(), Collections.singleton(getTestTransportPlugin()))) {
|
||||
fail("should not allow a node attribute with trailing whitespace");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertEquals("node.attr.test_attr cannot have leading or trailing whitespace [trailing ]", e.getMessage());
|
||||
|
@ -169,7 +160,7 @@ public class NodeTests extends ESTestCase {
|
|||
.put(ClusterName.CLUSTER_NAME_SETTING.getKey(), InternalTestCluster.clusterName("single-node-cluster", randomLong()))
|
||||
.put(Environment.PATH_HOME_SETTING.getKey(), tempDir)
|
||||
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
|
||||
.put(NetworkModule.TRANSPORT_TYPE_KEY, "mock-socket-network")
|
||||
.put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType())
|
||||
.put(Node.NODE_DATA_SETTING.getKey(), true);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,6 @@ import org.elasticsearch.test.InternalTestCluster;
|
|||
import org.elasticsearch.test.NodeConfigurationSource;
|
||||
import org.elasticsearch.test.TestCustomMetaData;
|
||||
import org.elasticsearch.test.discovery.TestZenDiscovery;
|
||||
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||
import org.elasticsearch.tribe.TribeServiceTests.MergableCustomMetaData1;
|
||||
import org.elasticsearch.tribe.TribeServiceTests.MergableCustomMetaData2;
|
||||
import org.junit.After;
|
||||
|
@ -291,7 +290,7 @@ public class TribeIntegrationTests extends ESIntegTestCase {
|
|||
settings.put(Node.NODE_MASTER_SETTING.getKey(), false);
|
||||
settings.put(Node.NODE_INGEST_SETTING.getKey(), false);
|
||||
settings.put(NetworkModule.HTTP_ENABLED.getKey(), false);
|
||||
settings.put(NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME);
|
||||
settings.put(NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), getTestTransportType());
|
||||
// add dummy tribe setting so that node is always identifiable as tribe in this test even if the set of connecting cluster is empty
|
||||
settings.put(TribeService.BLOCKS_WRITE_SETTING.getKey(), TribeService.BLOCKS_WRITE_SETTING.getDefault(Settings.EMPTY));
|
||||
|
||||
|
@ -299,7 +298,7 @@ public class TribeIntegrationTests extends ESIntegTestCase {
|
|||
String tribeSetting = "tribe." + c.getClusterName() + ".";
|
||||
settings.put(tribeSetting + ClusterName.CLUSTER_NAME_SETTING.getKey(), c.getClusterName());
|
||||
settings.put(tribeSetting + DiscoverySettings.INITIAL_STATE_TIMEOUT_SETTING.getKey(), "100ms");
|
||||
settings.put(tribeSetting + NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME);
|
||||
settings.put(tribeSetting + NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), getTestTransportType());
|
||||
});
|
||||
|
||||
return settings;
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.elasticsearch.node.Node;
|
|||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.TestCustomMetaData;
|
||||
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
@ -186,7 +185,7 @@ public class TribeServiceTests extends ESTestCase {
|
|||
|
||||
public static class MockTribePlugin extends TribePlugin {
|
||||
|
||||
static List<Class<? extends Plugin>> classpathPlugins = Arrays.asList(MockTribePlugin.class, MockTcpTransportPlugin.class);
|
||||
static List<Class<? extends Plugin>> classpathPlugins = Arrays.asList(MockTribePlugin.class, getTestTransportPlugin());
|
||||
|
||||
public MockTribePlugin(Settings settings) {
|
||||
super(settings);
|
||||
|
@ -204,14 +203,14 @@ public class TribeServiceTests extends ESTestCase {
|
|||
.put("node.name", "test-node")
|
||||
.put("path.home", tempDir)
|
||||
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
|
||||
.put(NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), "mock-socket-network");
|
||||
.put(NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), getTestTransportType());
|
||||
|
||||
final boolean tribeServiceEnable = randomBoolean();
|
||||
if (tribeServiceEnable) {
|
||||
String clusterName = "single-node-cluster";
|
||||
String tribeSetting = "tribe." + clusterName + ".";
|
||||
settings.put(tribeSetting + ClusterName.CLUSTER_NAME_SETTING.getKey(), clusterName)
|
||||
.put(tribeSetting + NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), "mock-socket-network");
|
||||
.put(tribeSetting + NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), getTestTransportType());
|
||||
}
|
||||
try (Node node = new MockNode(settings.build(), MockTribePlugin.classpathPlugins)) {
|
||||
if (tribeServiceEnable) {
|
||||
|
|
|
@ -19,12 +19,6 @@
|
|||
|
||||
package org.elasticsearch.tribe;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
|
@ -41,10 +35,15 @@ import org.elasticsearch.plugins.Plugin;
|
|||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.discovery.TestZenDiscovery;
|
||||
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.either;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
|
||||
|
@ -64,12 +63,12 @@ public class TribeUnitTests extends ESTestCase {
|
|||
public static void createTribes() throws NodeValidationException {
|
||||
Settings baseSettings = Settings.builder()
|
||||
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
|
||||
.put("transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
|
||||
.put("transport.type", getTestTransportType())
|
||||
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
|
||||
.put(NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING.getKey(), 2)
|
||||
.build();
|
||||
|
||||
classpathPlugins = Arrays.asList(TribeAwareTestZenDiscoveryPlugin.class, MockTribePlugin.class, MockTcpTransportPlugin.class);
|
||||
classpathPlugins = Arrays.asList(TribeAwareTestZenDiscoveryPlugin.class, MockTribePlugin.class, getTestTransportPlugin());
|
||||
|
||||
tribe1 = new MockNode(
|
||||
Settings.builder()
|
||||
|
@ -131,9 +130,9 @@ public class TribeUnitTests extends ESTestCase {
|
|||
private static void assertTribeNodeSuccessfullyCreated(Path configPath) throws Exception {
|
||||
// the tribe clients do need it to make sure they can find their corresponding tribes using the proper transport
|
||||
Settings settings = Settings.builder().put(NetworkModule.HTTP_ENABLED.getKey(), false).put("node.name", "tribe_node")
|
||||
.put("transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
|
||||
.put("tribe.t1.transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
|
||||
.put("tribe.t2.transport.type",MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
|
||||
.put("transport.type", getTestTransportType())
|
||||
.put("tribe.t1.transport.type", getTestTransportType())
|
||||
.put("tribe.t2.transport.type", getTestTransportType())
|
||||
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
|
||||
.build();
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.elasticsearch.env.Environment;
|
|||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||
import org.elasticsearch.transport.client.PreBuiltTransportClient;
|
||||
import org.elasticsearch.transport.nio.NioTransportPlugin;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
|
@ -81,9 +82,19 @@ public abstract class ESSmokeClientTestCase extends LuceneTestCase {
|
|||
.put("client.transport.ignore_cluster_name", true)
|
||||
.put(Environment.PATH_HOME_SETTING.getKey(), tempDir);
|
||||
final Collection<Class<? extends Plugin>> plugins;
|
||||
boolean usNio = random().nextBoolean();
|
||||
String transportKey;
|
||||
Class<? extends Plugin> transportPlugin;
|
||||
if (usNio) {
|
||||
transportKey = NioTransportPlugin.NIO_TRANSPORT_NAME;
|
||||
transportPlugin = NioTransportPlugin.class;
|
||||
} else {
|
||||
transportKey = MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME;
|
||||
transportPlugin = MockTcpTransportPlugin.class;
|
||||
}
|
||||
if (random().nextBoolean()) {
|
||||
builder.put(NetworkModule.TRANSPORT_TYPE_KEY, MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME);
|
||||
plugins = Collections.singleton(MockTcpTransportPlugin.class);
|
||||
builder.put(NetworkModule.TRANSPORT_TYPE_KEY, transportKey);
|
||||
plugins = Collections.singleton(transportPlugin);
|
||||
} else {
|
||||
plugins = Collections.emptyList();
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.elasticsearch.plugins.Plugin;
|
|||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||
import org.elasticsearch.transport.Netty4Plugin;
|
||||
import org.elasticsearch.transport.nio.NioTransportPlugin;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -38,14 +39,16 @@ public abstract class HttpSmokeTestCase extends ESIntegTestCase {
|
|||
@SuppressWarnings("unchecked")
|
||||
@BeforeClass
|
||||
public static void setUpTransport() {
|
||||
nodeTransportTypeKey = getTypeKey(randomFrom(MockTcpTransportPlugin.class, Netty4Plugin.class));
|
||||
nodeTransportTypeKey = getTypeKey(randomFrom(getTestTransportPlugin(), Netty4Plugin.class));
|
||||
nodeHttpTypeKey = getTypeKey(Netty4Plugin.class);
|
||||
clientTypeKey = getTypeKey(randomFrom(MockTcpTransportPlugin.class,Netty4Plugin.class));
|
||||
clientTypeKey = getTypeKey(randomFrom(getTestTransportPlugin(), Netty4Plugin.class));
|
||||
}
|
||||
|
||||
private static String getTypeKey(Class<? extends Plugin> clazz) {
|
||||
if (clazz.equals(MockTcpTransportPlugin.class)) {
|
||||
return MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME;
|
||||
} else if (clazz.equals(NioTransportPlugin.class)) {
|
||||
return NioTransportPlugin.NIO_TRANSPORT_NAME;
|
||||
} else {
|
||||
assert clazz.equals(Netty4Plugin.class);
|
||||
return Netty4Plugin.NETTY_TRANSPORT_NAME;
|
||||
|
@ -63,12 +66,12 @@ public abstract class HttpSmokeTestCase extends ESIntegTestCase {
|
|||
|
||||
@Override
|
||||
protected Collection<Class<? extends Plugin>> nodePlugins() {
|
||||
return Arrays.asList(MockTcpTransportPlugin.class, Netty4Plugin.class);
|
||||
return Arrays.asList(getTestTransportPlugin(), Netty4Plugin.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<Class<? extends Plugin>> transportClientPlugins() {
|
||||
return Arrays.asList(MockTcpTransportPlugin.class, Netty4Plugin.class);
|
||||
return Arrays.asList(getTestTransportPlugin(), Netty4Plugin.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,7 +23,6 @@ import com.carrotsearch.randomizedtesting.RandomizedContext;
|
|||
import com.carrotsearch.randomizedtesting.annotations.TestGroup;
|
||||
import com.carrotsearch.randomizedtesting.generators.RandomNumbers;
|
||||
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
|
||||
import org.elasticsearch.client.http.HttpHost;
|
||||
import org.apache.lucene.search.Sort;
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
|
@ -64,6 +63,7 @@ import org.elasticsearch.client.Client;
|
|||
import org.elasticsearch.client.Requests;
|
||||
import org.elasticsearch.client.RestClient;
|
||||
import org.elasticsearch.client.RestClientBuilder;
|
||||
import org.elasticsearch.client.http.HttpHost;
|
||||
import org.elasticsearch.cluster.ClusterModule;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
|
@ -134,7 +134,6 @@ import org.elasticsearch.test.disruption.ServiceDisruptionScheme;
|
|||
import org.elasticsearch.test.store.MockFSIndexStore;
|
||||
import org.elasticsearch.test.transport.MockTransportService;
|
||||
import org.elasticsearch.transport.AssertingTransportInterceptor;
|
||||
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
|
@ -1806,8 +1805,8 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
|||
ArrayList<Class<? extends Plugin>> mocks = new ArrayList<>(mockPlugins);
|
||||
// add both mock plugins - local and tcp if they are not there
|
||||
// we do this in case somebody overrides getMockPlugins and misses to call super
|
||||
if (mockPlugins.contains(MockTcpTransportPlugin.class) == false) {
|
||||
mocks.add(MockTcpTransportPlugin.class);
|
||||
if (mockPlugins.contains(getTestTransportPlugin()) == false) {
|
||||
mocks.add(getTestTransportPlugin());
|
||||
}
|
||||
mockPlugins = mocks;
|
||||
}
|
||||
|
@ -1820,7 +1819,7 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
|||
protected NodeConfigurationSource getNodeConfigSource() {
|
||||
Settings.Builder networkSettings = Settings.builder();
|
||||
if (addMockTransportService()) {
|
||||
networkSettings.put(NetworkModule.TRANSPORT_TYPE_KEY, MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME);
|
||||
networkSettings.put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType());
|
||||
}
|
||||
|
||||
NodeConfigurationSource nodeConfigurationSource = new NodeConfigurationSource() {
|
||||
|
@ -1828,8 +1827,8 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
|||
public Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder()
|
||||
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
|
||||
.put(networkSettings.build()).
|
||||
put(ESIntegTestCase.this.nodeSettings(nodeOrdinal)).build();
|
||||
.put(networkSettings.build())
|
||||
.put(ESIntegTestCase.this.nodeSettings(nodeOrdinal)).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1851,9 +1850,9 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
|||
@Override
|
||||
public Collection<Class<? extends Plugin>> transportClientPlugins() {
|
||||
Collection<Class<? extends Plugin>> plugins = ESIntegTestCase.this.transportClientPlugins();
|
||||
if (plugins.contains(MockTcpTransportPlugin.class) == false) {
|
||||
if (plugins.contains(getTestTransportPlugin()) == false) {
|
||||
plugins = new ArrayList<>(plugins);
|
||||
plugins.add(MockTcpTransportPlugin.class);
|
||||
plugins.add(getTestTransportPlugin());
|
||||
}
|
||||
return Collections.unmodifiableCollection(plugins);
|
||||
}
|
||||
|
@ -1911,7 +1910,7 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
|||
}
|
||||
|
||||
if (addMockTransportService()) {
|
||||
mocks.add(MockTcpTransportPlugin.class);
|
||||
mocks.add(getTestTransportPlugin());
|
||||
}
|
||||
|
||||
if (addTestZenDiscovery()) {
|
||||
|
|
|
@ -37,7 +37,6 @@ import org.elasticsearch.common.util.BigArrays;
|
|||
import org.elasticsearch.common.util.concurrent.EsExecutors;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.env.NodeEnvironment;
|
||||
import org.elasticsearch.index.Index;
|
||||
|
@ -51,7 +50,6 @@ import org.elasticsearch.script.ScriptService;
|
|||
import org.elasticsearch.search.internal.SearchContext;
|
||||
import org.elasticsearch.test.discovery.TestZenDiscovery;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
|
@ -175,15 +173,15 @@ public abstract class ESSingleNodeTestCase extends ESTestCase {
|
|||
.put(ScriptService.SCRIPT_MAX_COMPILATIONS_PER_MINUTE.getKey(), 1000)
|
||||
.put(EsExecutors.PROCESSORS_SETTING.getKey(), 1) // limit the number of threads created
|
||||
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
|
||||
.put("transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
|
||||
.put("transport.type", getTestTransportType())
|
||||
.put(Node.NODE_DATA_SETTING.getKey(), true)
|
||||
.put(NodeEnvironment.NODE_ID_SEED_SETTING.getKey(), random().nextLong())
|
||||
.put(nodeSettings()) // allow test cases to provide their own settings or override these
|
||||
.build();
|
||||
Collection<Class<? extends Plugin>> plugins = getPlugins();
|
||||
if (plugins.contains(MockTcpTransportPlugin.class) == false) {
|
||||
if (plugins.contains(getTestTransportPlugin()) == false) {
|
||||
plugins = new ArrayList<>(plugins);
|
||||
plugins.add(MockTcpTransportPlugin.class);
|
||||
plugins.add(getTestTransportPlugin());
|
||||
}
|
||||
if (plugins.contains(TestZenDiscovery.TestPlugin.class) == false) {
|
||||
plugins = new ArrayList<>(plugins);
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.apache.logging.log4j.status.StatusData;
|
|||
import org.apache.logging.log4j.status.StatusLogger;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
import org.apache.lucene.util.SetOnce;
|
||||
import org.apache.lucene.util.TestRuleMarkFailure;
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
import org.apache.lucene.util.TimeUnits;
|
||||
|
@ -91,6 +92,7 @@ import org.elasticsearch.indices.IndicesService;
|
|||
import org.elasticsearch.indices.analysis.AnalysisModule;
|
||||
import org.elasticsearch.plugins.AnalysisPlugin;
|
||||
import org.elasticsearch.plugins.MapperPlugin;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.plugins.ScriptPlugin;
|
||||
import org.elasticsearch.script.MockScriptEngine;
|
||||
import org.elasticsearch.script.Script;
|
||||
|
@ -132,6 +134,7 @@ import java.util.Random;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Consumer;
|
||||
|
@ -885,8 +888,19 @@ public abstract class ESTestCase extends LuceneTestCase {
|
|||
return geohashGenerator.ofStringLength(random(), minPrecision, maxPrecision);
|
||||
}
|
||||
|
||||
public static String randomTestTransport() {
|
||||
return randomBoolean() ? NioTransportPlugin.NIO_TRANSPORT_NAME : MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME;
|
||||
private static boolean useNio;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUseNio() throws Exception {
|
||||
useNio = randomBoolean();
|
||||
}
|
||||
|
||||
public static String getTestTransportType() {
|
||||
return useNio ? NioTransportPlugin.NIO_TRANSPORT_NAME : MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME;
|
||||
}
|
||||
|
||||
public static Class<? extends Plugin> getTestTransportPlugin() {
|
||||
return useNio ? NioTransportPlugin.class : MockTcpTransportPlugin.class;
|
||||
}
|
||||
|
||||
private static final GeohashGenerator geohashGenerator = new GeohashGenerator();
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.elasticsearch.env.Environment;
|
|||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||
import org.elasticsearch.transport.MockTransportClient;
|
||||
import org.elasticsearch.transport.nio.NioTransportPlugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
|
@ -45,6 +46,7 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static org.elasticsearch.test.ESTestCase.getTestTransportType;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
|
@ -80,10 +82,16 @@ public final class ExternalTestCluster extends TestCluster {
|
|||
boolean addMockTcpTransport = additionalSettings.get(NetworkModule.TRANSPORT_TYPE_KEY) == null;
|
||||
|
||||
if (addMockTcpTransport) {
|
||||
clientSettingsBuilder.put(NetworkModule.TRANSPORT_TYPE_KEY, MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME);
|
||||
if (pluginClasses.contains(MockTcpTransportPlugin.class) == false) {
|
||||
String transport = getTestTransportType();
|
||||
clientSettingsBuilder.put(NetworkModule.TRANSPORT_TYPE_KEY, transport);
|
||||
if (pluginClasses.contains(MockTcpTransportPlugin.class) == false &&
|
||||
pluginClasses.contains(NioTransportPlugin.class) == false) {
|
||||
pluginClasses = new ArrayList<>(pluginClasses);
|
||||
pluginClasses.add(MockTcpTransportPlugin.class);
|
||||
if (transport.equals(NioTransportPlugin.NIO_TRANSPORT_NAME)) {
|
||||
pluginClasses.add(NioTransportPlugin.class);
|
||||
} else {
|
||||
pluginClasses.add(MockTcpTransportPlugin.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
Settings clientSettings = clientSettingsBuilder.build();
|
||||
|
|
|
@ -95,12 +95,10 @@ import org.elasticsearch.tasks.TaskInfo;
|
|||
import org.elasticsearch.tasks.TaskManager;
|
||||
import org.elasticsearch.test.disruption.ServiceDisruptionScheme;
|
||||
import org.elasticsearch.test.transport.MockTransportService;
|
||||
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||
import org.elasticsearch.transport.MockTransportClient;
|
||||
import org.elasticsearch.transport.TcpTransport;
|
||||
import org.elasticsearch.transport.Transport;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.transport.nio.NioTransportPlugin;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
@ -138,8 +136,8 @@ import static org.elasticsearch.discovery.DiscoverySettings.INITIAL_STATE_TIMEOU
|
|||
import static org.elasticsearch.discovery.zen.ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING;
|
||||
import static org.elasticsearch.test.ESTestCase.assertBusy;
|
||||
import static org.elasticsearch.test.ESTestCase.awaitBusy;
|
||||
import static org.elasticsearch.test.ESTestCase.randomBoolean;
|
||||
import static org.elasticsearch.test.ESTestCase.randomFrom;
|
||||
import static org.elasticsearch.test.ESTestCase.getTestTransportType;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
|
@ -978,9 +976,7 @@ public final class InternalTestCluster extends TestCluster {
|
|||
if (NetworkModule.TRANSPORT_TYPE_SETTING.exists(settings)) {
|
||||
builder.put(NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), NetworkModule.TRANSPORT_TYPE_SETTING.get(settings));
|
||||
} else {
|
||||
String transport = randomBoolean() ? NioTransportPlugin.NIO_TRANSPORT_NAME :
|
||||
MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME;
|
||||
builder.put(NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), transport);
|
||||
builder.put(NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), getTestTransportType());
|
||||
}
|
||||
TransportClient client = new MockTransportClient(builder.build(), plugins);
|
||||
client.addTransportAddress(addr);
|
||||
|
|
|
@ -34,6 +34,7 @@ import java.util.Map;
|
|||
import java.util.function.Supplier;
|
||||
|
||||
public class MockTcpTransportPlugin extends Plugin implements NetworkPlugin {
|
||||
|
||||
public static final String MOCK_TCP_TRANSPORT_NAME = "mock-socket-network";
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.elasticsearch.plugins.Plugin;
|
|||
import org.elasticsearch.search.MockSearchService;
|
||||
import org.elasticsearch.search.SearchService;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -41,11 +40,11 @@ public class MockNodeTests extends ESTestCase {
|
|||
public void testComponentsMockedByMarkerPlugins() throws IOException {
|
||||
Settings settings = Settings.builder() // All these are required or MockNode will fail to build.
|
||||
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
|
||||
.put("transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
|
||||
.put("transport.type", getTestTransportType())
|
||||
.put("http.enabled", false)
|
||||
.build();
|
||||
List<Class<? extends Plugin>> plugins = new ArrayList<>();
|
||||
plugins.add(MockTcpTransportPlugin.class);
|
||||
plugins.add(getTestTransportPlugin());
|
||||
boolean useMockBigArrays = randomBoolean();
|
||||
boolean useMockSearchService = randomBoolean();
|
||||
if (useMockBigArrays) {
|
||||
|
|
|
@ -35,9 +35,7 @@ import org.elasticsearch.test.ESTestCase;
|
|||
import org.elasticsearch.test.InternalTestCluster;
|
||||
import org.elasticsearch.test.NodeConfigurationSource;
|
||||
import org.elasticsearch.test.discovery.TestZenDiscovery;
|
||||
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||
import org.elasticsearch.transport.TcpTransport;
|
||||
import org.elasticsearch.transport.nio.NioTransportPlugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
@ -177,7 +175,7 @@ public class InternalTestClusterTests extends ESTestCase {
|
|||
final int numClientNodes = randomIntBetween(0, 2);
|
||||
final String clusterName1 = "shared1";
|
||||
final String clusterName2 = "shared2";
|
||||
String transportClient = randomTestTransport();
|
||||
String transportClient = getTestTransportType();
|
||||
NodeConfigurationSource nodeConfigurationSource = new NodeConfigurationSource() {
|
||||
@Override
|
||||
public Settings nodeSettings(int nodeOrdinal) {
|
||||
|
@ -186,7 +184,7 @@ public class InternalTestClusterTests extends ESTestCase {
|
|||
NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING.getKey(),
|
||||
2 * ((masterNodes ? InternalTestCluster.DEFAULT_HIGH_NUM_MASTER_NODES : 0) + maxNumDataNodes + numClientNodes))
|
||||
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
|
||||
.put(NetworkModule.TRANSPORT_TYPE_KEY, MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME);
|
||||
.put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType());
|
||||
if (autoManageMinMasterNodes == false) {
|
||||
assert minNumDataNodes == maxNumDataNodes;
|
||||
assert masterNodes == false;
|
||||
|
@ -211,7 +209,7 @@ public class InternalTestClusterTests extends ESTestCase {
|
|||
String nodePrefix = "foobar";
|
||||
|
||||
Path baseDir = createTempDir();
|
||||
final List<Class<? extends Plugin>> mockPlugins = Arrays.asList(MockTcpTransportPlugin.class, TestZenDiscovery.TestPlugin.class);
|
||||
final List<Class<? extends Plugin>> mockPlugins = Arrays.asList(getTestTransportPlugin(), TestZenDiscovery.TestPlugin.class);
|
||||
InternalTestCluster cluster0 = new InternalTestCluster(clusterSeed, baseDir, masterNodes,
|
||||
autoManageMinMasterNodes, minNumDataNodes, maxNumDataNodes, clusterName1, nodeConfigurationSource, numClientNodes,
|
||||
enableHttpPipelining, nodePrefix, mockPlugins, Function.identity());
|
||||
|
@ -255,7 +253,7 @@ public class InternalTestClusterTests extends ESTestCase {
|
|||
final int maxNumDataNodes = 2;
|
||||
final int numClientNodes = randomIntBetween(0, 2);
|
||||
final String clusterName1 = "shared1";
|
||||
String transportClient = randomTestTransport();
|
||||
String transportClient = getTestTransportType();
|
||||
NodeConfigurationSource nodeConfigurationSource = new NodeConfigurationSource() {
|
||||
@Override
|
||||
public Settings nodeSettings(int nodeOrdinal) {
|
||||
|
@ -263,7 +261,7 @@ public class InternalTestClusterTests extends ESTestCase {
|
|||
.put(
|
||||
NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING.getKey(),
|
||||
2 + (masterNodes ? InternalTestCluster.DEFAULT_HIGH_NUM_MASTER_NODES : 0) + maxNumDataNodes + numClientNodes)
|
||||
.put(NetworkModule.TRANSPORT_TYPE_KEY, MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
|
||||
.put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -283,7 +281,7 @@ public class InternalTestClusterTests extends ESTestCase {
|
|||
Path baseDir = createTempDir();
|
||||
InternalTestCluster cluster = new InternalTestCluster(clusterSeed, baseDir, masterNodes,
|
||||
true, minNumDataNodes, maxNumDataNodes, clusterName1, nodeConfigurationSource, numClientNodes,
|
||||
enableHttpPipelining, nodePrefix, Arrays.asList(MockTcpTransportPlugin.class, TestZenDiscovery.TestPlugin.class),
|
||||
enableHttpPipelining, nodePrefix, Arrays.asList(getTestTransportPlugin(), TestZenDiscovery.TestPlugin.class),
|
||||
Function.identity());
|
||||
try {
|
||||
cluster.beforeTest(random(), 0.0);
|
||||
|
@ -364,7 +362,7 @@ public class InternalTestClusterTests extends ESTestCase {
|
|||
final Path baseDir = createTempDir();
|
||||
final int numNodes = 5;
|
||||
|
||||
String transportClient = randomTestTransport();
|
||||
String transportClient = getTestTransportType();
|
||||
InternalTestCluster cluster = new InternalTestCluster(randomLong(), baseDir, false,
|
||||
false, 0, 0, "test", new NodeConfigurationSource() {
|
||||
@Override
|
||||
|
@ -372,7 +370,7 @@ public class InternalTestClusterTests extends ESTestCase {
|
|||
return Settings.builder()
|
||||
.put(NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING.getKey(), numNodes)
|
||||
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
|
||||
.put(NetworkModule.TRANSPORT_TYPE_KEY, MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
|
||||
.put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType())
|
||||
.put(DiscoverySettings.INITIAL_STATE_TIMEOUT_SETTING.getKey(), 0)
|
||||
// speedup join timeout as setting initial state timeout to 0 makes split
|
||||
// elections more likely
|
||||
|
@ -390,7 +388,7 @@ public class InternalTestClusterTests extends ESTestCase {
|
|||
return Settings.builder()
|
||||
.put(NetworkModule.TRANSPORT_TYPE_KEY, transportClient).build();
|
||||
}
|
||||
}, 0, randomBoolean(), "", Arrays.asList(MockTcpTransportPlugin.class, TestZenDiscovery.TestPlugin.class), Function.identity());
|
||||
}, 0, randomBoolean(), "", Arrays.asList(getTestTransportPlugin(), TestZenDiscovery.TestPlugin.class), Function.identity());
|
||||
cluster.beforeTest(random(), 0.0);
|
||||
List<DiscoveryNode.Role> roles = new ArrayList<>();
|
||||
for (int i = 0; i < numNodes; i++) {
|
||||
|
@ -452,13 +450,13 @@ public class InternalTestClusterTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testTwoNodeCluster() throws Exception {
|
||||
String transportClient = randomTestTransport();
|
||||
String transportClient = getTestTransportType();
|
||||
NodeConfigurationSource nodeConfigurationSource = new NodeConfigurationSource() {
|
||||
@Override
|
||||
public Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder().put(NetworkModule.HTTP_ENABLED.getKey(), false)
|
||||
.put(NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING.getKey(), 2)
|
||||
.put(NetworkModule.TRANSPORT_TYPE_KEY, MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
|
||||
.put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -478,7 +476,7 @@ public class InternalTestClusterTests extends ESTestCase {
|
|||
Path baseDir = createTempDir();
|
||||
InternalTestCluster cluster = new InternalTestCluster(randomLong(), baseDir, false, true, 2, 2,
|
||||
"test", nodeConfigurationSource, 0, enableHttpPipelining, nodePrefix,
|
||||
Arrays.asList(MockTcpTransportPlugin.class, TestZenDiscovery.TestPlugin.class), Function.identity());
|
||||
Arrays.asList(getTestTransportPlugin(), TestZenDiscovery.TestPlugin.class), Function.identity());
|
||||
try {
|
||||
cluster.beforeTest(random(), 0.0);
|
||||
assertMMNinNodeSetting(cluster, 2);
|
||||
|
|
Loading…
Reference in New Issue