-
Notifications
You must be signed in to change notification settings - Fork 26k
Excluding system data streams from global and factory retention #108038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 21 commits
959c4c8
892b36a
e28c0a4
5ec38d1
232c442
40ff495
ea71ebc
df52058
c47801d
f9137cb
0fa423a
81427b8
f82d9e7
ba7b91b
4344dd4
87fc681
8c5a93f
59dd38b
2f15fc5
475550b
66b557a
ea2be97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |
| import org.elasticsearch.common.compress.CompressedXContent; | ||
| import org.elasticsearch.common.settings.Settings; | ||
| import org.elasticsearch.core.Nullable; | ||
| import org.elasticsearch.core.TimeValue; | ||
| import org.elasticsearch.datastreams.DataStreamsPlugin; | ||
| import org.elasticsearch.index.Index; | ||
| import org.elasticsearch.index.mapper.DateFieldMapper; | ||
|
|
@@ -46,6 +47,8 @@ | |
|
|
||
| import static org.elasticsearch.cluster.metadata.DataStreamTestHelper.backingIndexEqualTo; | ||
| import static org.elasticsearch.cluster.metadata.MetadataIndexTemplateService.DEFAULT_TIMESTAMP_FIELD; | ||
| import static org.elasticsearch.datastreams.lifecycle.DataStreamLifecycleServiceIT.TestSystemDataStreamPlugin.SYSTEM_DATA_STREAM_NAME; | ||
| import static org.elasticsearch.datastreams.lifecycle.DataStreamLifecycleServiceIT.TestSystemDataStreamPlugin.SYSTEM_DATA_STREAM_RETENTION_DAYS; | ||
| import static org.elasticsearch.indices.ShardLimitValidator.SETTING_CLUSTER_MAX_SHARDS_PER_NODE; | ||
| import static org.hamcrest.Matchers.containsString; | ||
| import static org.hamcrest.Matchers.equalTo; | ||
|
|
@@ -59,7 +62,11 @@ public class ExplainDataStreamLifecycleIT extends ESIntegTestCase { | |
|
|
||
| @Override | ||
| protected Collection<Class<? extends Plugin>> nodePlugins() { | ||
| return List.of(DataStreamsPlugin.class, MockTransportService.TestPlugin.class); | ||
| return List.of( | ||
| DataStreamsPlugin.class, | ||
| MockTransportService.TestPlugin.class, | ||
| DataStreamLifecycleServiceIT.TestSystemDataStreamPlugin.class | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -194,6 +201,54 @@ public void testExplainLifecycle() throws Exception { | |
| } | ||
| } | ||
|
|
||
| public void testSystemExplainLifecycle() throws Exception { | ||
| /* | ||
| * This test makes sure that for system data streams, we correctly ignore the global retention when calling | ||
| * ExplainDataStreamLifecycle. It is very simila to testExplainLifecycle, but only focuses on the retention for a system index. | ||
| */ | ||
| String dataStreamName = SYSTEM_DATA_STREAM_NAME; | ||
| CreateDataStreamAction.Request createDataStreamRequest = new CreateDataStreamAction.Request(dataStreamName); | ||
| client().execute(CreateDataStreamAction.INSTANCE, createDataStreamRequest).get(); | ||
|
|
||
| indexDocs(dataStreamName, 1); | ||
|
|
||
| assertBusy(() -> { | ||
| GetDataStreamAction.Request getDataStreamRequest = new GetDataStreamAction.Request(new String[] { dataStreamName }); | ||
| GetDataStreamAction.Response getDataStreamResponse = client().execute(GetDataStreamAction.INSTANCE, getDataStreamRequest) | ||
| .actionGet(); | ||
| assertThat(getDataStreamResponse.getDataStreams().size(), equalTo(1)); | ||
| assertThat(getDataStreamResponse.getDataStreams().get(0).getDataStream().getName(), equalTo(dataStreamName)); | ||
| List<Index> backingIndices = getDataStreamResponse.getDataStreams().get(0).getDataStream().getIndices(); | ||
| assertThat(backingIndices.size(), equalTo(2)); | ||
| String backingIndex = backingIndices.get(0).getName(); | ||
| assertThat(backingIndex, backingIndexEqualTo(dataStreamName, 1)); | ||
| String writeIndex = backingIndices.get(1).getName(); | ||
| assertThat(writeIndex, backingIndexEqualTo(dataStreamName, 2)); | ||
| }); | ||
|
|
||
| ExplainDataStreamLifecycleAction.Request explainIndicesRequest = new ExplainDataStreamLifecycleAction.Request( | ||
| new String[] { | ||
| DataStream.getDefaultBackingIndexName(dataStreamName, 1), | ||
| DataStream.getDefaultBackingIndexName(dataStreamName, 2) } | ||
| ); | ||
| ExplainDataStreamLifecycleAction.Response response = client().execute( | ||
| ExplainDataStreamLifecycleAction.INSTANCE, | ||
| explainIndicesRequest | ||
| ).actionGet(); | ||
| assertThat(response.getIndices().size(), is(2)); | ||
| // we requested the explain for indices with the default include_details=false | ||
| assertThat(response.getRolloverConfiguration(), nullValue()); | ||
| for (ExplainIndexDataStreamLifecycle explainIndex : response.getIndices()) { | ||
| assertThat(explainIndex.isManagedByLifecycle(), is(true)); | ||
| assertThat(explainIndex.getIndexCreationDate(), notNullValue()); | ||
| assertThat(explainIndex.getLifecycle(), notNullValue()); | ||
| assertThat( | ||
| explainIndex.getLifecycle().getDataStreamRetention(), | ||
| equalTo(TimeValue.timeValueDays(SYSTEM_DATA_STREAM_RETENTION_DAYS)) | ||
| ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this test missing a request that actually sets a global retention? Without such a request, this assertion becomes rather trivial, I think. But maybe I'm missing something.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops. Good catch! |
||
| } | ||
| } | ||
|
|
||
| public void testExplainLifecycleForIndicesWithErrors() throws Exception { | ||
| // empty lifecycle contains the default rollover | ||
| DataStreamLifecycle lifecycle = new DataStreamLifecycle(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: