From 16d7f0c9998ee71a8e468a041612618a53827cdf Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Fri, 27 May 2016 08:45:54 +0200 Subject: [PATCH] Introduce dedicated master nodes in testing infrastructure (elastic/elasticsearch#2314) This is a companion commit to elastic/elasticsearchelastic/elasticsearch#18514, fixing issues introduced by adding dedicated master nodes to the test infra Original commit: elastic/x-pack-elasticsearch@8c0571f2de67057f416f13870394e08b40d630a3 --- .../messy/tests/SearchInputIT.java | 5 +++-- .../messy/tests/SearchTransformIT.java | 5 +++-- .../plugin/LicensesServiceNodeTests.java | 2 +- .../xpack/TribeTransportTestCase.java | 2 +- .../agent/settings/MarvelSettingsTests.java | 2 +- .../audit/index/IndexAuditTrailTests.java | 9 ++++++--- .../RemoteIndexAuditTrailStartingTests.java | 5 +++-- .../authc/pki/PkiAuthenticationTests.java | 2 +- .../PkiWithoutClientAuthenticationTests.java | 2 +- .../shield/authc/pki/PkiWithoutSSLTests.java | 2 +- .../filter/IpFilteringUpdateTests.java | 2 +- .../elasticsearch/test/ShieldIntegTestCase.java | 17 ++++++++++++----- .../transport/KnownActionsTests.java | 3 +-- .../history/HistoryStoreSettingsTests.java | 3 ++- .../WatcherIndexTemplateRegistryTests.java | 4 ++-- 15 files changed, 39 insertions(+), 26 deletions(-) diff --git a/elasticsearch/qa/messy-test-xpack-with-mustache/src/test/java/org/elasticsearch/messy/tests/SearchInputIT.java b/elasticsearch/qa/messy-test-xpack-with-mustache/src/test/java/org/elasticsearch/messy/tests/SearchInputIT.java index e7480f0050b..b2d46d4a4ac 100644 --- a/elasticsearch/qa/messy-test-xpack-with-mustache/src/test/java/org/elasticsearch/messy/tests/SearchInputIT.java +++ b/elasticsearch/qa/messy-test-xpack-with-mustache/src/test/java/org/elasticsearch/messy/tests/SearchInputIT.java @@ -25,6 +25,7 @@ import org.elasticsearch.script.mustache.MustachePlugin; import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; +import org.elasticsearch.xpack.common.text.TextTemplate; import org.elasticsearch.xpack.watcher.actions.ActionWrapper; import org.elasticsearch.xpack.watcher.actions.ExecutableActions; import org.elasticsearch.xpack.watcher.condition.always.ExecutableAlwaysCondition; @@ -36,7 +37,6 @@ import org.elasticsearch.xpack.watcher.input.search.SearchInputFactory; import org.elasticsearch.xpack.watcher.input.simple.ExecutableSimpleInput; import org.elasticsearch.xpack.watcher.input.simple.SimpleInput; import org.elasticsearch.xpack.watcher.support.init.proxy.WatcherClientProxy; -import org.elasticsearch.xpack.common.text.TextTemplate; import org.elasticsearch.xpack.watcher.trigger.schedule.IntervalSchedule; import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleTrigger; import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleTriggerEvent; @@ -72,7 +72,8 @@ import static org.joda.time.DateTimeZone.UTC; /** */ -@ClusterScope(scope = SUITE, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, numDataNodes = 1) +@ClusterScope(scope = SUITE, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, supportsDedicatedMasters = false, + numDataNodes = 1) public class SearchInputIT extends ESIntegTestCase { @Override diff --git a/elasticsearch/qa/messy-test-xpack-with-mustache/src/test/java/org/elasticsearch/messy/tests/SearchTransformIT.java b/elasticsearch/qa/messy-test-xpack-with-mustache/src/test/java/org/elasticsearch/messy/tests/SearchTransformIT.java index dc13579070b..d2b9f47bbd3 100644 --- a/elasticsearch/qa/messy-test-xpack-with-mustache/src/test/java/org/elasticsearch/messy/tests/SearchTransformIT.java +++ b/elasticsearch/qa/messy-test-xpack-with-mustache/src/test/java/org/elasticsearch/messy/tests/SearchTransformIT.java @@ -30,6 +30,7 @@ import org.elasticsearch.script.mustache.MustachePlugin; import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; +import org.elasticsearch.xpack.common.text.TextTemplate; import org.elasticsearch.xpack.watcher.actions.ExecutableActions; import org.elasticsearch.xpack.watcher.condition.always.ExecutableAlwaysCondition; import org.elasticsearch.xpack.watcher.execution.TriggeredExecutionContext; @@ -37,7 +38,6 @@ import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext; import org.elasticsearch.xpack.watcher.input.simple.ExecutableSimpleInput; import org.elasticsearch.xpack.watcher.input.simple.SimpleInput; import org.elasticsearch.xpack.watcher.support.init.proxy.WatcherClientProxy; -import org.elasticsearch.xpack.common.text.TextTemplate; import org.elasticsearch.xpack.watcher.transform.Transform; import org.elasticsearch.xpack.watcher.transform.TransformBuilders; import org.elasticsearch.xpack.watcher.transform.search.ExecutableSearchTransform; @@ -91,7 +91,8 @@ import static org.joda.time.DateTimeZone.UTC; /** * */ -@ClusterScope(scope = SUITE, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, numDataNodes = 1) +@ClusterScope(scope = SUITE, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, supportsDedicatedMasters = false, + numDataNodes = 1) public class SearchTransformIT extends ESIntegTestCase { @Override diff --git a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/LicensesServiceNodeTests.java b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/LicensesServiceNodeTests.java index 9ac18c44d95..13b77e9eec1 100644 --- a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/LicensesServiceNodeTests.java +++ b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/LicensesServiceNodeTests.java @@ -21,7 +21,7 @@ import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST; /** */ -@ESIntegTestCase.ClusterScope(scope = TEST, numDataNodes = 10, numClientNodes = 0) +@ESIntegTestCase.ClusterScope(scope = TEST, supportsDedicatedMasters = false, numDataNodes = 10, numClientNodes = 0) public class LicensesServiceNodeTests extends AbstractLicensesIntegrationTestCase { @Override diff --git a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/xpack/TribeTransportTestCase.java b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/xpack/TribeTransportTestCase.java index deb1c6456e4..0ba61a72e1e 100644 --- a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/xpack/TribeTransportTestCase.java +++ b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/xpack/TribeTransportTestCase.java @@ -100,7 +100,7 @@ public abstract class TribeTransportTestCase extends ESIntegTestCase { } }; final InternalTestCluster cluster2 = new InternalTestCluster(InternalTestCluster.configuredNodeMode(), - randomLong(), createTempDir(), 2, 2, + randomLong(), createTempDir(), true, 2, 2, UUIDs.randomBase64UUID(random()), nodeConfigurationSource, 1, false, "tribe_node2", getMockPlugins(), getClientWrapper()); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/settings/MarvelSettingsTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/settings/MarvelSettingsTests.java index bea8fe25868..6a7e6f754ac 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/settings/MarvelSettingsTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/settings/MarvelSettingsTests.java @@ -23,7 +23,7 @@ import static org.hamcrest.Matchers.equalTo; //test is just too slow, please fix it to not be sleep-based //@BadApple(bugUrl = "https://github.com/elastic/x-plugins/issues/1007") -@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 1, numClientNodes = 0) +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, supportsDedicatedMasters = false, numDataNodes = 1, numClientNodes = 0) public class MarvelSettingsTests extends MarvelIntegTestCase { private final TimeValue interval = newRandomTimeValue(); private final TimeValue indexStatsTimeout = newRandomTimeValue(); diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java index ef210aa05bf..be3a74d833f 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java @@ -13,9 +13,9 @@ import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.Client; -import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.client.Requests; import org.elasticsearch.cluster.health.ClusterHealthStatus; +import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Priority; import org.elasticsearch.common.inject.util.Providers; import org.elasticsearch.common.network.NetworkAddress; @@ -36,6 +36,9 @@ import org.elasticsearch.shield.authc.AuthenticationToken; import org.elasticsearch.shield.crypto.InternalCryptoService; import org.elasticsearch.shield.transport.filter.IPFilter; import org.elasticsearch.shield.transport.filter.ShieldIpFilterRule; +import org.elasticsearch.shield.transport.netty.ShieldNettyTransport; +import org.elasticsearch.shield.user.SystemUser; +import org.elasticsearch.shield.user.User; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.InternalTestCluster; import org.elasticsearch.test.ShieldIntegTestCase; @@ -80,7 +83,7 @@ import static org.mockito.Mockito.when; /** * */ -@ESIntegTestCase.ClusterScope(scope = SUITE, numDataNodes = 1) +@ESIntegTestCase.ClusterScope(scope = SUITE, supportsDedicatedMasters = false, numDataNodes = 1) public class IndexAuditTrailTests extends ShieldIntegTestCase { public static final String SECOND_CLUSTER_NODE_PREFIX = "remote_" + SUITE_CLUSTER_NODE_PREFIX; @@ -143,7 +146,7 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase { return builder.build(); } }; - remoteCluster = new InternalTestCluster("network", randomLong(), createTempDir(), numNodes, numNodes, cluster2Name, + remoteCluster = new InternalTestCluster("network", randomLong(), createTempDir(), false, numNodes, numNodes, cluster2Name, cluster2SettingsSource, 0, false, SECOND_CLUSTER_NODE_PREFIX, getMockPlugins(), useShield ? getClientWrapper() : Function.identity()); remoteCluster.beforeTest(random(), 0.5); diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/RemoteIndexAuditTrailStartingTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/RemoteIndexAuditTrailStartingTests.java index 8ccf9e94319..776b8e0ebd0 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/RemoteIndexAuditTrailStartingTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/RemoteIndexAuditTrailStartingTests.java @@ -104,8 +104,9 @@ public class RemoteIndexAuditTrailStartingTests extends ShieldIntegTestCase { return builder.build(); } }; - remoteCluster = new InternalTestCluster("network", randomLong(), createTempDir(), numNodes, numNodes, cluster2Name, - cluster2SettingsSource, 0, false, SECOND_CLUSTER_NODE_PREFIX, getMockPlugins(), getClientWrapper()); + remoteCluster = new InternalTestCluster("network", randomLong(), createTempDir(), false, + numNodes, numNodes, + cluster2Name, cluster2SettingsSource, 0, false, SECOND_CLUSTER_NODE_PREFIX, getMockPlugins(), getClientWrapper()); remoteCluster.beforeTest(random(), 0.5); } diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/pki/PkiAuthenticationTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/pki/PkiAuthenticationTests.java index e93e7243269..26f8f964ea7 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/pki/PkiAuthenticationTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/pki/PkiAuthenticationTests.java @@ -46,7 +46,7 @@ import static org.hamcrest.Matchers.is; /** * Test authentication via PKI on both REST and Transport layers */ -@ClusterScope(numClientNodes = 0, numDataNodes = 1) +@ClusterScope(numClientNodes = 0, supportsDedicatedMasters = false, numDataNodes = 1) public class PkiAuthenticationTests extends ShieldIntegTestCase { @Override diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/pki/PkiWithoutClientAuthenticationTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/pki/PkiWithoutClientAuthenticationTests.java index bd6c7fc5b94..f874fcfebe2 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/pki/PkiWithoutClientAuthenticationTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/pki/PkiWithoutClientAuthenticationTests.java @@ -33,7 +33,7 @@ import java.util.Locale; import static org.hamcrest.Matchers.is; -@ClusterScope(numClientNodes = 0, numDataNodes = 1) +@ClusterScope(numClientNodes = 0, supportsDedicatedMasters = false, numDataNodes = 1) public class PkiWithoutClientAuthenticationTests extends ShieldIntegTestCase { private TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/pki/PkiWithoutSSLTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/pki/PkiWithoutSSLTests.java index e1e6d933bc1..fcfc3cccdb0 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/pki/PkiWithoutSSLTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/pki/PkiWithoutSSLTests.java @@ -21,7 +21,7 @@ import org.elasticsearch.test.rest.client.http.HttpResponse; import static org.hamcrest.Matchers.is; -@ClusterScope(numClientNodes = 0, numDataNodes = 1) +@ClusterScope(numClientNodes = 0, supportsDedicatedMasters = false, numDataNodes = 1) public class PkiWithoutSSLTests extends ShieldIntegTestCase { @Override public boolean sslTransportEnabled() { diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/transport/filter/IpFilteringUpdateTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/transport/filter/IpFilteringUpdateTests.java index 7218c0d27ce..c0da74d8ba8 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/transport/filter/IpFilteringUpdateTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/transport/filter/IpFilteringUpdateTests.java @@ -20,7 +20,7 @@ import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.is; -@ClusterScope(scope = TEST, numDataNodes = 1) +@ClusterScope(scope = TEST, supportsDedicatedMasters = false, numDataNodes = 1) public class IpFilteringUpdateTests extends ShieldIntegTestCase { private static int randomClientPort; diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldIntegTestCase.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldIntegTestCase.java index 070a82b676a..c1a09ae3833 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldIntegTestCase.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldIntegTestCase.java @@ -59,13 +59,20 @@ public abstract class ShieldIntegTestCase extends ESIntegTestCase { private static int maxNumberOfNodes() { ClusterScope clusterScope = ShieldIntegTestCase.class.getAnnotation(ClusterScope.class); if (clusterScope == null) { - return InternalTestCluster.DEFAULT_MAX_NUM_DATA_NODES + InternalTestCluster.DEFAULT_MAX_NUM_CLIENT_NODES; + return InternalTestCluster.DEFAULT_HIGH_NUM_MASTER_NODES + + InternalTestCluster.DEFAULT_MAX_NUM_DATA_NODES + + InternalTestCluster.DEFAULT_MAX_NUM_CLIENT_NODES; } else { - if (clusterScope.numClientNodes() < 0) { - return clusterScope.maxNumDataNodes() + InternalTestCluster.DEFAULT_MAX_NUM_CLIENT_NODES; - } else { - return clusterScope.maxNumDataNodes() + clusterScope.numClientNodes(); + int clientNodes = clusterScope.numClientNodes(); + if (clientNodes < 0) { + clientNodes = InternalTestCluster.DEFAULT_MAX_NUM_CLIENT_NODES; } + int masterNodes = 0; + if (clusterScope.supportsDedicatedMasters()) { + masterNodes = InternalTestCluster.DEFAULT_HIGH_NUM_MASTER_NODES; + } + + return masterNodes + clusterScope.maxNumDataNodes() + clientNodes; } } diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/transport/KnownActionsTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/transport/KnownActionsTests.java index d1bb8285252..4f994db7f90 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/transport/KnownActionsTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/transport/KnownActionsTests.java @@ -15,7 +15,6 @@ import org.elasticsearch.shield.action.ShieldActionModule; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ShieldIntegTestCase; import org.elasticsearch.xpack.XPackPlugin; -import org.elasticsearch.xpack.watcher.Watcher; import org.junit.BeforeClass; import java.io.IOException; @@ -43,7 +42,7 @@ import static org.hamcrest.CoreMatchers.hasItems; import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.is; -@ClusterScope(numClientNodes = 0, numDataNodes = 1) +@ClusterScope(numClientNodes = 0, supportsDedicatedMasters = false, numDataNodes = 1) public class KnownActionsTests extends ShieldIntegTestCase { private static Set knownActions; private static Set knownHandlers; diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryStoreSettingsTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryStoreSettingsTests.java index a401da098d4..68154144268 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryStoreSettingsTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryStoreSettingsTests.java @@ -21,7 +21,8 @@ import static org.hamcrest.core.Is.is; /** */ @TestLogging("cluster:DEBUG,action.admin.cluster.settings:DEBUG,watcher:DEBUG") -@ESIntegTestCase.ClusterScope(scope = TEST, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, numDataNodes = 1) +@ESIntegTestCase.ClusterScope(scope = TEST, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, + supportsDedicatedMasters = false, numDataNodes = 1) public class HistoryStoreSettingsTests extends AbstractWatcherIntegrationTestCase { public void testChangeSettings() throws Exception { diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java index e1528f9c86b..41d7cbc29ff 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java @@ -11,7 +11,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase; -import org.elasticsearch.xpack.watcher.WatcherModule; import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase; import java.util.ArrayList; @@ -25,7 +24,8 @@ import static org.hamcrest.core.Is.is; /** */ -@ESIntegTestCase.ClusterScope(scope = TEST, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, numDataNodes = 1) +@ESIntegTestCase.ClusterScope(scope = TEST, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, + supportsDedicatedMasters = false, numDataNodes = 1) public class WatcherIndexTemplateRegistryTests extends AbstractWatcherIntegrationTestCase { @Override