From f2dd5dd6eb6cbaffe86967875faaf8a0148b9e4e Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 5 Feb 2019 17:42:24 +0000 Subject: [PATCH] Remove DiscoveryPlugin#getDiscoveryTypes (#38414) With this change we no longer support pluggable discovery implementations. No known implementations of `DiscoveryPlugin` actually override this method, so in practice this should have no effect on the wider world. However, we were using this rather extensively in tests to provide the `test-zen` discovery type. We no longer need a separate discovery type for tests as we no longer need to customise its behaviour. Relates #38410 --- .../migration/migrate_7_0/plugins.asciidoc | 5 + .../rest/discovery/Zen2RestApiIT.java | 6 - .../discovery/DiscoveryModule.java | 15 +- .../plugins/DiscoveryPlugin.java | 48 +------ .../master/IndexingMasterFailoverIT.java | 7 - .../client/transport/TransportClientIT.java | 5 +- .../coordination/RareClusterStateIT.java | 7 - .../cluster/coordination/Zen1IT.java | 8 +- .../cluster/routing/PrimaryAllocationIT.java | 7 - .../discovery/AbstractDisruptionTestCase.java | 19 +-- .../discovery/DiscoveryModuleTests.java | 35 ----- .../discovery/SnapshotDisruptionIT.java | 8 +- .../elasticsearch/test/ESIntegTestCase.java | 15 -- .../test/ESSingleNodeTestCase.java | 6 - .../org/elasticsearch/test/ESTestCase.java | 11 -- .../test/InternalTestCluster.java | 22 +-- .../test/discovery/TestZenDiscovery.java | 133 ------------------ .../test/test/InternalTestClusterTests.java | 3 +- .../elasticsearch/xpack/CcrIntegTestCase.java | 3 +- .../ml/integration/NetworkDisruptionIT.java | 9 -- .../xpack/ml/support/BaseMlIntegTestCase.java | 3 +- .../elasticsearch/license/LicensingTests.java | 19 +-- ...ServerTransportFilterIntegrationTests.java | 27 +--- 23 files changed, 46 insertions(+), 375 deletions(-) delete mode 100644 test/framework/src/main/java/org/elasticsearch/test/discovery/TestZenDiscovery.java diff --git a/docs/reference/migration/migrate_7_0/plugins.asciidoc b/docs/reference/migration/migrate_7_0/plugins.asciidoc index 7e65a9fb41c..5641d412a14 100644 --- a/docs/reference/migration/migrate_7_0/plugins.asciidoc +++ b/docs/reference/migration/migrate_7_0/plugins.asciidoc @@ -70,3 +70,8 @@ The `RealmSettings.simpleString` method can be used as a convenience for the abo Tribe node functionality has been removed in favor of <>. +[float] +==== Discovery implementations are no longer pluggable + +* The method `DiscoveryPlugin#getDiscoveryTypes()` was removed, so that plugins + can no longer provide their own discovery implementations. diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/rest/discovery/Zen2RestApiIT.java b/modules/transport-netty4/src/test/java/org/elasticsearch/rest/discovery/Zen2RestApiIT.java index f26b02696e7..5cf96419f55 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/rest/discovery/Zen2RestApiIT.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/rest/discovery/Zen2RestApiIT.java @@ -36,7 +36,6 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.http.HttpServerTransport; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.InternalTestCluster; -import org.elasticsearch.test.discovery.TestZenDiscovery; import org.hamcrest.Matchers; import java.io.IOException; @@ -51,11 +50,6 @@ import static org.hamcrest.core.Is.is; @ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, transportClientRatio = 0, autoMinMasterNodes = false) public class Zen2RestApiIT extends ESNetty4IntegTestCase { - @Override - protected Settings nodeSettings(int nodeOrdinal) { - return Settings.builder().put(super.nodeSettings(nodeOrdinal)).put(TestZenDiscovery.USE_ZEN2.getKey(), true).build(); - } - @Override protected boolean addMockHttpTransport() { return false; // enable http diff --git a/server/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java b/server/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java index 5db6cd3ee0f..b6639a9c25e 100644 --- a/server/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java +++ b/server/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java @@ -55,6 +55,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Random; import java.util.Set; import java.util.function.BiConsumer; import java.util.function.Function; @@ -69,8 +70,8 @@ import static org.elasticsearch.node.Node.NODE_NAME_SETTING; public class DiscoveryModule { private static final Logger logger = LogManager.getLogger(DiscoveryModule.class); - public static final String ZEN_DISCOVERY_TYPE = "zen"; - public static final String ZEN2_DISCOVERY_TYPE = "zen2"; + public static final String ZEN_DISCOVERY_TYPE = "legacy-zen"; + public static final String ZEN2_DISCOVERY_TYPE = "zen"; public static final Setting DISCOVERY_TYPE_SETTING = new Setting<>("discovery.type", ZEN2_DISCOVERY_TYPE, Function.identity(), Property.NodeScope); @@ -136,17 +137,9 @@ public class DiscoveryModule { discoveryTypes.put(ZEN2_DISCOVERY_TYPE, () -> new Coordinator(NODE_NAME_SETTING.get(settings), settings, clusterSettings, transportService, namedWriteableRegistry, allocationService, masterService, () -> gatewayMetaState.getPersistedState(settings, (ClusterApplierService) clusterApplier), hostsProvider, clusterApplier, - joinValidators, Randomness.get())); + joinValidators, new Random(Randomness.get().nextLong()))); discoveryTypes.put("single-node", () -> new SingleNodeDiscovery(settings, transportService, masterService, clusterApplier, gatewayMetaState)); - for (DiscoveryPlugin plugin : plugins) { - plugin.getDiscoveryTypes(threadPool, transportService, namedWriteableRegistry, masterService, clusterApplier, clusterSettings, - hostsProvider, allocationService, gatewayMetaState).forEach((key, value) -> { - if (discoveryTypes.put(key, value) != null) { - throw new IllegalArgumentException("Cannot register discovery type [" + key + "] twice"); - } - }); - } String discoveryType = DISCOVERY_TYPE_SETTING.get(settings); Supplier discoverySupplier = discoveryTypes.get(discoveryType); if (discoverySupplier == null) { diff --git a/server/src/main/java/org/elasticsearch/plugins/DiscoveryPlugin.java b/server/src/main/java/org/elasticsearch/plugins/DiscoveryPlugin.java index 994607a9c97..5886a9d773e 100644 --- a/server/src/main/java/org/elasticsearch/plugins/DiscoveryPlugin.java +++ b/server/src/main/java/org/elasticsearch/plugins/DiscoveryPlugin.java @@ -19,26 +19,18 @@ package org.elasticsearch.plugins; +import org.elasticsearch.cluster.ClusterState; +import org.elasticsearch.cluster.node.DiscoveryNode; +import org.elasticsearch.common.network.NetworkService; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.discovery.zen.UnicastHostsProvider; +import org.elasticsearch.transport.TransportService; + import java.util.Collections; import java.util.Map; import java.util.function.BiConsumer; import java.util.function.Supplier; -import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.cluster.routing.allocation.AllocationService; -import org.elasticsearch.cluster.service.ClusterApplier; -import org.elasticsearch.cluster.service.MasterService; -import org.elasticsearch.common.io.stream.NamedWriteableRegistry; -import org.elasticsearch.common.network.NetworkService; -import org.elasticsearch.common.settings.ClusterSettings; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.discovery.Discovery; -import org.elasticsearch.discovery.zen.UnicastHostsProvider; -import org.elasticsearch.gateway.GatewayMetaState; -import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.TransportService; - /** * An additional extension point for {@link Plugin}s that extends Elasticsearch's discovery functionality. To add an additional * {@link NetworkService.CustomNameResolver} just implement the interface and implement the {@link #getCustomNameResolver(Settings)} method: @@ -53,32 +45,6 @@ import org.elasticsearch.transport.TransportService; * } */ public interface DiscoveryPlugin { - - /** - * Returns custom discovery implementations added by this plugin. - * - * The key of the returned map is the name of the discovery implementation - * (see {@link org.elasticsearch.discovery.DiscoveryModule#DISCOVERY_TYPE_SETTING}, and - * the value is a supplier to construct the {@link Discovery}. - * - * @param threadPool Use to schedule ping actions - * @param transportService Use to communicate with other nodes - * @param masterService Use to submit cluster state update tasks - * @param clusterApplier Use to locally apply cluster state updates - * @param clusterSettings Use to get cluster settings - * @param hostsProvider Use to find configured hosts which should be pinged for initial discovery - */ - default Map> getDiscoveryTypes(ThreadPool threadPool, TransportService transportService, - NamedWriteableRegistry namedWriteableRegistry, - MasterService masterService, - ClusterApplier clusterApplier, - ClusterSettings clusterSettings, - UnicastHostsProvider hostsProvider, - AllocationService allocationService, - GatewayMetaState gatewayMetaState) { - return Collections.emptyMap(); - } - /** * Override to add additional {@link NetworkService.CustomNameResolver}s. * This can be handy if you want to provide your own Network interface name like _mycard_ diff --git a/server/src/test/java/org/elasticsearch/action/support/master/IndexingMasterFailoverIT.java b/server/src/test/java/org/elasticsearch/action/support/master/IndexingMasterFailoverIT.java index 4068d36ec40..1317183f286 100644 --- a/server/src/test/java/org/elasticsearch/action/support/master/IndexingMasterFailoverIT.java +++ b/server/src/test/java/org/elasticsearch/action/support/master/IndexingMasterFailoverIT.java @@ -23,7 +23,6 @@ import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase; -import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.test.disruption.NetworkDisruption; import org.elasticsearch.test.disruption.NetworkDisruption.NetworkDisconnect; import org.elasticsearch.test.disruption.NetworkDisruption.TwoPartitions; @@ -50,12 +49,6 @@ public class IndexingMasterFailoverIT extends ESIntegTestCase { return classes; } - @Override - protected Settings nodeSettings(int nodeOrdinal) { - return Settings.builder().put(super.nodeSettings(nodeOrdinal)) - .put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false).build(); - } - /** * Indexing operations which entail mapping changes require a blocking request to the master node to update the mapping. * If the master node is being disrupted or if it cannot commit cluster state changes, it needs to retry within timeout limits. diff --git a/server/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java b/server/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java index 709af1dfe3c..dab44b37a3e 100644 --- a/server/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java +++ b/server/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java @@ -34,7 +34,6 @@ import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ESIntegTestCase.Scope; import org.elasticsearch.test.MockHttpTransport; -import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.transport.MockTransportClient; import org.elasticsearch.transport.TransportService; @@ -66,10 +65,8 @@ public class TransportClientIT extends ESIntegTestCase { .put("transport.type", getTestTransportType()) .put(Node.NODE_DATA_SETTING.getKey(), false) .put("cluster.name", "foobar") - .put(TestZenDiscovery.USE_ZEN2.getKey(), getUseZen2()) .putList(ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getKey(), "testNodeVersionIsUpdated") - .build(), Arrays.asList(getTestTransportPlugin(), TestZenDiscovery.TestPlugin.class, - MockHttpTransport.TestPlugin.class)).start()) { + .build(), Arrays.asList(getTestTransportPlugin(), MockHttpTransport.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. diff --git a/server/src/test/java/org/elasticsearch/cluster/coordination/RareClusterStateIT.java b/server/src/test/java/org/elasticsearch/cluster/coordination/RareClusterStateIT.java index f072fd4fb9c..ccde363fdc5 100644 --- a/server/src/test/java/org/elasticsearch/cluster/coordination/RareClusterStateIT.java +++ b/server/src/test/java/org/elasticsearch/cluster/coordination/RareClusterStateIT.java @@ -49,7 +49,6 @@ import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.test.ESIntegTestCase; -import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.test.disruption.BlockClusterStateProcessing; import org.elasticsearch.test.junit.annotations.TestLogging; @@ -71,12 +70,6 @@ import static org.hamcrest.Matchers.instanceOf; @TestLogging("_root:DEBUG") public class RareClusterStateIT extends ESIntegTestCase { - @Override - protected Settings nodeSettings(int nodeOrdinal) { - return Settings.builder().put(super.nodeSettings(nodeOrdinal)) - .put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false).build(); - } - @Override protected int numberOfShards() { return 1; diff --git a/server/src/test/java/org/elasticsearch/cluster/coordination/Zen1IT.java b/server/src/test/java/org/elasticsearch/cluster/coordination/Zen1IT.java index 6ac753b5bc6..3ba9f58523d 100644 --- a/server/src/test/java/org/elasticsearch/cluster/coordination/Zen1IT.java +++ b/server/src/test/java/org/elasticsearch/cluster/coordination/Zen1IT.java @@ -37,13 +37,13 @@ import org.elasticsearch.common.Priority; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.discovery.Discovery; +import org.elasticsearch.discovery.DiscoveryModule; import org.elasticsearch.discovery.zen.ElectMasterService; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.gateway.MetaStateService; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.InternalTestCluster.RestartCallback; -import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.transport.TransportService; @@ -71,12 +71,10 @@ import static org.hamcrest.Matchers.is; public class Zen1IT extends ESIntegTestCase { private static Settings ZEN1_SETTINGS = Coordinator.addZen1Attribute(true, Settings.builder() - .put(TestZenDiscovery.USE_ZEN2.getKey(), false) - .put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false)) // Zen2 does not know about mock pings - .build(); + .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), DiscoveryModule.ZEN_DISCOVERY_TYPE)).build(); private static Settings ZEN2_SETTINGS = Settings.builder() - .put(TestZenDiscovery.USE_ZEN2.getKey(), true) + .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), DiscoveryModule.ZEN2_DISCOVERY_TYPE) .build(); protected Collection> nodePlugins() { diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/PrimaryAllocationIT.java b/server/src/test/java/org/elasticsearch/cluster/routing/PrimaryAllocationIT.java index a64f5093638..9a7e25d29bb 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/PrimaryAllocationIT.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/PrimaryAllocationIT.java @@ -47,7 +47,6 @@ import org.elasticsearch.indices.IndicesService; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.InternalTestCluster; -import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.test.disruption.NetworkDisruption; import org.elasticsearch.test.disruption.NetworkDisruption.NetworkDisconnect; import org.elasticsearch.test.disruption.NetworkDisruption.TwoPartitions; @@ -88,12 +87,6 @@ public class PrimaryAllocationIT extends ESIntegTestCase { return Arrays.asList(MockTransportService.TestPlugin.class); } - @Override - protected Settings nodeSettings(int nodeOrdinal) { - return Settings.builder().put(super.nodeSettings(nodeOrdinal)) - .put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false).build(); - } - public void testBulkWeirdScenario() throws Exception { String master = internalCluster().startMasterOnlyNode(Settings.EMPTY); internalCluster().startDataOnlyNodes(2); diff --git a/server/src/test/java/org/elasticsearch/discovery/AbstractDisruptionTestCase.java b/server/src/test/java/org/elasticsearch/discovery/AbstractDisruptionTestCase.java index 825a4203ef9..97ba76b8220 100644 --- a/server/src/test/java/org/elasticsearch/discovery/AbstractDisruptionTestCase.java +++ b/server/src/test/java/org/elasticsearch/discovery/AbstractDisruptionTestCase.java @@ -30,12 +30,9 @@ import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.discovery.zen.UnicastZenPing; -import org.elasticsearch.discovery.zen.ZenPing; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.InternalTestCluster; -import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.test.disruption.NetworkDisruption; import org.elasticsearch.test.disruption.NetworkDisruption.Bridge; import org.elasticsearch.test.disruption.NetworkDisruption.DisruptedLinks; @@ -65,8 +62,7 @@ public abstract class AbstractDisruptionTestCase extends ESIntegTestCase { @Override protected Settings nodeSettings(int nodeOrdinal) { - return Settings.builder().put(super.nodeSettings(nodeOrdinal)).put(DEFAULT_SETTINGS) - .put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false).build(); + return Settings.builder().put(super.nodeSettings(nodeOrdinal)).put(DEFAULT_SETTINGS).build(); } @Override @@ -114,22 +110,9 @@ public abstract class AbstractDisruptionTestCase extends ESIntegTestCase { InternalTestCluster internalCluster = internalCluster(); List nodes = internalCluster.startNodes(numberOfNodes); ensureStableCluster(numberOfNodes); - - // TODO: this is a temporary solution so that nodes will not base their reaction to a partition based on previous successful results - clearTemporalResponses(); return nodes; } - protected void clearTemporalResponses() { - final Discovery discovery = internalCluster().getInstance(Discovery.class); - if (discovery instanceof TestZenDiscovery) { - ZenPing zenPing = ((TestZenDiscovery) discovery).getZenPing(); - if (zenPing instanceof UnicastZenPing) { - ((UnicastZenPing) zenPing).clearTemporalResponses(); - } - } - } - static final Settings DEFAULT_SETTINGS = Settings.builder() .put(LeaderChecker.LEADER_CHECK_TIMEOUT_SETTING.getKey(), "1s") // for hitting simulated network failures quickly .put(LeaderChecker.LEADER_CHECK_RETRY_COUNT_SETTING.getKey(), 1) // for hitting simulated network failures quickly diff --git a/server/src/test/java/org/elasticsearch/discovery/DiscoveryModuleTests.java b/server/src/test/java/org/elasticsearch/discovery/DiscoveryModuleTests.java index f44f33e71ee..285bb7b1fd1 100644 --- a/server/src/test/java/org/elasticsearch/discovery/DiscoveryModuleTests.java +++ b/server/src/test/java/org/elasticsearch/discovery/DiscoveryModuleTests.java @@ -22,7 +22,6 @@ import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.coordination.Coordinator; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.cluster.service.ClusterApplier; import org.elasticsearch.cluster.service.MasterService; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; @@ -36,7 +35,6 @@ import org.elasticsearch.discovery.zen.ZenDiscovery; import org.elasticsearch.gateway.GatewayMetaState; import org.elasticsearch.plugins.DiscoveryPlugin; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.test.NoopDiscovery; import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; @@ -75,18 +73,6 @@ public class DiscoveryModuleTests extends ESTestCase { } } - public interface DummyDiscoveryPlugin extends DiscoveryPlugin { - Map> impl(); - @Override - default Map> getDiscoveryTypes(ThreadPool threadPool, TransportService transportService, - NamedWriteableRegistry namedWriteableRegistry, - MasterService masterService, ClusterApplier clusterApplier, - ClusterSettings clusterSettings, UnicastHostsProvider hostsProvider, - AllocationService allocationService, GatewayMetaState gatewayMetaState) { - return impl(); - } - } - @Before public void setupDummyServices() { threadPool = mock(ThreadPool.class); @@ -114,19 +100,6 @@ public class DiscoveryModuleTests extends ESTestCase { assertTrue(module.getDiscovery() instanceof Coordinator); } - public void testLazyConstructionDiscovery() { - DummyDiscoveryPlugin plugin = () -> Collections.singletonMap("custom", - () -> { throw new AssertionError("created discovery type which was not selected"); }); - newModule(Settings.EMPTY, Collections.singletonList(plugin)); - } - - public void testRegisterDiscovery() { - Settings settings = Settings.builder().put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "custom").build(); - DummyDiscoveryPlugin plugin = () -> Collections.singletonMap("custom", NoopDiscovery::new); - DiscoveryModule module = newModule(settings, Collections.singletonList(plugin)); - assertTrue(module.getDiscovery() instanceof NoopDiscovery); - } - public void testUnknownDiscovery() { Settings settings = Settings.builder().put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "dne").build(); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> @@ -134,14 +107,6 @@ public class DiscoveryModuleTests extends ESTestCase { assertEquals("Unknown discovery type [dne]", e.getMessage()); } - public void testDuplicateDiscovery() { - DummyDiscoveryPlugin plugin1 = () -> Collections.singletonMap("dup", () -> null); - DummyDiscoveryPlugin plugin2 = () -> Collections.singletonMap("dup", () -> null); - IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> - newModule(Settings.EMPTY, Arrays.asList(plugin1, plugin2))); - assertEquals("Cannot register discovery type [dup] twice", e.getMessage()); - } - public void testHostsProvider() { Settings settings = Settings.builder().put(DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING.getKey(), "custom").build(); AtomicBoolean created = new AtomicBoolean(false); diff --git a/server/src/test/java/org/elasticsearch/discovery/SnapshotDisruptionIT.java b/server/src/test/java/org/elasticsearch/discovery/SnapshotDisruptionIT.java index 8548b332c1a..b9ac5f33dd9 100644 --- a/server/src/test/java/org/elasticsearch/discovery/SnapshotDisruptionIT.java +++ b/server/src/test/java/org/elasticsearch/discovery/SnapshotDisruptionIT.java @@ -18,8 +18,6 @@ */ package org.elasticsearch.discovery; -import java.util.Arrays; -import java.util.Collection; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse; @@ -38,17 +36,18 @@ import org.elasticsearch.snapshots.SnapshotInfo; import org.elasticsearch.snapshots.SnapshotMissingException; import org.elasticsearch.snapshots.SnapshotState; import org.elasticsearch.test.ESIntegTestCase; -import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.test.disruption.NetworkDisruption; import org.elasticsearch.test.junit.annotations.TestLogging; +import org.elasticsearch.test.transport.MockTransportService; +import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.elasticsearch.test.transport.MockTransportService; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; @@ -68,7 +67,6 @@ public class SnapshotDisruptionIT extends ESIntegTestCase { protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder().put(super.nodeSettings(nodeOrdinal)) .put(AbstractDisruptionTestCase.DEFAULT_SETTINGS) - .put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false) .build(); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java index 363050fde26..4aeebaf0505 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java @@ -140,7 +140,6 @@ import org.elasticsearch.search.MockSearchService; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchService; import org.elasticsearch.test.client.RandomizingClient; -import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.test.disruption.NetworkDisruption; import org.elasticsearch.test.disruption.ServiceDisruptionScheme; import org.elasticsearch.test.store.MockFSIndexStore; @@ -1931,9 +1930,6 @@ public abstract class ESIntegTestCase extends ESTestCase { initialNodeSettings.put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType()); initialTransportClientSettings.put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType()); } - if (addTestZenDiscovery() && getUseZen2() == false) { - initialNodeSettings.put(TestZenDiscovery.USE_ZEN2.getKey(), false); - } return new NodeConfigurationSource() { @Override public Settings nodeSettings(int nodeOrdinal) { @@ -1979,14 +1975,6 @@ public abstract class ESIntegTestCase extends ESTestCase { return true; } - /** - * Iff this returns true test zen discovery implementations is used for the test runs. - * The default is {@code true}. - */ - protected boolean addTestZenDiscovery() { - return true; - } - /** Returns {@code true} iff this test cluster should use a dummy http transport */ protected boolean addMockHttpTransport() { return true; @@ -2028,9 +2016,6 @@ public abstract class ESIntegTestCase extends ESTestCase { if (addMockTransportService()) { mocks.add(getTestTransportPlugin()); } - if (addTestZenDiscovery()) { - mocks.add(TestZenDiscovery.TestPlugin.class); - } if (addMockHttpTransport()) { mocks.add(MockHttpTransport.TestPlugin.class); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java index e2d21043282..376264954d7 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java @@ -50,7 +50,6 @@ import org.elasticsearch.node.NodeValidationException; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.script.ScriptService; import org.elasticsearch.search.internal.SearchContext; -import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.threadpool.ThreadPool; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -193,7 +192,6 @@ public abstract class ESSingleNodeTestCase extends ESTestCase { .put(EsExecutors.PROCESSORS_SETTING.getKey(), 1) // limit the number of threads created .put("transport.type", getTestTransportType()) .put(Node.NODE_DATA_SETTING.getKey(), true) - .put(TestZenDiscovery.USE_ZEN2.getKey(), getUseZen2()) .put(NodeEnvironment.NODE_ID_SEED_SETTING.getKey(), random().nextLong()) // default the watermarks low values to prevent tests from failing on nodes without enough disk space .put(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), "1b") @@ -212,10 +210,6 @@ public abstract class ESSingleNodeTestCase extends ESTestCase { plugins = new ArrayList<>(plugins); plugins.add(getTestTransportPlugin()); } - if (plugins.contains(TestZenDiscovery.TestPlugin.class) == false) { - plugins = new ArrayList<>(plugins); - plugins.add(TestZenDiscovery.TestPlugin.class); - } if (addMockHttpTransport()) { plugins.add(MockHttpTransport.TestPlugin.class); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java index 235cf2ad24f..a36018921e9 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java @@ -1006,17 +1006,6 @@ public abstract class ESTestCase extends LuceneTestCase { return geohashGenerator.ofStringLength(random(), minPrecision, maxPrecision); } - private static boolean useZen2; - - @BeforeClass - public static void setUseZen2() { - useZen2 = true; - } - - protected static boolean getUseZen2() { - return useZen2; - } - public static String getTestTransportType() { return MockNioTransportPlugin.MOCK_NIO_TRANSPORT_NAME; } diff --git a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java index 12902b70177..a1a3865dcde 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java @@ -76,7 +76,6 @@ import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.core.internal.io.IOUtils; -import org.elasticsearch.discovery.DiscoveryModule; import org.elasticsearch.discovery.zen.ElectMasterService; import org.elasticsearch.discovery.zen.ZenDiscovery; import org.elasticsearch.env.Environment; @@ -106,7 +105,6 @@ import org.elasticsearch.node.NodeValidationException; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.script.ScriptService; import org.elasticsearch.search.SearchService; -import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.test.disruption.ServiceDisruptionScheme; import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.transport.MockTransportClient; @@ -151,6 +149,9 @@ import static org.apache.lucene.util.LuceneTestCase.rarely; import static org.elasticsearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; import static org.elasticsearch.common.unit.TimeValue.timeValueMillis; import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; +import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_TYPE_SETTING; +import static org.elasticsearch.discovery.DiscoveryModule.ZEN2_DISCOVERY_TYPE; +import static org.elasticsearch.discovery.DiscoveryModule.ZEN_DISCOVERY_TYPE; import static org.elasticsearch.discovery.DiscoverySettings.INITIAL_STATE_TIMEOUT_SETTING; import static org.elasticsearch.discovery.zen.ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING; import static org.elasticsearch.discovery.zen.FileBasedUnicastHostsProvider.UNICAST_HOSTS_FILE; @@ -158,8 +159,6 @@ import static org.elasticsearch.test.ESTestCase.assertBusy; import static org.elasticsearch.test.ESTestCase.awaitBusy; import static org.elasticsearch.test.ESTestCase.getTestTransportType; import static org.elasticsearch.test.ESTestCase.randomFrom; -import static org.elasticsearch.test.discovery.TestZenDiscovery.USE_ZEN2; -import static org.elasticsearch.test.discovery.TestZenDiscovery.usingZen1; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; @@ -401,6 +400,10 @@ public final class InternalTestCluster extends TestCluster { EsExecutors.daemonThreadFactory("test_" + clusterName), new ThreadContext(Settings.EMPTY)); } + private static boolean usingZen1(Settings settings) { + return ZEN_DISCOVERY_TYPE.equals(DISCOVERY_TYPE_SETTING.get(settings)); + } + public int getBootstrapMasterNodeIndex() { return bootstrapMasterNodeIndex; } @@ -636,9 +639,9 @@ public final class InternalTestCluster extends TestCluster { .put("node.name", name) .put(NodeEnvironment.NODE_ID_SEED_SETTING.getKey(), seed); - final String discoveryType = DiscoveryModule.DISCOVERY_TYPE_SETTING.get(updatedSettings.build()); + final String discoveryType = DISCOVERY_TYPE_SETTING.get(updatedSettings.build()); final boolean usingSingleNodeDiscovery = discoveryType.equals("single-node"); - final boolean usingZen1 = TestZenDiscovery.usingZen1(updatedSettings.build()); + final boolean usingZen1 = usingZen1(updatedSettings.build()); if (usingSingleNodeDiscovery == false) { if (autoManageMinMasterNodes) { assertThat("min master nodes may not be set when auto managed", @@ -1009,8 +1012,8 @@ public final class InternalTestCluster extends TestCluster { if (DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.exists(finalSettings)) { // simulating an upgrade from Zen1 to Zen2, but there's no way to remove a setting when restarting a node, so // you have to set it to REMOVED_MINIMUM_MASTER_NODES (== Integer.MAX_VALUE) to indicate its removal: - assertTrue(USE_ZEN2.exists(finalSettings)); - assertTrue(USE_ZEN2.get(finalSettings)); + assertTrue(DISCOVERY_TYPE_SETTING.exists(finalSettings)); + assertThat(DISCOVERY_TYPE_SETTING.get(finalSettings), equalTo(ZEN2_DISCOVERY_TYPE)); assertThat(DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.get(finalSettings), equalTo(REMOVED_MINIMUM_MASTER_NODES)); final Builder builder = Settings.builder().put(finalSettings); @@ -2057,7 +2060,8 @@ public final class InternalTestCluster extends TestCluster { final int prevMasterCount = getMasterNodesCount(); int autoBootstrapMasterNodeIndex = prevMasterCount == 0 && autoManageMinMasterNodes && newMasterCount > 0 && Arrays.stream(extraSettings) - .allMatch(s -> Node.NODE_MASTER_SETTING.get(s) == false || TestZenDiscovery.USE_ZEN2.get(s) == true) + .allMatch(s -> Node.NODE_MASTER_SETTING.get(s) == false + || ZEN2_DISCOVERY_TYPE.equals(DISCOVERY_TYPE_SETTING.get(s))) ? RandomNumbers.randomIntBetween(random, 0, newMasterCount - 1) : -1; final int numOfNodes = extraSettings.length; diff --git a/test/framework/src/main/java/org/elasticsearch/test/discovery/TestZenDiscovery.java b/test/framework/src/main/java/org/elasticsearch/test/discovery/TestZenDiscovery.java deleted file mode 100644 index 43976b9dfc7..00000000000 --- a/test/framework/src/main/java/org/elasticsearch/test/discovery/TestZenDiscovery.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.test.discovery; - -import org.elasticsearch.cluster.coordination.Coordinator; -import org.elasticsearch.cluster.routing.allocation.AllocationService; -import org.elasticsearch.cluster.service.ClusterApplier; -import org.elasticsearch.cluster.service.ClusterApplierService; -import org.elasticsearch.cluster.service.MasterService; -import org.elasticsearch.common.Randomness; -import org.elasticsearch.common.io.stream.NamedWriteableRegistry; -import org.elasticsearch.common.settings.ClusterSettings; -import org.elasticsearch.common.settings.Setting; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.discovery.Discovery; -import org.elasticsearch.discovery.DiscoveryModule; -import org.elasticsearch.discovery.zen.UnicastHostsProvider; -import org.elasticsearch.discovery.zen.ZenDiscovery; -import org.elasticsearch.discovery.zen.ZenPing; -import org.elasticsearch.gateway.GatewayMetaState; -import org.elasticsearch.plugins.DiscoveryPlugin; -import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.TransportService; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.function.Supplier; - -import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; - -/** - * A alternative zen discovery which allows using mocks for things like pings, as well as - * giving access to internals. - */ -public class TestZenDiscovery extends ZenDiscovery { - - public static final Setting USE_MOCK_PINGS = - Setting.boolSetting("discovery.zen.use_mock_pings", true, Setting.Property.NodeScope); - - public static final Setting USE_ZEN2 = - Setting.boolSetting("discovery.zen.use_zen2", true, Setting.Property.NodeScope); - private static final String TEST_ZEN_DISCOVERY_TYPE = "test-zen"; - - /** A plugin which installs mock discovery and configures it to be used. */ - public static class TestPlugin extends Plugin implements DiscoveryPlugin { - protected final Settings settings; - public TestPlugin(Settings settings) { - this.settings = settings; - } - - @Override - public Map> getDiscoveryTypes(ThreadPool threadPool, TransportService transportService, - NamedWriteableRegistry namedWriteableRegistry, - MasterService masterService, ClusterApplier clusterApplier, - ClusterSettings clusterSettings, UnicastHostsProvider hostsProvider, - AllocationService allocationService, GatewayMetaState gatewayMetaState) { - // we don't get the latest setting which were updated by the extra settings for the plugin. TODO: fix. - Settings fixedSettings = Settings.builder().put(settings).putList(DISCOVERY_SEED_HOSTS_SETTING.getKey()).build(); - return Collections.singletonMap("test-zen", () -> { - if (USE_ZEN2.get(settings)) { - return new Coordinator("test_node", fixedSettings, clusterSettings, transportService, namedWriteableRegistry, - allocationService, masterService, - () -> gatewayMetaState.getPersistedState(settings, (ClusterApplierService) clusterApplier), hostsProvider, - clusterApplier, Collections.emptyList(), new Random(Randomness.get().nextLong())); - } else { - return new TestZenDiscovery(fixedSettings, threadPool, transportService, namedWriteableRegistry, masterService, - clusterApplier, clusterSettings, hostsProvider, allocationService, gatewayMetaState); - } - }); - } - - @Override - public List> getSettings() { - return Arrays.asList(USE_MOCK_PINGS, USE_ZEN2); - } - - @Override - public Settings additionalSettings() { - return Settings.builder() - .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), TEST_ZEN_DISCOVERY_TYPE) - .putList(DISCOVERY_SEED_HOSTS_SETTING.getKey()) - .build(); - } - } - - private TestZenDiscovery(Settings settings, ThreadPool threadPool, TransportService transportService, - NamedWriteableRegistry namedWriteableRegistry, MasterService masterService, - ClusterApplier clusterApplier, ClusterSettings clusterSettings, UnicastHostsProvider hostsProvider, - AllocationService allocationService, GatewayMetaState gatewayMetaState) { - super(settings, threadPool, transportService, namedWriteableRegistry, masterService, clusterApplier, clusterSettings, - hostsProvider, allocationService, Collections.emptyList(), gatewayMetaState); - } - - @Override - protected ZenPing newZenPing(Settings settings, ThreadPool threadPool, TransportService transportService, - UnicastHostsProvider hostsProvider) { - if (USE_MOCK_PINGS.get(settings) && USE_ZEN2.get(settings) == false) { - return new MockZenPing(this); - } else { - return super.newZenPing(settings, threadPool, transportService, hostsProvider); - } - } - - public ZenPing getZenPing() { - return zenPing; - } - - public static boolean usingZen1(Settings settings) { - return DiscoveryModule.ZEN_DISCOVERY_TYPE.equals(DiscoveryModule.DISCOVERY_TYPE_SETTING.get(settings)) - || USE_ZEN2.get(settings) == false; - } -} diff --git a/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java b/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java index f1028322754..1aaaf6aa90a 100644 --- a/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java +++ b/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java @@ -35,7 +35,6 @@ import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.InternalTestCluster; import org.elasticsearch.test.MockHttpTransport; import org.elasticsearch.test.NodeConfigurationSource; -import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.transport.TransportSettings; import java.io.IOException; @@ -72,7 +71,7 @@ import static org.hamcrest.Matchers.not; public class InternalTestClusterTests extends ESTestCase { private static Collection> mockPlugins() { - return Arrays.asList(getTestTransportPlugin(), TestZenDiscovery.TestPlugin.class, MockHttpTransport.TestPlugin.class); + return Arrays.asList(getTestTransportPlugin(), MockHttpTransport.TestPlugin.class); } public void testInitializiationIsConsistent() { diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java index 48ea50af999..8dd70a23cf8 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java @@ -64,7 +64,6 @@ import org.elasticsearch.test.InternalTestCluster; import org.elasticsearch.test.MockHttpTransport; import org.elasticsearch.test.NodeConfigurationSource; import org.elasticsearch.test.TestCluster; -import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.transport.TransportService; import org.elasticsearch.transport.nio.MockNioTransportPlugin; @@ -121,7 +120,7 @@ public abstract class CcrIntegTestCase extends ESTestCase { stopClusters(); Collection> mockPlugins = Arrays.asList(ESIntegTestCase.TestSeedPlugin.class, - TestZenDiscovery.TestPlugin.class, MockHttpTransport.TestPlugin.class, MockTransportService.TestPlugin.class, + MockHttpTransport.TestPlugin.class, MockTransportService.TestPlugin.class, MockNioTransportPlugin.class); InternalTestCluster leaderCluster = new InternalTestCluster(randomLong(), createTempDir(), true, true, numberOfNodesPerCluster(), diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/NetworkDisruptionIT.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/NetworkDisruptionIT.java index 5429bddc437..8a257baa3d6 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/NetworkDisruptionIT.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/NetworkDisruptionIT.java @@ -8,12 +8,10 @@ package org.elasticsearch.xpack.ml.integration; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.support.master.AcknowledgedResponse; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeUnit; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.test.disruption.NetworkDisruption; import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.xpack.core.ml.action.CloseJobAction; @@ -33,13 +31,6 @@ import java.util.Set; public class NetworkDisruptionIT extends BaseMlIntegTestCase { - @Override - protected Settings nodeSettings(int nodeOrdinal) { - return Settings.builder().put(super.nodeSettings(nodeOrdinal)) - .put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false) - .build(); - } - @Override protected Collection> nodePlugins() { Collection> plugins = new ArrayList<>(super.nodePlugins()); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java index e5627fdd41b..a95f341ed15 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java @@ -26,7 +26,6 @@ import org.elasticsearch.license.LicenseService; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.MockHttpTransport; -import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.ml.MachineLearningField; import org.elasticsearch.xpack.core.ml.action.CloseJobAction; @@ -114,7 +113,7 @@ public abstract class BaseMlIntegTestCase extends ESIntegTestCase { @Override protected Collection> getMockPlugins() { - return Arrays.asList(TestZenDiscovery.TestPlugin.class, TestSeedPlugin.class, MockHttpTransport.TestPlugin.class); + return Arrays.asList(TestSeedPlugin.class, MockHttpTransport.TestPlugin.class); } @Before diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/license/LicensingTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/license/LicensingTests.java index 3d195687721..bd788673123 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/license/LicensingTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/license/LicensingTests.java @@ -26,7 +26,6 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.discovery.DiscoveryModule; -import org.elasticsearch.discovery.zen.ElectMasterService; import org.elasticsearch.node.MockNode; import org.elasticsearch.node.Node; import org.elasticsearch.plugins.Plugin; @@ -35,7 +34,6 @@ import org.elasticsearch.test.MockHttpTransport; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; import org.elasticsearch.test.SecuritySettingsSourceField; -import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.test.junit.annotations.TestLogging; import org.elasticsearch.transport.Netty4Plugin; import org.elasticsearch.transport.Transport; @@ -132,13 +130,6 @@ public class LicensingTests extends SecurityIntegTestCase { return super.maxNumberOfNodes() + 1; } - @Override - public Settings nodeSettings(int nodeOrdinal) { - return Settings.builder().put(super.nodeSettings(nodeOrdinal)) - .put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false) - .build(); - } - @Before public void resetLicensing() { enableLicensing(); @@ -297,18 +288,10 @@ public class LicensingTests extends SecurityIntegTestCase { .put("network.host", "localhost") .put("cluster.name", internalCluster().getClusterName()) .put("path.home", home) - .put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false) - .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "test-zen") - .put(TestZenDiscovery.USE_ZEN2.getKey(), getUseZen2()) .putList(DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING.getKey()) .putList(DISCOVERY_SEED_HOSTS_SETTING.getKey(), unicastHostsList); - if (getUseZen2() == false) { - nodeSettings.put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), - ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.get(internalCluster().getInstance(Settings.class))); - } - Collection> mockPlugins = Arrays.asList(LocalStateSecurity.class, TestZenDiscovery.TestPlugin.class, - MockHttpTransport.TestPlugin.class); + Collection> mockPlugins = Arrays.asList(LocalStateSecurity.class, MockHttpTransport.TestPlugin.class); try (Node node = new MockNode(nodeSettings.build(), mockPlugins)) { node.start(); ensureStableCluster(cluster().size() + 1); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterIntegrationTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterIntegrationTests.java index 5dcb4817396..53dd508c542 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterIntegrationTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterIntegrationTests.java @@ -13,7 +13,6 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.network.NetworkAddress; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; -import org.elasticsearch.discovery.zen.ElectMasterService; import org.elasticsearch.node.MockNode; import org.elasticsearch.node.Node; import org.elasticsearch.node.NodeValidationException; @@ -22,7 +21,6 @@ import org.elasticsearch.test.MockHttpTransport; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; import org.elasticsearch.test.SecuritySettingsSourceField; -import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.ConnectionProfile; import org.elasticsearch.transport.Transport; @@ -77,8 +75,7 @@ public class ServerTransportFilterIntegrationTests extends SecurityIntegTestCase // make sure this is "localhost", no matter if ipv4 or ipv6, but be consistent .put("transport.profiles.client.bind_host", "localhost") .put("xpack.security.audit.enabled", false) - .put(XPackSettings.WATCHER_ENABLED.getKey(), false) - .put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false); + .put(XPackSettings.WATCHER_ENABLED.getKey(), false); if (randomBoolean()) { settingsBuilder.put("transport.profiles.default.xpack.security.type", "node"); // this is default lets set it randomly } @@ -108,15 +105,8 @@ public class ServerTransportFilterIntegrationTests extends SecurityIntegTestCase .put("xpack.security.transport.ssl.enabled", true) .put(XPackSettings.WATCHER_ENABLED.getKey(), false) .put("path.home", home) - .put(Node.NODE_MASTER_SETTING.getKey(), false) - .put(TestZenDiscovery.USE_ZEN2.getKey(), getUseZen2()) - .put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false); - if (getUseZen2() == false) { - nodeSettings.put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), - ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.get(internalCluster().getInstance(Settings.class))); - } - Collection> mockPlugins = Arrays.asList( - LocalStateSecurity.class, TestZenDiscovery.TestPlugin.class, MockHttpTransport.TestPlugin.class); + .put(Node.NODE_MASTER_SETTING.getKey(), false); + Collection> mockPlugins = Arrays.asList(LocalStateSecurity.class, MockHttpTransport.TestPlugin.class); addSSLSettingsForPEMFiles( nodeSettings, "/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem", @@ -154,15 +144,8 @@ public class ServerTransportFilterIntegrationTests extends SecurityIntegTestCase .put(XPackSettings.WATCHER_ENABLED.getKey(), false) .put("discovery.initial_state_timeout", "0s") .put("path.home", home) - .put(Node.NODE_MASTER_SETTING.getKey(), false) - .put(TestZenDiscovery.USE_ZEN2.getKey(), getUseZen2()) - .put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false); - if (getUseZen2() == false) { - nodeSettings.put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), - ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.get(internalCluster().getInstance(Settings.class))); - } - Collection> mockPlugins = Arrays.asList( - LocalStateSecurity.class, TestZenDiscovery.TestPlugin.class, MockHttpTransport.TestPlugin.class); + .put(Node.NODE_MASTER_SETTING.getKey(), false); + Collection> mockPlugins = Arrays.asList(LocalStateSecurity.class, MockHttpTransport.TestPlugin.class); addSSLSettingsForPEMFiles( nodeSettings, "/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem",