From c26d2b5fa563036df8095116dc52679715e1f77b Mon Sep 17 00:00:00 2001 From: Dan Hermann Date: Thu, 9 Jul 2020 13:11:45 -0500 Subject: [PATCH] Data stream support for indices shard stores API --- .../test/indices.shard_stores/10_basic.yml | 56 +++++++++++++++++++ .../elasticsearch/indices/DataStreamIT.java | 2 + .../shards/IndicesShardStoresRequest.java | 5 ++ 3 files changed, 63 insertions(+) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.shard_stores/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.shard_stores/10_basic.yml index db90bf29624..4a1cbbe462c 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.shard_stores/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.shard_stores/10_basic.yml @@ -80,3 +80,59 @@ - match: { indices.index2.shards.0.stores.0.allocation: "primary" } - match: { indices.index2.shards.1.stores.0.allocation: "primary" } +--- +"Data streams test": + - skip: + version: " - 7.99.99" + reason: "change to 7.8.99 after backport" + features: allowed_warnings + + - do: + allowed_warnings: + - "index template [my-template1] has index patterns [simple-data-stream1] matching patterns from existing older templates [global] with patterns (global => [*]); this template [my-template1] will take precedence during new index creation" + indices.put_index_template: + name: my-template1 + body: + index_patterns: [simple-data-stream1] + template: + mappings: + properties: + '@timestamp': + type: date + settings: + number_of_shards: "1" + number_of_replicas: "0" + data_stream: + timestamp_field: '@timestamp' + + - do: + indices.create_data_stream: + name: simple-data-stream1 + - is_true: acknowledged + + # rollover data stream to create new backing index + - do: + indices.rollover: + alias: "simple-data-stream1" + + - match: { old_index: .ds-simple-data-stream1-000001 } + - match: { new_index: .ds-simple-data-stream1-000002 } + - match: { rolled_over: true } + - match: { dry_run: false } + + - do: + cluster.health: + wait_for_status: green + + - do: + indices.shard_stores: + index: simple-data-stream1 + status: "green" + + - match: { indices.\.ds-simple-data-stream1-000001.shards.0.stores.0.allocation: "primary" } + - match: { indices.\.ds-simple-data-stream1-000002.shards.0.stores.0.allocation: "primary" } + + - do: + indices.delete_data_stream: + name: simple-data-stream1 + - is_true: acknowledged diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/DataStreamIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/DataStreamIT.java index 7e7f88efbff..a2e8a93aa32 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/DataStreamIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/DataStreamIT.java @@ -421,6 +421,7 @@ public class DataStreamIT extends ESIntegTestCase { verifyResolvability(dataStreamName, client().admin().indices().prepareGetIndex().addIndices(dataStreamName), false); verifyResolvability(dataStreamName, client().admin().cluster().prepareSearchShards(dataStreamName), false); verifyResolvability(dataStreamName, client().admin().indices().prepareOpen(dataStreamName), false); + verifyResolvability(dataStreamName, client().admin().indices().prepareShardStores(dataStreamName), false); request = new CreateDataStreamAction.Request("logs-barbaz"); client().admin().indices().createDataStream(request).actionGet(); @@ -456,6 +457,7 @@ public class DataStreamIT extends ESIntegTestCase { verifyResolvability(wildcardExpression, client().admin().indices().prepareGetIndex().addIndices(wildcardExpression), false); verifyResolvability(wildcardExpression, client().admin().cluster().prepareSearchShards(wildcardExpression), false); verifyResolvability(wildcardExpression, client().admin().indices().prepareOpen(wildcardExpression), false); + verifyResolvability(wildcardExpression, client().admin().indices().prepareShardStores(wildcardExpression), false); } public void testCannotDeleteComposableTemplateUsedByDataStream() throws Exception { diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresRequest.java index 45a9c7283d0..2bd5e4510d8 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresRequest.java @@ -107,6 +107,11 @@ public class IndicesShardStoresRequest extends MasterNodeReadRequest