|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the "Elastic License |
| 4 | + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side |
| 5 | + * Public License v 1"; you may not use this file except in compliance with, at |
| 6 | + * your election, the "Elastic License 2.0", the "GNU Affero General Public |
| 7 | + * License v3.0 only", or the "Server Side Public License, v 1". |
| 8 | + */ |
| 9 | + |
| 10 | +package org.elasticsearch.index.engine; |
| 11 | + |
| 12 | +import org.elasticsearch.action.index.IndexRequestBuilder; |
| 13 | +import org.elasticsearch.cluster.DiskUsageIntegTestCase; |
| 14 | +import org.elasticsearch.cluster.metadata.IndexMetadata; |
| 15 | +import org.elasticsearch.common.settings.Settings; |
| 16 | +import org.elasticsearch.test.ESIntegTestCase; |
| 17 | + |
| 18 | +import java.util.Locale; |
| 19 | +import java.util.stream.IntStream; |
| 20 | + |
| 21 | +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) |
| 22 | +public class MergeWithLowDiskSpaceIT extends DiskUsageIntegTestCase { |
| 23 | + |
| 24 | + @Override |
| 25 | + protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) { |
| 26 | + return Settings.builder() |
| 27 | + .put(super.nodeSettings(nodeOrdinal, otherSettings)) |
| 28 | + // the default of "5s" slows down testing |
| 29 | + .put(ThreadPoolMergeExecutorService.INDICES_MERGE_DISK_CHECK_INTERVAL_SETTING.getKey(), "100ms") |
| 30 | + .put(ThreadPoolMergeScheduler.USE_THREAD_POOL_MERGE_SCHEDULER_SETTING.getKey(), true) |
| 31 | + .build(); |
| 32 | + } |
| 33 | + |
| 34 | + public void testShardCloseWhenDiskSpaceInsufficient() { |
| 35 | + internalCluster().startNode(); |
| 36 | + ensureStableCluster(1); |
| 37 | + final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); |
| 38 | + createIndex( |
| 39 | + indexName, |
| 40 | + Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0).put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).build() |
| 41 | + ); |
| 42 | + indexRandom( |
| 43 | + true, |
| 44 | + IntStream.range(1, 100) |
| 45 | + .mapToObj(i -> prepareIndex(indexName).setSource("field", randomAlphaOfLength(50))) |
| 46 | + .toArray(IndexRequestBuilder[]::new) |
| 47 | + ); |
| 48 | + } |
| 49 | +} |
0 commit comments