Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
/**
* 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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tests depend on there being exactly one node in the cluster, which I solved like this.

public class IngestFailureStoreMetricsIT extends ESIntegTestCase {

private static final List<String> METRICS = List.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tests didn't actually need any specific cluster configuration.

public abstract class AbstractSnapshotRestTestCase extends HttpSmokeTestCase {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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;
Expand All @@ -27,6 +28,7 @@
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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;
Expand All @@ -27,6 +28,7 @@
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
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
Expand Down Expand Up @@ -104,7 +103,6 @@ public void testSystemIndexIsAutoCreatedViaConcreteName() {
*/
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");
Expand Down Expand Up @@ -132,7 +130,6 @@ public void testNonPrimarySystemIndexIsAutoCreatedViaConcreteName() throws Excep
*/
public void testNonPrimarySystemIndexCreationThrowsError() {
final String nonPrimarySystemIndex = INDEX_NAME + "-2";
internalCluster().startNodes(1);

// Create the system index
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> createIndex(nonPrimarySystemIndex));
Expand Down Expand Up @@ -269,8 +266,6 @@ public void testCreateSystemAliasViaComposableTemplateWithAllowsTemplates() thro
}

private void doCreateTest(Runnable runnable, String concreteIndex) {
internalCluster().startNodes(1);

// Trigger the creation of the system index
runnable.run();
ensureGreen(INDEX_NAME);
Expand All @@ -293,8 +288,6 @@ private void doCreateTest(Runnable runnable, String concreteIndex) {
}

public void testConcurrentAutoCreates() throws InterruptedException {
internalCluster().startNodes(3);

final Client client = client();
final int count = randomIntBetween(5, 30);
final CountDownLatch latch = new CountDownLatch(count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void testBulkProcessorAutoCreateRestrictions() {
}

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"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ public void testAwarenessZonesIncrementalNodes() {
}

public void testForceAwarenessSettingValidation() {
internalCluster().startNode();
final String prefix = AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP_SETTING.getKey();

final IllegalArgumentException illegalArgumentException = expectThrows(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ public void testDisablingAllocationFiltering() {
}

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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
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;

Expand All @@ -27,16 +26,14 @@
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));
}

Expand All @@ -53,7 +50,7 @@ public void testGreen() throws Exception {
// 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());
Expand All @@ -64,7 +61,7 @@ public void testYellow() throws Exception {
// 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));
Expand All @@ -75,7 +72,7 @@ public void testRed() throws Exception {
// 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));
Expand All @@ -86,15 +83,15 @@ private void createIndex(int shards, int replicas) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ public void testForceMergeCausesFullSnapshot() throws Exception {
}

public void testRecordCorrectSegmentCountsWithBackgroundMerges() throws Exception {
internalCluster().startMasterOnlyNode();
internalCluster().ensureAtLeastNumDataNodes(2);
final String repoName = "test-repo";
createRepository(repoName, "fs");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,7 @@ public void testStartWithSuccessfulShardSnapshotPendingFinalization() throws Exc
}

public void testConcurrentRestoreDeleteAndClone() throws Exception {
internalCluster().startNode();
final String repository = "test-repo";
createRepository(logger, repository, "fs");

Expand Down Expand Up @@ -2137,7 +2138,7 @@ public void testQueuedSnapshotAfterPartialWithIndexRecreate() throws Exception {
}

public void testDeleteIndexWithOutOfOrderFinalization() {

internalCluster().startNode();
final var indexToDelete = "index-to-delete";
final var indexNames = List.of(indexToDelete, "index-0", "index-1", "index-2");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ public void testRestoreShrinkIndex() throws Exception {
}

public void testSnapshotWithDateMath() {
internalCluster().startMasterOnlyNode();
final String repo = "repo";

final String snapshotName = "<snapshot-{now/d}>";
Expand Down Expand Up @@ -712,6 +713,8 @@ public void testSnapshotWithDateMath() {
}

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";
Expand Down Expand Up @@ -798,6 +801,8 @@ public void testSnapshotTotalAndIncrementalSizes() throws Exception {
}

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";
Expand Down Expand Up @@ -968,6 +973,8 @@ public void testDataNodeRestartAfterShardSnapshotFailure() throws Exception {
}

public void testRetentionLeasesClearedOnRestore() throws Exception {
internalCluster().startMasterOnlyNode();
internalCluster().startDataOnlyNode();
final String repoName = "test-repo-retention-leases";
createRepository(repoName, "fs");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ private void afterInternal(boolean afterClass) throws Exception {
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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -831,14 +831,11 @@ private static String getRoleSuffix(Settings settings) {
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();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
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;
Expand All @@ -28,7 +27,6 @@
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ private Settings.Builder nodeSettingsBuilder(int nodeOrdinal, Settings otherSett
}

public void testClusterRestartWithLicense() throws Exception {
wipeAllLicenses();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wiping the licenses before the test starts doesn't make sense if we start with an empty cluster (i.e. no nodes).


int numNodes = randomIntBetween(1, 5);
logger.info("--> starting {} node(s)", numNodes);
internalCluster().startNodes(numNodes);
Expand Down Expand Up @@ -79,7 +77,6 @@ public void testClusterRestartWithLicense() throws Exception {
}

public void testClusterRestartWhileEnabled() throws Exception {
wipeAllLicenses();
internalCluster().startNode();
ensureGreen();
assertLicenseActive(true);
Expand All @@ -91,7 +88,6 @@ public void testClusterRestartWhileEnabled() throws Exception {
}

public void testClusterRestartWhileExpired() throws Exception {
wipeAllLicenses();
internalCluster().startNode();
ensureGreen();
assertLicenseActive(true);
Expand All @@ -106,7 +102,6 @@ public void testClusterRestartWhileExpired() throws Exception {

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
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;
Expand All @@ -40,15 +39,13 @@
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;

/**
* 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<SearchBlockPlugin> initBlockFactory(boolean searchBlock, boolean fieldCapsBlock) {
Expand Down
Loading