diff --git a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/IngestFailureStoreMetricsIT.java b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/IngestFailureStoreMetricsIT.java index 4bb51a4bf0df..bd723ef5d301 100644 --- a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/IngestFailureStoreMetricsIT.java +++ b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/IngestFailureStoreMetricsIT.java @@ -57,7 +57,7 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcke /** * An integration test that verifies how different paths/scenarios affect the APM metrics for failure stores. */ -@ESIntegTestCase.ClusterScope(numDataNodes = 0, numClientNodes = 0, scope = ESIntegTestCase.Scope.SUITE) +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 1, numClientNodes = 0, supportsDedicatedMasters = false) public class IngestFailureStoreMetricsIT extends ESIntegTestCase { private static final List METRICS = List.of( diff --git a/qa/smoke-test-http/src/internalClusterTest/java/org/elasticsearch/http/snapshots/AbstractSnapshotRestTestCase.java b/qa/smoke-test-http/src/internalClusterTest/java/org/elasticsearch/http/snapshots/AbstractSnapshotRestTestCase.java index d3d7695a10a3..ac8d2d374a05 100644 --- a/qa/smoke-test-http/src/internalClusterTest/java/org/elasticsearch/http/snapshots/AbstractSnapshotRestTestCase.java +++ b/qa/smoke-test-http/src/internalClusterTest/java/org/elasticsearch/http/snapshots/AbstractSnapshotRestTestCase.java @@ -14,11 +14,9 @@ import org.elasticsearch.common.util.CollectionUtils; import org.elasticsearch.http.HttpSmokeTestCase; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.snapshots.mockstore.MockRepository; -import org.elasticsearch.test.ESIntegTestCase; import java.util.Collection; -@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, numClientNodes = 0) public abstract class AbstractSnapshotRestTestCase extends HttpSmokeTestCase { /** diff --git a/qa/smoke-test-http/src/internalClusterTest/java/org/elasticsearch/http/snapshots/RestGetSnapshotsCancellationIT.java b/qa/smoke-test-http/src/internalClusterTest/java/org/elasticsearch/http/snapshots/RestGetSnapshotsCancellationIT.java index 5a743a75291c..ee830bc0e3ac 100644 --- a/qa/smoke-test-http/src/internalClusterTest/java/org/elasticsearch/http/snapshots/RestGetSnapshotsCancellationIT.java +++ b/qa/smoke-test-http/src/internalClusterTest/java/org/elasticsearch/http/snapshots/RestGetSnapshotsCancellationIT.java @@ -17,6 +17,7 @@ import org.elasticsearch.client.Request; import org.elasticsearch.client.Response; import org.elasticsearch.snapshots.AbstractSnapshotIntegTestCase; import org.elasticsearch.snapshots.mockstore.MockRepository; +import org.elasticsearch.test.ESIntegTestCase; import java.util.concurrent.CancellationException; import java.util.concurrent.TimeUnit; @@ -27,6 +28,7 @@ import static org.elasticsearch.test.TaskAssertions.assertAllTasksHaveFinished; import static org.elasticsearch.test.TaskAssertions.awaitTaskWithPrefix; import static org.hamcrest.core.IsEqual.equalTo; +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) public class RestGetSnapshotsCancellationIT extends AbstractSnapshotRestTestCase { public void testGetSnapshotsCancellation() throws Exception { diff --git a/qa/smoke-test-http/src/internalClusterTest/java/org/elasticsearch/http/snapshots/RestSnapshotsStatusCancellationIT.java b/qa/smoke-test-http/src/internalClusterTest/java/org/elasticsearch/http/snapshots/RestSnapshotsStatusCancellationIT.java index dc10aa27b8a0..cbb08d9812f1 100644 --- a/qa/smoke-test-http/src/internalClusterTest/java/org/elasticsearch/http/snapshots/RestSnapshotsStatusCancellationIT.java +++ b/qa/smoke-test-http/src/internalClusterTest/java/org/elasticsearch/http/snapshots/RestSnapshotsStatusCancellationIT.java @@ -17,6 +17,7 @@ import org.elasticsearch.client.Request; import org.elasticsearch.client.Response; import org.elasticsearch.snapshots.AbstractSnapshotIntegTestCase; import org.elasticsearch.snapshots.mockstore.MockRepository; +import org.elasticsearch.test.ESIntegTestCase; import java.util.Collection; import java.util.concurrent.CancellationException; @@ -27,6 +28,7 @@ import static org.elasticsearch.test.TaskAssertions.assertAllCancellableTasksAre import static org.elasticsearch.test.TaskAssertions.assertAllTasksHaveFinished; import static org.elasticsearch.test.TaskAssertions.awaitTaskWithPrefix; +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) public class RestSnapshotsStatusCancellationIT extends AbstractSnapshotRestTestCase { public void testSnapshotStatusCancellation() throws Exception { diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/AutoCreateSystemIndexIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/AutoCreateSystemIndexIT.java index 5def913d7f12..bcbdc7f73919 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/AutoCreateSystemIndexIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/AutoCreateSystemIndexIT.java @@ -50,7 +50,6 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; -@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) public class AutoCreateSystemIndexIT extends ESIntegTestCase { @Override diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CreateSystemIndicesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CreateSystemIndicesIT.java index 64e23300426b..77c6d7d5dff1 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CreateSystemIndicesIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CreateSystemIndicesIT.java @@ -56,7 +56,6 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; -@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) public class CreateSystemIndicesIT extends ESIntegTestCase { @Before @@ -104,7 +103,6 @@ public class CreateSystemIndicesIT extends ESIntegTestCase { */ public void testNonPrimarySystemIndexIsAutoCreatedViaConcreteName() throws Exception { final String nonPrimarySystemIndex = INDEX_NAME + "-2"; - internalCluster().startNodes(1); // Trigger the creation of the system index indexDoc(nonPrimarySystemIndex, "1", "foo", "bar"); @@ -132,7 +130,6 @@ public class CreateSystemIndicesIT extends ESIntegTestCase { */ public void testNonPrimarySystemIndexCreationThrowsError() { final String nonPrimarySystemIndex = INDEX_NAME + "-2"; - internalCluster().startNodes(1); // Create the system index IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> createIndex(nonPrimarySystemIndex)); @@ -269,8 +266,6 @@ public class CreateSystemIndicesIT extends ESIntegTestCase { } private void doCreateTest(Runnable runnable, String concreteIndex) { - internalCluster().startNodes(1); - // Trigger the creation of the system index runnable.run(); ensureGreen(INDEX_NAME); @@ -293,8 +288,6 @@ public class CreateSystemIndicesIT extends ESIntegTestCase { } public void testConcurrentAutoCreates() throws InterruptedException { - internalCluster().startNodes(3); - final Client client = client(); final int count = randomIntBetween(5, 30); final CountDownLatch latch = new CountDownLatch(count); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/bulk/BulkProcessorClusterSettingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/bulk/BulkProcessorClusterSettingsIT.java index f6169c373bb1..532d7fbc471c 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/bulk/BulkProcessorClusterSettingsIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/bulk/BulkProcessorClusterSettingsIT.java @@ -51,6 +51,7 @@ public class BulkProcessorClusterSettingsIT extends ESIntegTestCase { } public void testIndexWithDisabledAutoCreateIndex() { + internalCluster().startNode(); updateClusterSettings(Settings.builder().put(AutoCreateIndex.AUTO_CREATE_INDEX_SETTING.getKey(), randomFrom("-*", "+.*"))); final BulkItemResponse itemResponse = client().prepareBulk() .add(prepareIndex("test-index").setSource("foo", "bar")) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/AwarenessAllocationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/AwarenessAllocationIT.java index 0feaf1b85f95..cbae5a88c90f 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/AwarenessAllocationIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/AwarenessAllocationIT.java @@ -251,6 +251,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase { } public void testForceAwarenessSettingValidation() { + internalCluster().startNode(); final String prefix = AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP_SETTING.getKey(); final IllegalArgumentException illegalArgumentException = expectThrows( diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java index 0ac2d03f68bf..3d732560b253 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java @@ -186,6 +186,8 @@ public class FilteringAllocationIT extends ESIntegTestCase { } public void testInvalidIPFilterClusterSettings() { + logger.info("--> starting 2 nodes"); + internalCluster().startNodes(2); String ipKey = randomFrom("_ip", "_host_ip", "_publish_ip"); var filterSetting = randomFrom( FilterAllocationDecider.CLUSTER_ROUTING_REQUIRE_GROUP_SETTING, diff --git a/server/src/internalClusterTest/java/org/elasticsearch/health/node/ShardsCapacityHealthIndicatorServiceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/health/node/ShardsCapacityHealthIndicatorServiceIT.java index 82454213d9db..01a7ecf4f947 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/health/node/ShardsCapacityHealthIndicatorServiceIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/health/node/ShardsCapacityHealthIndicatorServiceIT.java @@ -16,7 +16,6 @@ import org.elasticsearch.health.HealthService; import org.elasticsearch.health.HealthStatus; import org.elasticsearch.health.metadata.HealthMetadata; import org.elasticsearch.test.ESIntegTestCase; -import org.elasticsearch.test.InternalTestCluster; import org.junit.After; import org.junit.Before; @@ -27,16 +26,14 @@ import static org.elasticsearch.indices.ShardLimitValidator.SETTING_CLUSTER_MAX_ import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.hasSize; -@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 1, numClientNodes = 0, supportsDedicatedMasters = false) public class ShardsCapacityHealthIndicatorServiceIT extends ESIntegTestCase { private static final String INDEX_NAME = "index-name"; - private InternalTestCluster internalCluster; @Before public void setUp() throws Exception { super.setUp(); - internalCluster = internalCluster(); updateClusterSettings(Settings.builder().put(SETTING_CLUSTER_MAX_SHARDS_PER_NODE.getKey(), 30)); } @@ -53,7 +50,7 @@ public class ShardsCapacityHealthIndicatorServiceIT extends ESIntegTestCase { // index: 4 shards + 1 replica = 8 shards used (30 - 8 = 22 > 10 available shards) createIndex(4, 1); - var result = fetchShardsCapacityIndicatorResult(internalCluster); + var result = fetchShardsCapacityIndicatorResult(); assertEquals(result.status(), HealthStatus.GREEN); assertEquals(result.symptom(), "The cluster has enough room to add new shards."); assertThat(result.diagnosisList(), empty()); @@ -64,7 +61,7 @@ public class ShardsCapacityHealthIndicatorServiceIT extends ESIntegTestCase { // index: 11 shards + 1 replica = 22 shards used (30 - 22 < 10 available shards) createIndex(10, 1); - var result = fetchShardsCapacityIndicatorResult(internalCluster); + var result = fetchShardsCapacityIndicatorResult(); assertEquals(result.status(), HealthStatus.YELLOW); assertEquals(result.symptom(), "Cluster is close to reaching the configured maximum number of shards for data nodes."); assertThat(result.diagnosisList(), hasSize(1)); @@ -75,7 +72,7 @@ public class ShardsCapacityHealthIndicatorServiceIT extends ESIntegTestCase { // index: 13 shards + 1 replica = 26 shards used (30 - 26 < 5 available shards) createIndex(13, 1); - var result = fetchShardsCapacityIndicatorResult(internalCluster); + var result = fetchShardsCapacityIndicatorResult(); assertEquals(result.status(), HealthStatus.RED); assertEquals(result.symptom(), "Cluster is close to reaching the configured maximum number of shards for data nodes."); assertThat(result.diagnosisList(), hasSize(1)); @@ -86,15 +83,15 @@ public class ShardsCapacityHealthIndicatorServiceIT extends ESIntegTestCase { createIndex(INDEX_NAME, indexSettings(shards, replicas).build()); } - private HealthIndicatorResult fetchShardsCapacityIndicatorResult(InternalTestCluster internalCluster) throws Exception { - ensureStableCluster(internalCluster.getNodeNames().length); - var healthNode = ESIntegTestCase.waitAndGetHealthNode(internalCluster); + private HealthIndicatorResult fetchShardsCapacityIndicatorResult() throws Exception { + ensureStableCluster(internalCluster().getNodeNames().length); + var healthNode = ESIntegTestCase.waitAndGetHealthNode(internalCluster()); assertNotNull(healthNode); - var randomNode = internalCluster.getRandomNodeName(); + var randomNode = internalCluster().getRandomNodeName(); waitForShardLimitsMetadata(randomNode); - var healthService = internalCluster.getInstance(HealthService.class, randomNode); + var healthService = internalCluster().getInstance(HealthService.class, randomNode); var healthIndicatorResults = getHealthServiceResults(healthService, randomNode); assertThat(healthIndicatorResults, hasSize(1)); return healthIndicatorResults.get(0); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestStatsNamesAndTypesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestStatsNamesAndTypesIT.java index 9284c8e2dfbc..d32803476ae7 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestStatsNamesAndTypesIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestStatsNamesAndTypesIT.java @@ -36,7 +36,7 @@ import java.util.function.Function; import static org.hamcrest.Matchers.equalTo; -@ESIntegTestCase.ClusterScope(numDataNodes = 0, numClientNodes = 0, scope = ESIntegTestCase.Scope.TEST) +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 1, numClientNodes = 0, supportsDedicatedMasters = false) public class IngestStatsNamesAndTypesIT extends ESIntegTestCase { @Override diff --git a/server/src/internalClusterTest/java/org/elasticsearch/rest/RestControllerIT.java b/server/src/internalClusterTest/java/org/elasticsearch/rest/RestControllerIT.java index 564d18ef4a61..36759db01aa1 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/rest/RestControllerIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/rest/RestControllerIT.java @@ -52,7 +52,7 @@ import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; -@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numClientNodes = 1, numDataNodes = 0) +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 1, numClientNodes = 0, supportsDedicatedMasters = false) public class RestControllerIT extends ESIntegTestCase { @Override protected boolean addMockHttpTransport() { diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/retriever/RetrieverTelemetryIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/retriever/RetrieverTelemetryIT.java index 40849bea5512..1762e4fe299c 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/retriever/RetrieverTelemetryIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/retriever/RetrieverTelemetryIT.java @@ -30,7 +30,6 @@ import java.util.List; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.equalTo; -@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) public class RetrieverTelemetryIT extends ESIntegTestCase { private static final String INDEX_NAME = "test_index"; diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/BlobStoreIncrementalityIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/BlobStoreIncrementalityIT.java index 616a4b5a772d..f80413741e2e 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/BlobStoreIncrementalityIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/BlobStoreIncrementalityIT.java @@ -173,6 +173,8 @@ public class BlobStoreIncrementalityIT extends AbstractSnapshotIntegTestCase { } public void testRecordCorrectSegmentCountsWithBackgroundMerges() throws Exception { + internalCluster().startMasterOnlyNode(); + internalCluster().ensureAtLeastNumDataNodes(2); final String repoName = "test-repo"; createRepository(repoName, "fs"); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/ConcurrentSnapshotsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/ConcurrentSnapshotsIT.java index 96f3c3b7b569..ae45491f6919 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/ConcurrentSnapshotsIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/ConcurrentSnapshotsIT.java @@ -1480,6 +1480,7 @@ public class ConcurrentSnapshotsIT extends AbstractSnapshotIntegTestCase { } public void testConcurrentRestoreDeleteAndClone() throws Exception { + internalCluster().startNode(); final String repository = "test-repo"; createRepository(logger, repository, "fs"); @@ -2137,7 +2138,7 @@ public class ConcurrentSnapshotsIT extends AbstractSnapshotIntegTestCase { } public void testDeleteIndexWithOutOfOrderFinalization() { - + internalCluster().startNode(); final var indexToDelete = "index-to-delete"; final var indexNames = List.of(indexToDelete, "index-0", "index-1", "index-2"); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java index 26818002e112..e0bfab595a31 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java @@ -685,6 +685,7 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest } public void testSnapshotWithDateMath() { + internalCluster().startMasterOnlyNode(); final String repo = "repo"; final String snapshotName = ""; @@ -712,6 +713,8 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest } public void testSnapshotTotalAndIncrementalSizes() throws Exception { + internalCluster().startMasterOnlyNode(); + internalCluster().startDataOnlyNode(); final String indexName = "test-blocks-1"; final String repositoryName = "repo-" + indexName; final String snapshot0 = "snapshot-0"; @@ -798,6 +801,8 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest } public void testDeduplicateIndexMetadata() throws Exception { + internalCluster().startMasterOnlyNode(); + internalCluster().startDataOnlyNode(); final String indexName = "test-blocks-1"; final String repositoryName = "repo-" + indexName; final String snapshot0 = "snapshot-0"; @@ -968,6 +973,8 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest } public void testRetentionLeasesClearedOnRestore() throws Exception { + internalCluster().startMasterOnlyNode(); + internalCluster().startDataOnlyNode(); final String repoName = "test-repo-retention-leases"; createRepository(repoName, "fs"); 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 63c7adc97dd7..d3f906eda9f3 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java @@ -580,7 +580,7 @@ public abstract class ESIntegTestCase extends ESTestCase { internalCluster().clearDisruptionScheme(); } try { - if (cluster() != null) { + if (cluster() != null && cluster().size() > 0) { if (currentClusterScope != Scope.TEST) { Metadata metadata = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().getMetadata(); 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 7494b3a8bc9c..b4f278a7fbc7 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java @@ -831,14 +831,11 @@ public final class InternalTestCluster extends TestCluster { public Client client() { /* Randomly return a client to one of the nodes in the cluster */ NodeAndClient c = getRandomNodeAndClient(); - ensureOpen(); if (c == null) { - synchronized (this) { - return getOrBuildRandomNode().client(); - } - } else { - return c.client(); + throw new AssertionError("Unable to get client, no node found"); } + ensureOpen(); + return c.client(); } /** diff --git a/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/action/TransportGetAutoscalingCapacityActionIT.java b/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/action/TransportGetAutoscalingCapacityActionIT.java index 990c4bf6f524..1c25b8338735 100644 --- a/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/action/TransportGetAutoscalingCapacityActionIT.java +++ b/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/action/TransportGetAutoscalingCapacityActionIT.java @@ -10,7 +10,6 @@ package org.elasticsearch.xpack.autoscaling.action; import org.apache.logging.log4j.Level; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.monitor.os.OsProbe; -import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.MockLog; import org.elasticsearch.test.junit.annotations.TestLogging; import org.elasticsearch.xpack.autoscaling.AutoscalingIntegTestCase; @@ -28,7 +27,6 @@ import static org.hamcrest.Matchers.greaterThan; value = "org.elasticsearch.xpack.autoscaling.action.TransportGetAutoscalingCapacityAction:debug", reason = "to ensure we log autoscaling capacity response on DEBUG level" ) -@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) public class TransportGetAutoscalingCapacityActionIT extends AutoscalingIntegTestCase { public void testCurrentCapacity() throws Exception { diff --git a/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistryRolloverIT.java b/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistryRolloverIT.java index c377578faf81..04f9c540f949 100644 --- a/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistryRolloverIT.java +++ b/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistryRolloverIT.java @@ -37,7 +37,6 @@ import static org.hamcrest.Matchers.endsWith; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; -@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, numClientNodes = 0) public class IndexTemplateRegistryRolloverIT extends ESIntegTestCase { private ClusterService clusterService; diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/license/ClusterStateLicenseServiceClusterTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/license/ClusterStateLicenseServiceClusterTests.java index 00bf1c7fe174..ef36d8a93ee5 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/license/ClusterStateLicenseServiceClusterTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/license/ClusterStateLicenseServiceClusterTests.java @@ -33,8 +33,6 @@ public class ClusterStateLicenseServiceClusterTests extends AbstractLicensesInte } public void testClusterRestartWithLicense() throws Exception { - wipeAllLicenses(); - int numNodes = randomIntBetween(1, 5); logger.info("--> starting {} node(s)", numNodes); internalCluster().startNodes(numNodes); @@ -79,7 +77,6 @@ public class ClusterStateLicenseServiceClusterTests extends AbstractLicensesInte } public void testClusterRestartWhileEnabled() throws Exception { - wipeAllLicenses(); internalCluster().startNode(); ensureGreen(); assertLicenseActive(true); @@ -91,7 +88,6 @@ public class ClusterStateLicenseServiceClusterTests extends AbstractLicensesInte } public void testClusterRestartWhileExpired() throws Exception { - wipeAllLicenses(); internalCluster().startNode(); ensureGreen(); assertLicenseActive(true); @@ -106,7 +102,6 @@ public class ClusterStateLicenseServiceClusterTests extends AbstractLicensesInte public void testClusterRestartWithOldSignature() throws Exception { assumeFalse("Can't run in a FIPS JVM. We can't generate old licenses since PBEWithSHA1AndDESede is not available", inFipsJvm()); - wipeAllLicenses(); internalCluster().startNode(); ensureGreen(); assertLicenseActive(true); diff --git a/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlBlockingIntegTestCase.java b/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlBlockingIntegTestCase.java index 414705aff0b7..599e4906bc35 100644 --- a/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlBlockingIntegTestCase.java +++ b/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlBlockingIntegTestCase.java @@ -27,7 +27,6 @@ import org.elasticsearch.search.internal.ReaderContext; import org.elasticsearch.tasks.Task; import org.elasticsearch.tasks.TaskId; import org.elasticsearch.tasks.TaskInfo; -import org.elasticsearch.test.ESIntegTestCase; import java.io.IOException; import java.nio.file.Path; @@ -40,7 +39,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; -import static org.elasticsearch.test.ESIntegTestCase.Scope.SUITE; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.hasSize; @@ -48,7 +46,6 @@ import static org.hamcrest.Matchers.hasSize; /** * IT tests that can block EQL execution at different places */ -@ESIntegTestCase.ClusterScope(scope = SUITE, numDataNodes = 0, numClientNodes = 0, maxNumDataNodes = 0) public abstract class AbstractEqlBlockingIntegTestCase extends AbstractEqlIntegTestCase { protected List initBlockFactory(boolean searchBlock, boolean fieldCapsBlock) { diff --git a/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlIntegTestCase.java b/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlIntegTestCase.java index 329d0e3d0a04..727a09d8d3ed 100644 --- a/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlIntegTestCase.java +++ b/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlIntegTestCase.java @@ -16,9 +16,6 @@ import org.elasticsearch.xpack.core.XPackSettings; import java.util.Collection; import java.util.Collections; -import static org.elasticsearch.test.ESIntegTestCase.Scope.SUITE; - -@ESIntegTestCase.ClusterScope(scope = SUITE, numDataNodes = 0, numClientNodes = 0, maxNumDataNodes = 0) public abstract class AbstractEqlIntegTestCase extends ESIntegTestCase { @Override diff --git a/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AsyncEqlSearchActionIT.java b/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AsyncEqlSearchActionIT.java index fc8fd11e3527..dca988a55ccd 100644 --- a/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AsyncEqlSearchActionIT.java +++ b/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AsyncEqlSearchActionIT.java @@ -29,6 +29,7 @@ import org.elasticsearch.script.MockScriptPlugin; import org.elasticsearch.search.SearchModule; import org.elasticsearch.tasks.Task; import org.elasticsearch.tasks.TaskId; +import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.xpack.core.XPackPlugin; import org.elasticsearch.xpack.core.async.AsyncExecutionId; import org.elasticsearch.xpack.core.async.DeleteAsyncResultRequest; @@ -64,6 +65,7 @@ import static org.hamcrest.Matchers.lessThan; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 0) public class AsyncEqlSearchActionIT extends AbstractEqlBlockingIntegTestCase { private final ExecutorService executorService = Executors.newFixedThreadPool(1); @@ -81,6 +83,7 @@ public class AsyncEqlSearchActionIT extends AbstractEqlBlockingIntegTestCase { } private void prepareIndex() throws Exception { + internalCluster().startNode(); assertAcked( indicesAdmin().prepareCreate("test") .setMapping("val", "type=integer", "event_type", "type=keyword", "@timestamp", "type=date", "i", "type=integer") @@ -108,6 +111,7 @@ public class AsyncEqlSearchActionIT extends AbstractEqlBlockingIntegTestCase { } public void testBasicAsyncExecution() throws Exception { + internalCluster().startNode(); prepareIndex(); boolean success = randomBoolean(); @@ -160,6 +164,7 @@ public class AsyncEqlSearchActionIT extends AbstractEqlBlockingIntegTestCase { } public void testGoingAsync() throws Exception { + internalCluster().startNode(); prepareIndex(); boolean success = randomBoolean(); @@ -218,6 +223,7 @@ public class AsyncEqlSearchActionIT extends AbstractEqlBlockingIntegTestCase { } public void testAsyncCancellation() throws Exception { + internalCluster().startNode(); prepareIndex(); boolean success = randomBoolean(); @@ -261,6 +267,7 @@ public class AsyncEqlSearchActionIT extends AbstractEqlBlockingIntegTestCase { } public void testFinishingBeforeTimeout() throws Exception { + internalCluster().startNode(); prepareIndex(); boolean success = randomBoolean(); diff --git a/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/PartialSearchResultsIT.java b/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/PartialSearchResultsIT.java index 712695fa1b9c..d9b2d6f6e646 100644 --- a/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/PartialSearchResultsIT.java +++ b/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/PartialSearchResultsIT.java @@ -17,6 +17,7 @@ import org.elasticsearch.common.util.CollectionUtils; import org.elasticsearch.core.TimeValue; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.search.SearchService; +import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.xpack.core.async.GetAsyncResultRequest; import org.elasticsearch.xpack.eql.plugin.EqlAsyncGetResultAction; @@ -32,6 +33,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 0) public class PartialSearchResultsIT extends AbstractEqlIntegTestCase { @Override diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverTelemetryTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverTelemetryTests.java index 237ee1cde1ef..07474169fbe9 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverTelemetryTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverTelemetryTests.java @@ -34,7 +34,6 @@ import java.util.List; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.equalTo; -@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) public class TextSimilarityRankRetrieverTelemetryTests extends ESIntegTestCase { private static final String INDEX_NAME = "test_index"; diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/license/MachineLearningLicensingIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/license/MachineLearningLicensingIT.java index 479fb20650b1..b9930a4c5ed2 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/license/MachineLearningLicensingIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/license/MachineLearningLicensingIT.java @@ -26,6 +26,7 @@ import org.elasticsearch.persistent.PersistentTasksCustomMetadata; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; import org.elasticsearch.search.aggregations.metrics.AvgAggregationBuilder; +import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.xpack.core.XPackField; import org.elasticsearch.xpack.core.ml.MachineLearningField; @@ -74,6 +75,7 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 1, numClientNodes = 0, supportsDedicatedMasters = false) public class MachineLearningLicensingIT extends BaseMlIntegTestCase { public static final Set RELATED_TASKS = Set.of(MlTasks.DATAFEED_TASK_NAME, MlTasks.JOB_TASK_NAME); diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java index ee5814a3be57..b9f674a6ef62 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java @@ -22,6 +22,7 @@ import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.AggregatorFactories; import org.elasticsearch.search.aggregations.bucket.histogram.HistogramAggregationBuilder; import org.elasticsearch.search.aggregations.metrics.MaxAggregationBuilder; +import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.xpack.core.ml.MlTasks; import org.elasticsearch.xpack.core.ml.action.CloseJobAction; @@ -63,6 +64,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasEntry; import static org.hamcrest.Matchers.notNullValue; +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) public class BasicDistributedJobsIT extends BaseMlIntegTestCase { public void testFailOverBasics() throws Exception { diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/CategorizeTextAggregationIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/CategorizeTextAggregationIT.java index d4b29e3c9253..205d9f6032ac 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/CategorizeTextAggregationIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/CategorizeTextAggregationIT.java @@ -15,6 +15,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.metrics.Max; import org.elasticsearch.search.aggregations.metrics.Min; +import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.xpack.ml.aggs.categorization.CategorizeTextAggregationBuilder; import org.elasticsearch.xpack.ml.aggs.categorization.InternalCategorizationAggregation; import org.elasticsearch.xpack.ml.support.BaseMlIntegTestCase; @@ -27,13 +28,13 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.notANumber; +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 3) public class CategorizeTextAggregationIT extends BaseMlIntegTestCase { private static final String DATA_INDEX = "categorization-agg-data"; @Before public void setupCluster() { - internalCluster().ensureAtLeastNumDataNodes(3); ensureStableCluster(); createSourceData(); } diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/CategorizeTextDistributedIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/CategorizeTextDistributedIT.java index bed5b1cb1bbf..5cc420a37443 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/CategorizeTextDistributedIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/CategorizeTextDistributedIT.java @@ -15,6 +15,7 @@ import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.xpack.ml.aggs.categorization.CategorizeTextAggregationBuilder; import org.elasticsearch.xpack.ml.aggs.categorization.InternalCategorizationAggregation; import org.elasticsearch.xpack.ml.support.BaseMlIntegTestCase; @@ -32,6 +33,7 @@ import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) public class CategorizeTextDistributedIT extends BaseMlIntegTestCase { /** diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/EstablishedMemUsageIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/EstablishedMemUsageIT.java index 96b4aea1a55b..75b4abcf4696 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/EstablishedMemUsageIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/EstablishedMemUsageIT.java @@ -14,6 +14,7 @@ import org.elasticsearch.cluster.service.MasterService; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.indices.TestIndexNameExpressionResolver; +import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.xpack.core.ClientHelper; import org.elasticsearch.xpack.core.ml.action.PutJobAction; @@ -36,6 +37,7 @@ import java.util.concurrent.atomic.AtomicReference; import static org.hamcrest.CoreMatchers.equalTo; +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 1, numClientNodes = 0, supportsDedicatedMasters = false) public class EstablishedMemUsageIT extends BaseMlIntegTestCase { private final long bucketSpan = AnalysisConfig.Builder.DEFAULT_BUCKET_SPAN.getMillis(); diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/JobStorageDeletionTaskIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/JobStorageDeletionTaskIT.java index f2b768517b38..e85e680e494c 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/JobStorageDeletionTaskIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/JobStorageDeletionTaskIT.java @@ -20,6 +20,7 @@ import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.indices.TestIndexNameExpressionResolver; import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.xpack.core.ClientHelper; import org.elasticsearch.xpack.core.action.util.QueryPage; @@ -51,6 +52,7 @@ import static org.hamcrest.Matchers.nullValue; /** * Test that ML does not touch unnecessary indices when removing job index aliases */ +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 1, numClientNodes = 0, supportsDedicatedMasters = false) public class JobStorageDeletionTaskIT extends BaseMlIntegTestCase { private static final long bucketSpan = AnalysisConfig.Builder.DEFAULT_BUCKET_SPAN.getMillis(); diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/JobsAndModelsIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/JobsAndModelsIT.java index 5be72ff9b727..a1b001cb168e 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/JobsAndModelsIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/JobsAndModelsIT.java @@ -13,6 +13,7 @@ import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.cluster.node.DiscoveryNodeRole; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.unit.ByteSizeValue; +import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xcontent.json.JsonXContent; import org.elasticsearch.xpack.core.ml.MlTasks; @@ -55,6 +56,7 @@ import static org.hamcrest.Matchers.nullValue; * Tests that involve interactions of ML jobs that are persistent tasks * and trained models. */ +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) public class JobsAndModelsIT extends BaseMlIntegTestCase { @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/103588") diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/LearningToRankExplainIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/LearningToRankExplainIT.java index d05f4a37d550..272e2104033f 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/LearningToRankExplainIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/LearningToRankExplainIT.java @@ -17,6 +17,7 @@ import org.elasticsearch.core.Predicates; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.xcontent.XContentParser; import org.elasticsearch.xcontent.json.JsonXContent; import org.elasticsearch.xpack.core.ml.action.PutTrainedModelAction; @@ -42,6 +43,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) public class LearningToRankExplainIT extends BaseMlIntegTestCase { private static final String LTR_SEARCH_INDEX = "ltr-search-index"; diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/MlDistributedFailureIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/MlDistributedFailureIT.java index b9a3c7d41412..1ea507587e87 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/MlDistributedFailureIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/MlDistributedFailureIT.java @@ -29,6 +29,8 @@ import org.elasticsearch.persistent.PersistentTaskResponse; import org.elasticsearch.persistent.PersistentTasksClusterService; import org.elasticsearch.persistent.PersistentTasksCustomMetadata; import org.elasticsearch.persistent.UpdatePersistentTaskStatusAction; +import org.elasticsearch.test.ESIntegTestCase; +import org.elasticsearch.test.junit.annotations.TestLogging; import org.elasticsearch.xcontent.ToXContent; import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xcontent.XContentParser; @@ -64,8 +66,6 @@ import org.elasticsearch.xpack.ml.MachineLearning; import org.elasticsearch.xpack.ml.job.persistence.JobResultsPersister; import org.elasticsearch.xpack.ml.job.process.autodetect.BlackHoleAutodetectProcess; import org.elasticsearch.xpack.ml.support.BaseMlIntegTestCase; -import org.junit.After; -import org.junit.Before; import java.io.IOException; import java.util.Collections; @@ -91,6 +91,8 @@ import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; +@TestLogging(value = "org.elasticsearch.xpack.ml.utils.persistence:TRACE", reason = "") +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) public class MlDistributedFailureIT extends BaseMlIntegTestCase { @Override @@ -113,16 +115,6 @@ public class MlDistributedFailureIT extends BaseMlIntegTestCase { }); } - @Before - public void setLogging() { - updateClusterSettings(Settings.builder().put("logger.org.elasticsearch.xpack.ml.utils.persistence", "TRACE")); - } - - @After - public void unsetLogging() { - updateClusterSettings(Settings.builder().putNull("logger.org.elasticsearch.xpack.ml.utils.persistence")); - } - public void testLoseDedicatedMasterNode() throws Exception { internalCluster().ensureAtMostNumDataNodes(0); logger.info("Starting dedicated master node..."); diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/MlNodeShutdownIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/MlNodeShutdownIT.java index dd5ae88d49bf..169186ac99b1 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/MlNodeShutdownIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/MlNodeShutdownIT.java @@ -12,6 +12,7 @@ import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.core.TimeValue; +import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.xpack.core.action.util.QueryPage; import org.elasticsearch.xpack.core.ml.action.CloseJobAction; import org.elasticsearch.xpack.core.ml.action.GetJobsStatsAction; @@ -33,6 +34,7 @@ import static org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata.Type import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) public class MlNodeShutdownIT extends BaseMlIntegTestCase { public void testJobsVacateShuttingDownNode() throws Exception { diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/NetworkDisruptionIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/NetworkDisruptionIT.java index d77f9e8b117a..f4ab16d69171 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/NetworkDisruptionIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/NetworkDisruptionIT.java @@ -12,6 +12,7 @@ import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.util.CollectionUtils; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.disruption.NetworkDisruption; import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.xpack.core.ml.action.CloseJobAction; @@ -30,6 +31,7 @@ import java.util.Set; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) public class NetworkDisruptionIT extends BaseMlIntegTestCase { @Override diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/TooManyJobsIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/TooManyJobsIT.java index c3132898f1dd..5cf23dc6b36c 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/TooManyJobsIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/TooManyJobsIT.java @@ -15,6 +15,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.core.TimeValue; import org.elasticsearch.persistent.PersistentTasksCustomMetadata; +import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.ml.MachineLearningField; import org.elasticsearch.xpack.core.ml.MlTasks; @@ -31,6 +32,7 @@ import org.elasticsearch.xpack.ml.utils.NativeMemoryCalculator; import java.util.List; +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) public class TooManyJobsIT extends BaseMlIntegTestCase { public void testCloseFailedJob() throws Exception { 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 372b07ed8c95..4473919130c8 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 @@ -122,7 +122,6 @@ import static org.mockito.Mockito.when; * Note for other type of integration tests you should use the external test cluster created by the Gradle integTest task. * For example tests extending this base class test with the non native autodetect process. */ -@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, numClientNodes = 0, supportsDedicatedMasters = false) public abstract class BaseMlIntegTestCase extends ESIntegTestCase { // The ML jobs can trigger many tasks that are not easily tracked. For this reason, here we list @@ -171,7 +170,9 @@ public abstract class BaseMlIntegTestCase extends ESIntegTestCase { @Before public void ensureTemplatesArePresent() throws Exception { - awaitClusterState(logger, MachineLearning::criticalTemplatesInstalled); + if (cluster().size() > 0) { + awaitClusterState(logger, MachineLearning::criticalTemplatesInstalled); + } } protected Job.Builder createJob(String id) { diff --git a/x-pack/plugin/rank-rrf/src/internalClusterTest/java/org/elasticsearch/xpack/rank/rrf/RRFRetrieverTelemetryIT.java b/x-pack/plugin/rank-rrf/src/internalClusterTest/java/org/elasticsearch/xpack/rank/rrf/RRFRetrieverTelemetryIT.java index 9bc1cd80ea38..556f8b87923d 100644 --- a/x-pack/plugin/rank-rrf/src/internalClusterTest/java/org/elasticsearch/xpack/rank/rrf/RRFRetrieverTelemetryIT.java +++ b/x-pack/plugin/rank-rrf/src/internalClusterTest/java/org/elasticsearch/xpack/rank/rrf/RRFRetrieverTelemetryIT.java @@ -36,7 +36,7 @@ import java.util.List; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.equalTo; -@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 1, numClientNodes = 0, supportsDedicatedMasters = false) public class RRFRetrieverTelemetryIT extends ESIntegTestCase { private static final String INDEX_NAME = "test_index"; diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/profile/ApiKeyOwnerProfileIntegTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/profile/ApiKeyOwnerProfileIntegTests.java index 60208bfea906..d29d7fdf2123 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/profile/ApiKeyOwnerProfileIntegTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/profile/ApiKeyOwnerProfileIntegTests.java @@ -36,7 +36,7 @@ import static org.hamcrest.Matchers.iterableWithSize; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; -@ESIntegTestCase.ClusterScope(numDataNodes = 0, numClientNodes = 0, scope = ESIntegTestCase.Scope.TEST) +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 1, numClientNodes = 0, supportsDedicatedMasters = false) public class ApiKeyOwnerProfileIntegTests extends SecurityIntegTestCase { public static final SecureString FILE_USER_TEST_PASSWORD = new SecureString("file-user-test-password".toCharArray()); diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/support/CleanupRoleMappingDuplicatesMigrationIT.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/support/CleanupRoleMappingDuplicatesMigrationIT.java index 6454ad5db69c..9f67f3b90006 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/support/CleanupRoleMappingDuplicatesMigrationIT.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/support/CleanupRoleMappingDuplicatesMigrationIT.java @@ -125,6 +125,7 @@ public class CleanupRoleMappingDuplicatesMigrationIT extends SecurityIntegTestCa public void testMigrationSuccessful() throws Exception { internalCluster().setBootstrapMasterNodeIndex(0); + internalCluster().startNode(); ensureGreen(); final String masterNode = internalCluster().getMasterName(); @@ -158,6 +159,7 @@ public class CleanupRoleMappingDuplicatesMigrationIT extends SecurityIntegTestCa public void testMigrationSuccessfulNoOverlap() throws Exception { internalCluster().setBootstrapMasterNodeIndex(0); + internalCluster().startNode(); ensureGreen(); final String masterNode = internalCluster().getMasterName(); @@ -191,6 +193,7 @@ public class CleanupRoleMappingDuplicatesMigrationIT extends SecurityIntegTestCa public void testMigrationSuccessfulNoNative() throws Exception { internalCluster().setBootstrapMasterNodeIndex(0); + internalCluster().startNode(); ensureGreen(); final String masterNode = internalCluster().getMasterName(); @@ -221,6 +224,7 @@ public class CleanupRoleMappingDuplicatesMigrationIT extends SecurityIntegTestCa public void testMigrationFallbackNamePreCondition() throws Exception { internalCluster().setBootstrapMasterNodeIndex(0); + internalCluster().startNode(); ensureGreen(); final String masterNode = internalCluster().getMasterName(); // Wait for file watcher to start @@ -256,6 +260,7 @@ public class CleanupRoleMappingDuplicatesMigrationIT extends SecurityIntegTestCa public void testSkipMigrationNoFileBasedMappings() throws Exception { internalCluster().setBootstrapMasterNodeIndex(0); + internalCluster().startNode(); ensureGreen(); // Create a native role mapping to create security index and trigger migration (skipped initially) createNativeRoleMapping("everyone_kibana_alone"); @@ -275,6 +280,7 @@ public class CleanupRoleMappingDuplicatesMigrationIT extends SecurityIntegTestCa public void testSkipMigrationEmptyFileBasedMappings() throws Exception { internalCluster().setBootstrapMasterNodeIndex(0); + internalCluster().startNode(); ensureGreen(); final String masterNode = internalCluster().getMasterName(); @@ -304,6 +310,7 @@ public class CleanupRoleMappingDuplicatesMigrationIT extends SecurityIntegTestCa public void testNewIndexSkipMigration() { internalCluster().setBootstrapMasterNodeIndex(0); + internalCluster().startNode(); final String masterNode = internalCluster().getMasterName(); ensureGreen(); deleteSecurityIndex(); // hack to force a new security index to be created diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/transport/filter/IpFilteringIntegrationTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/transport/filter/IpFilteringIntegrationTests.java index 1f052da89d24..881acb6158ff 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/transport/filter/IpFilteringIntegrationTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/transport/filter/IpFilteringIntegrationTests.java @@ -70,6 +70,7 @@ public class IpFilteringIntegrationTests extends SecurityIntegTestCase { } public void testThatIpFilteringIsIntegratedIntoNettyPipelineViaHttp() throws Exception { + internalCluster().startNode(); TransportAddress transportAddress = randomFrom( internalCluster().getDataNodeInstance(HttpServerTransport.class).boundAddress().boundAddresses() ); @@ -80,6 +81,7 @@ public class IpFilteringIntegrationTests extends SecurityIntegTestCase { } public void testThatIpFilteringIsAppliedForProfile() throws Exception { + internalCluster().startNode(); try (Socket socket = new Socket()) { trySocketConnection(socket, getProfileAddress("client")); assertThat(socket.isClosed(), is(true)); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/test/SecurityIntegTestCase.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/test/SecurityIntegTestCase.java index 3e3ca3dfdc9b..d59dc56d1568 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/test/SecurityIntegTestCase.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/test/SecurityIntegTestCase.java @@ -179,7 +179,9 @@ public abstract class SecurityIntegTestCase extends ESIntegTestCase { @Before // before methods from the superclass are run before this, which means that the current cluster is ready to go public void assertXPackIsInstalled() { - doAssertXPackIsInstalled(); + if (cluster().size() > 0) { + doAssertXPackIsInstalled(); + } } protected void doAssertXPackIsInstalled() { diff --git a/x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/AbstractSqlBlockingIntegTestCase.java b/x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/AbstractSqlBlockingIntegTestCase.java index 7ad54901e2d0..dee45caa23bf 100644 --- a/x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/AbstractSqlBlockingIntegTestCase.java +++ b/x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/AbstractSqlBlockingIntegTestCase.java @@ -42,7 +42,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; -import static org.elasticsearch.test.ESIntegTestCase.Scope.SUITE; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.hasSize; @@ -50,7 +49,7 @@ import static org.hamcrest.Matchers.hasSize; /** * IT tests that can block SQL execution at different places */ -@ESIntegTestCase.ClusterScope(scope = SUITE, numDataNodes = 0, numClientNodes = 0, maxNumDataNodes = 0) +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 1, numClientNodes = 0, supportsDedicatedMasters = false) public abstract class AbstractSqlBlockingIntegTestCase extends ESIntegTestCase { @Override diff --git a/x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/SqlSearchPageTimeoutIT.java b/x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/SqlSearchPageTimeoutIT.java index 37b4ca3268f1..4d30ed545820 100644 --- a/x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/SqlSearchPageTimeoutIT.java +++ b/x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/SqlSearchPageTimeoutIT.java @@ -14,6 +14,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.TimeValue; import org.elasticsearch.search.SearchContextMissingException; import org.elasticsearch.search.SearchService; +import org.elasticsearch.test.ESIntegTestCase; import java.util.Arrays; @@ -21,6 +22,7 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcke import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.instanceOf; +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 0) public class SqlSearchPageTimeoutIT extends AbstractSqlIntegTestCase { @Override @@ -40,6 +42,7 @@ public class SqlSearchPageTimeoutIT extends AbstractSqlIntegTestCase { } public void testSearchContextIsCleanedUpAfterPageTimeout(String query) throws Exception { + internalCluster().startNode(); setupTestIndex(); SqlQueryResponse response = new SqlQueryRequestBuilder(client()).query(query) diff --git a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/action/AbstractSqlIntegTestCase.java b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/action/AbstractSqlIntegTestCase.java index 4f7646127cf3..2cb7cb9aee18 100644 --- a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/action/AbstractSqlIntegTestCase.java +++ b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/action/AbstractSqlIntegTestCase.java @@ -15,9 +15,6 @@ import org.elasticsearch.xpack.core.XPackSettings; import java.util.Collection; import java.util.Collections; -import static org.elasticsearch.test.ESIntegTestCase.Scope.SUITE; - -@ESIntegTestCase.ClusterScope(scope = SUITE, numDataNodes = 0, numClientNodes = 0, maxNumDataNodes = 0) public abstract class AbstractSqlIntegTestCase extends ESIntegTestCase { @Override