Skip to content

Commit df1c573

Browse files
committed
Consistently name the failures lifecycle
1 parent a441c6f commit df1c573

File tree

11 files changed

+38
-38
lines changed

11 files changed

+38
-38
lines changed

modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ static void putComposableIndexTemplate(
10291029
@Nullable Settings settings,
10301030
@Nullable Map<String, Object> metadata,
10311031
@Nullable DataStreamLifecycle.Template dataLifecycle,
1032-
@Nullable DataStreamLifecycle.Template failureLifecycle,
1032+
@Nullable DataStreamLifecycle.Template failuresLifecycle,
10331033
boolean withFailureStore
10341034
) throws IOException {
10351035
TransportPutComposableIndexTemplateAction.Request request = new TransportPutComposableIndexTemplateAction.Request(id);
@@ -1042,7 +1042,7 @@ static void putComposableIndexTemplate(
10421042
.mappings(mappings == null ? null : CompressedXContent.fromJSON(mappings))
10431043
.lifecycle(dataLifecycle)
10441044
.dataStreamOptions(
1045-
new DataStreamOptions.Template(new DataStreamFailureStore.Template(withFailureStore, failureLifecycle))
1045+
new DataStreamOptions.Template(new DataStreamFailureStore.Template(withFailureStore, failuresLifecycle))
10461046
)
10471047
)
10481048
.metadata(metadata)

modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/lifecycle/ExplainDataStreamLifecycleIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public void testSystemExplainLifecycle() throws Exception {
246246
}
247247
}
248248

249-
public void testExplainFailureLifecycle() throws Exception {
249+
public void testExplainfailuresLifecycle() throws Exception {
250250
// Failure indices are always managed unless explicitly disabled.
251251
putComposableIndexTemplate(
252252
"id1",

modules/data-streams/src/javaRestTest/java/org/elasticsearch/datastreams/lifecycle/DataStreamGlobalRetentionIT.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ public void testDataStreamRetention() throws Exception {
123123
assertThat(lifecycle.get("effective_retention"), is("10s"));
124124
assertThat(lifecycle.get("retention_determined_by"), is("data_stream_configuration"));
125125
assertThat(lifecycle.get("data_retention"), is("10s"));
126-
Map<String, Object> failureLifecycle = ((Map<String, Map<String, Object>>) dataStream.get("failure_store")).get("lifecycle");
127-
assertThat(failureLifecycle.get("effective_retention"), is("10s"));
128-
assertThat(failureLifecycle.get("retention_determined_by"), is("data_stream_configuration"));
129-
assertThat(failureLifecycle.get("data_retention"), is("10s"));
126+
Map<String, Object> failuresLifecycle = ((Map<String, Map<String, Object>>) dataStream.get("failure_store")).get("lifecycle");
127+
assertThat(failuresLifecycle.get("effective_retention"), is("10s"));
128+
assertThat(failuresLifecycle.get("retention_determined_by"), is("data_stream_configuration"));
129+
assertThat(failuresLifecycle.get("data_retention"), is("10s"));
130130
}
131131

132132
// Verify that the first generation index was removed
@@ -161,10 +161,10 @@ public void testDefaultRetention() throws Exception {
161161
assertThat(lifecycle.get("effective_retention"), is("10s"));
162162
assertThat(lifecycle.get("retention_determined_by"), is("default_global_retention"));
163163
assertThat(lifecycle.get("data_retention"), nullValue());
164-
Map<String, Object> failureLifecycle = ((Map<String, Map<String, Object>>) dataStream.get("failure_store")).get("lifecycle");
165-
assertThat(failureLifecycle.get("effective_retention"), is("10s"));
166-
assertThat(failureLifecycle.get("retention_determined_by"), is("default_global_retention"));
167-
assertThat(failureLifecycle.get("data_retention"), nullValue());
164+
Map<String, Object> failuresLifecycle = ((Map<String, Map<String, Object>>) dataStream.get("failure_store")).get("lifecycle");
165+
assertThat(failuresLifecycle.get("effective_retention"), is("10s"));
166+
assertThat(failuresLifecycle.get("retention_determined_by"), is("default_global_retention"));
167+
assertThat(failuresLifecycle.get("data_retention"), nullValue());
168168
}
169169

170170
// Verify that the first generation index was removed
@@ -238,13 +238,13 @@ public void testMaxRetention() throws Exception {
238238
} else {
239239
assertThat(lifecycle.get("data_retention"), nullValue());
240240
}
241-
Map<String, Object> failureLifecycle = ((Map<String, Map<String, Object>>) dataStream.get("failure_store")).get("lifecycle");
242-
assertThat(failureLifecycle.get("effective_retention"), is("10s"));
243-
assertThat(failureLifecycle.get("retention_determined_by"), is("max_global_retention"));
241+
Map<String, Object> failuresLifecycle = ((Map<String, Map<String, Object>>) dataStream.get("failure_store")).get("lifecycle");
242+
assertThat(failuresLifecycle.get("effective_retention"), is("10s"));
243+
assertThat(failuresLifecycle.get("retention_determined_by"), is("max_global_retention"));
244244
if (withDataStreamLevelRetention) {
245-
assertThat(failureLifecycle.get("data_retention"), is("30d"));
245+
assertThat(failuresLifecycle.get("data_retention"), is("30d"));
246246
} else {
247-
assertThat(failureLifecycle.get("data_retention"), nullValue());
247+
assertThat(failuresLifecycle.get("data_retention"), nullValue());
248248
}
249249
}
250250

modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,9 @@ private void run(ProjectState projectState) {
366366
for (DataStream dataStream : project.dataStreams().values()) {
367367
clearErrorStoreForUnmanagedIndices(project, dataStream);
368368
var dataLifecycleDisabled = dataStream.getDataLifecycle() == null || dataStream.getDataLifecycle().enabled() == false;
369-
var failureLifecycleDisabled = dataStream.getFailureIndices().isEmpty()
369+
var failuresLifecycleDisabled = dataStream.getFailureIndices().isEmpty()
370370
|| dataStream.getFailuresLifecycle() != null && dataStream.getFailuresLifecycle().enabled() == false;
371-
if (dataLifecycleDisabled && failureLifecycleDisabled) {
371+
if (dataLifecycleDisabled && failuresLifecycleDisabled) {
372372
continue;
373373
}
374374

@@ -928,7 +928,7 @@ Set<Index> maybeExecuteRetention(ProjectMetadata project, DataStream dataStream,
928928
}
929929
Set<Index> indicesToBeRemoved = new HashSet<>();
930930
if (backingIndicesOlderThanRetention.isEmpty() == false) {
931-
assert dataStream.getDataLifecycle() != null : "data stream should have failure lifecycle if we have 'old' indices";
931+
assert dataStream.getDataLifecycle() != null : "data stream should have failures lifecycle if we have 'old' indices";
932932
for (Index index : backingIndicesOlderThanRetention) {
933933
if (indicesToExcludeForRemainingRun.contains(index) == false) {
934934
IndexMetadata backingIndex = project.index(index);
@@ -961,7 +961,7 @@ Set<Index> maybeExecuteRetention(ProjectMetadata project, DataStream dataStream,
961961
}
962962
}
963963
if (failureIndicesOlderThanRetention.isEmpty() == false) {
964-
assert dataStream.getFailuresLifecycle() != null : "data stream should have failure lifecycle if we have 'old' indices";
964+
assert dataStream.getFailuresLifecycle() != null : "data stream should have failures lifecycle if we have 'old' indices";
965965
for (Index index : failureIndicesOlderThanRetention) {
966966
if (indicesToExcludeForRemainingRun.contains(index) == false) {
967967
IndexMetadata failureIndex = project.index(index);

modules/data-streams/src/test/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleFixtures.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static DataStream createDataStream(
6868
int failureIndicesCount,
6969
Settings.Builder backingIndicesSettings,
7070
@Nullable DataStreamLifecycle dataLifecycle,
71-
@Nullable DataStreamLifecycle failureLifecycle,
71+
@Nullable DataStreamLifecycle failuresLifecycle,
7272
Long now
7373
) {
7474
final List<Index> backingIndices = new ArrayList<>();
@@ -111,7 +111,7 @@ public static DataStream createDataStream(
111111
false,
112112
dataLifecycle,
113113
failureIndices,
114-
new DataStreamOptions(new DataStreamFailureStore(failureIndices.isEmpty() == false, failureLifecycle))
114+
new DataStreamOptions(new DataStreamFailureStore(failureIndices.isEmpty() == false, failuresLifecycle))
115115
);
116116
}
117117

modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/240_failure_store_info.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
setup:
22
- requires:
33
test_runner_features: [ capabilities, allowed_warnings ]
4-
reason: "Data stream failure lifecycle config in templates was added in 9.1+"
4+
reason: "Data stream failures lifecycle config in templates was added in 9.1+"
55
capabilities:
66
- method: GET
77
path: /_data_stream/{target}

server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamFailureStoreTemplateTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected DataStreamFailureStore.Template mutateInstance(DataStreamFailureStore.
4343
case 1 -> lifecycle = lifecycle.get() != null && enabled.get() != null && randomBoolean()
4444
? randomEmptyResettableValue()
4545
: ResettableValue.create(
46-
randomValueOtherThan(lifecycle.get(), DataStreamLifecycleTemplateTests::randomFailureLifecycleTemplate)
46+
randomValueOtherThan(lifecycle.get(), DataStreamLifecycleTemplateTests::randomfailuresLifecycleTemplate)
4747
);
4848
default -> throw new IllegalArgumentException("illegal randomisation branch");
4949
}
@@ -61,7 +61,7 @@ static DataStreamFailureStore.Template randomFailureStoreTemplate() {
6161
return new DataStreamFailureStore.Template(
6262
enabledDefined ? ResettableValue.create(randomBoolean()) : randomEmptyResettableValue(),
6363
lifecycleDefined
64-
? ResettableValue.create(DataStreamLifecycleTemplateTests.randomFailureLifecycleTemplate())
64+
? ResettableValue.create(DataStreamLifecycleTemplateTests.randomfailuresLifecycleTemplate())
6565
: randomEmptyResettableValue()
6666
);
6767
}
@@ -95,7 +95,7 @@ public void testTemplateComposition() {
9595
boolean enabled = randomBoolean();
9696
DataStreamFailureStore.Template template = new DataStreamFailureStore.Template(
9797
enabled,
98-
randomBoolean() ? null : DataStreamLifecycleTemplateTests.randomFailureLifecycleTemplate()
98+
randomBoolean() ? null : DataStreamLifecycleTemplateTests.randomfailuresLifecycleTemplate()
9999
);
100100
DataStreamFailureStore.Template result = DataStreamFailureStore.builder(template).composeTemplate(template).buildTemplate();
101101
assertThat(result, equalTo(template));
@@ -124,13 +124,13 @@ public void testTemplateComposition() {
124124
// Test reset
125125
DataStreamFailureStore.Template fullyFilledTemplate = DataStreamFailureStore.builder()
126126
.enabled(ResettableValue.create(randomBoolean()))
127-
.lifecycle(DataStreamLifecycleTests.randomFailureLifecycle())
127+
.lifecycle(DataStreamLifecycleTests.randomFailuresLifecycle())
128128
.buildTemplate();
129129
result = DataStreamFailureStore.builder(fullyFilledTemplate)
130130
.composeTemplate(
131131
new DataStreamFailureStore.Template(
132132
ResettableValue.reset(),
133-
ResettableValue.create(DataStreamLifecycleTemplateTests.randomFailureLifecycleTemplate())
133+
ResettableValue.create(DataStreamLifecycleTemplateTests.randomfailuresLifecycleTemplate())
134134
)
135135
)
136136
.buildTemplate();

server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamFailureStoreTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected DataStreamFailureStore mutateInstance(DataStreamFailureStore instance)
3737
case 0 -> enabled = enabled != null && lifecycle != null && randomBoolean() ? null : Boolean.FALSE.equals(enabled);
3838
case 1 -> lifecycle = lifecycle != null && enabled != null && randomBoolean()
3939
? null
40-
: randomValueOtherThan(lifecycle, DataStreamLifecycleTests::randomFailureLifecycle);
40+
: randomValueOtherThan(lifecycle, DataStreamLifecycleTests::randomFailuresLifecycle);
4141
default -> throw new IllegalArgumentException("illegal randomisation branch");
4242
}
4343
return new DataStreamFailureStore(enabled, lifecycle);
@@ -53,7 +53,7 @@ static DataStreamFailureStore randomFailureStore() {
5353
boolean lifecycleDefined = enabledDefined == false || randomBoolean();
5454
return new DataStreamFailureStore(
5555
enabledDefined ? randomBoolean() : null,
56-
lifecycleDefined ? DataStreamLifecycleTests.randomFailureLifecycle() : null
56+
lifecycleDefined ? DataStreamLifecycleTests.randomFailuresLifecycle() : null
5757
);
5858
}
5959

server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamLifecycleTemplateTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public static DataStreamLifecycle.Template randomLifecycleTemplate() {
173173
* Failure store lifecycle doesn't support downsampling, this random lifecycle generator never defines
174174
* downsampling.
175175
*/
176-
public static DataStreamLifecycle.Template randomFailureLifecycleTemplate() {
176+
public static DataStreamLifecycle.Template randomfailuresLifecycleTemplate() {
177177
return new DataStreamLifecycle.Template(randomBoolean(), randomRetention(), ResettableValue.undefined());
178178
}
179179

server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamLifecycleTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,10 +407,10 @@ public static DataStreamLifecycle randomLifecycle() {
407407
}
408408

409409
/**
410-
* Failure lifecycle does not support downsampling, this is why we have a dedicated method
410+
* Failures lifecycle does not support downsampling, this is why we have a dedicated method
411411
* @return a random lifecycle without downsampling
412412
*/
413-
public static DataStreamLifecycle randomFailureLifecycle() {
413+
public static DataStreamLifecycle randomFailuresLifecycle() {
414414
return DataStreamLifecycle.builder()
415415
.dataRetention(randomBoolean() ? null : randomTimeValue(1, 365, TimeUnit.DAYS))
416416
.enabled(randomBoolean())

0 commit comments

Comments
 (0)