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@8c0571f2de
This commit is contained in:
Boaz Leskes 2016-05-27 08:45:54 +02:00
parent 21b2494c5b
commit 16d7f0c999
15 changed files with 39 additions and 26 deletions

View File

@ -25,6 +25,7 @@ import org.elasticsearch.script.mustache.MustachePlugin;
import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope; 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.ActionWrapper;
import org.elasticsearch.xpack.watcher.actions.ExecutableActions; import org.elasticsearch.xpack.watcher.actions.ExecutableActions;
import org.elasticsearch.xpack.watcher.condition.always.ExecutableAlwaysCondition; 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.ExecutableSimpleInput;
import org.elasticsearch.xpack.watcher.input.simple.SimpleInput; import org.elasticsearch.xpack.watcher.input.simple.SimpleInput;
import org.elasticsearch.xpack.watcher.support.init.proxy.WatcherClientProxy; 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.IntervalSchedule;
import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleTrigger; import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleTrigger;
import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleTriggerEvent; 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 { public class SearchInputIT extends ESIntegTestCase {
@Override @Override

View File

@ -30,6 +30,7 @@ import org.elasticsearch.script.mustache.MustachePlugin;
import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope; 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.actions.ExecutableActions;
import org.elasticsearch.xpack.watcher.condition.always.ExecutableAlwaysCondition; import org.elasticsearch.xpack.watcher.condition.always.ExecutableAlwaysCondition;
import org.elasticsearch.xpack.watcher.execution.TriggeredExecutionContext; 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.ExecutableSimpleInput;
import org.elasticsearch.xpack.watcher.input.simple.SimpleInput; import org.elasticsearch.xpack.watcher.input.simple.SimpleInput;
import org.elasticsearch.xpack.watcher.support.init.proxy.WatcherClientProxy; 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.Transform;
import org.elasticsearch.xpack.watcher.transform.TransformBuilders; import org.elasticsearch.xpack.watcher.transform.TransformBuilders;
import org.elasticsearch.xpack.watcher.transform.search.ExecutableSearchTransform; 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 { public class SearchTransformIT extends ESIntegTestCase {
@Override @Override

View File

@ -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 { public class LicensesServiceNodeTests extends AbstractLicensesIntegrationTestCase {
@Override @Override

View File

@ -100,7 +100,7 @@ public abstract class TribeTransportTestCase extends ESIntegTestCase {
} }
}; };
final InternalTestCluster cluster2 = new InternalTestCluster(InternalTestCluster.configuredNodeMode(), final InternalTestCluster cluster2 = new InternalTestCluster(InternalTestCluster.configuredNodeMode(),
randomLong(), createTempDir(), 2, 2, randomLong(), createTempDir(), true, 2, 2,
UUIDs.randomBase64UUID(random()), nodeConfigurationSource, 1, false, "tribe_node2", UUIDs.randomBase64UUID(random()), nodeConfigurationSource, 1, false, "tribe_node2",
getMockPlugins(), getClientWrapper()); getMockPlugins(), getClientWrapper());

View File

@ -23,7 +23,7 @@ import static org.hamcrest.Matchers.equalTo;
//test is just too slow, please fix it to not be sleep-based //test is just too slow, please fix it to not be sleep-based
//@BadApple(bugUrl = "https://github.com/elastic/x-plugins/issues/1007") //@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 { public class MarvelSettingsTests extends MarvelIntegTestCase {
private final TimeValue interval = newRandomTimeValue(); private final TimeValue interval = newRandomTimeValue();
private final TimeValue indexStatsTimeout = newRandomTimeValue(); private final TimeValue indexStatsTimeout = newRandomTimeValue();

View File

@ -13,9 +13,9 @@ import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.client.Requests; import org.elasticsearch.client.Requests;
import org.elasticsearch.cluster.health.ClusterHealthStatus; import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.Priority; import org.elasticsearch.common.Priority;
import org.elasticsearch.common.inject.util.Providers; import org.elasticsearch.common.inject.util.Providers;
import org.elasticsearch.common.network.NetworkAddress; 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.crypto.InternalCryptoService;
import org.elasticsearch.shield.transport.filter.IPFilter; import org.elasticsearch.shield.transport.filter.IPFilter;
import org.elasticsearch.shield.transport.filter.ShieldIpFilterRule; 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.ESIntegTestCase;
import org.elasticsearch.test.InternalTestCluster; import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.ShieldIntegTestCase; 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 class IndexAuditTrailTests extends ShieldIntegTestCase {
public static final String SECOND_CLUSTER_NODE_PREFIX = "remote_" + SUITE_CLUSTER_NODE_PREFIX; 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(); 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(), cluster2SettingsSource, 0, false, SECOND_CLUSTER_NODE_PREFIX, getMockPlugins(),
useShield ? getClientWrapper() : Function.identity()); useShield ? getClientWrapper() : Function.identity());
remoteCluster.beforeTest(random(), 0.5); remoteCluster.beforeTest(random(), 0.5);

View File

@ -104,8 +104,9 @@ public class RemoteIndexAuditTrailStartingTests extends ShieldIntegTestCase {
return builder.build(); return builder.build();
} }
}; };
remoteCluster = new InternalTestCluster("network", randomLong(), createTempDir(), numNodes, numNodes, cluster2Name, remoteCluster = new InternalTestCluster("network", randomLong(), createTempDir(), false,
cluster2SettingsSource, 0, false, SECOND_CLUSTER_NODE_PREFIX, getMockPlugins(), getClientWrapper()); numNodes, numNodes,
cluster2Name, cluster2SettingsSource, 0, false, SECOND_CLUSTER_NODE_PREFIX, getMockPlugins(), getClientWrapper());
remoteCluster.beforeTest(random(), 0.5); remoteCluster.beforeTest(random(), 0.5);
} }

View File

@ -46,7 +46,7 @@ import static org.hamcrest.Matchers.is;
/** /**
* Test authentication via PKI on both REST and Transport layers * 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 { public class PkiAuthenticationTests extends ShieldIntegTestCase {
@Override @Override

View File

@ -33,7 +33,7 @@ import java.util.Locale;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
@ClusterScope(numClientNodes = 0, numDataNodes = 1) @ClusterScope(numClientNodes = 0, supportsDedicatedMasters = false, numDataNodes = 1)
public class PkiWithoutClientAuthenticationTests extends ShieldIntegTestCase { public class PkiWithoutClientAuthenticationTests extends ShieldIntegTestCase {
private TrustManager[] trustAllCerts = new TrustManager[] { private TrustManager[] trustAllCerts = new TrustManager[] {
new X509TrustManager() { new X509TrustManager() {

View File

@ -21,7 +21,7 @@ import org.elasticsearch.test.rest.client.http.HttpResponse;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
@ClusterScope(numClientNodes = 0, numDataNodes = 1) @ClusterScope(numClientNodes = 0, supportsDedicatedMasters = false, numDataNodes = 1)
public class PkiWithoutSSLTests extends ShieldIntegTestCase { public class PkiWithoutSSLTests extends ShieldIntegTestCase {
@Override @Override
public boolean sslTransportEnabled() { public boolean sslTransportEnabled() {

View File

@ -20,7 +20,7 @@ import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
@ClusterScope(scope = TEST, numDataNodes = 1) @ClusterScope(scope = TEST, supportsDedicatedMasters = false, numDataNodes = 1)
public class IpFilteringUpdateTests extends ShieldIntegTestCase { public class IpFilteringUpdateTests extends ShieldIntegTestCase {
private static int randomClientPort; private static int randomClientPort;

View File

@ -59,13 +59,20 @@ public abstract class ShieldIntegTestCase extends ESIntegTestCase {
private static int maxNumberOfNodes() { private static int maxNumberOfNodes() {
ClusterScope clusterScope = ShieldIntegTestCase.class.getAnnotation(ClusterScope.class); ClusterScope clusterScope = ShieldIntegTestCase.class.getAnnotation(ClusterScope.class);
if (clusterScope == null) { 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 { } else {
if (clusterScope.numClientNodes() < 0) { int clientNodes = clusterScope.numClientNodes();
return clusterScope.maxNumDataNodes() + InternalTestCluster.DEFAULT_MAX_NUM_CLIENT_NODES; if (clientNodes < 0) {
} else { clientNodes = InternalTestCluster.DEFAULT_MAX_NUM_CLIENT_NODES;
return clusterScope.maxNumDataNodes() + clusterScope.numClientNodes();
} }
int masterNodes = 0;
if (clusterScope.supportsDedicatedMasters()) {
masterNodes = InternalTestCluster.DEFAULT_HIGH_NUM_MASTER_NODES;
}
return masterNodes + clusterScope.maxNumDataNodes() + clientNodes;
} }
} }

View File

@ -15,7 +15,6 @@ import org.elasticsearch.shield.action.ShieldActionModule;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ShieldIntegTestCase; import org.elasticsearch.test.ShieldIntegTestCase;
import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.watcher.Watcher;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import java.io.IOException; 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.hasItem;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
@ClusterScope(numClientNodes = 0, numDataNodes = 1) @ClusterScope(numClientNodes = 0, supportsDedicatedMasters = false, numDataNodes = 1)
public class KnownActionsTests extends ShieldIntegTestCase { public class KnownActionsTests extends ShieldIntegTestCase {
private static Set<String> knownActions; private static Set<String> knownActions;
private static Set<String> knownHandlers; private static Set<String> knownHandlers;

View File

@ -21,7 +21,8 @@ import static org.hamcrest.core.Is.is;
/** /**
*/ */
@TestLogging("cluster:DEBUG,action.admin.cluster.settings:DEBUG,watcher:DEBUG") @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 class HistoryStoreSettingsTests extends AbstractWatcherIntegrationTestCase {
public void testChangeSettings() throws Exception { public void testChangeSettings() throws Exception {

View File

@ -11,7 +11,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.xpack.watcher.WatcherModule;
import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase; import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase;
import java.util.ArrayList; 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 { public class WatcherIndexTemplateRegistryTests extends AbstractWatcherIntegrationTestCase {
@Override @Override