Skip to content

Commit cd4e3fa

Browse files
committed
Add test case for when we display ilm
1 parent dc5f3cd commit cd4e3fa

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

server/src/test/java/org/elasticsearch/action/datastreams/GetDataStreamActionTests.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,45 @@ public void testDataStreamInfoToXContent() throws IOException {
6363
}
6464
}
6565

66+
@SuppressWarnings("unchecked")
67+
public void testFailureStoreIndexManagedByIlmToXContent() throws IOException {
68+
{
69+
70+
Index failureIndex = new Index("my-fs", randomUUID());
71+
var failureIndexProperties = new GetDataStreamAction.Response.IndexProperties(
72+
randomBoolean(),
73+
"my-policy",
74+
randomFrom(GetDataStreamAction.Response.ManagedBy.values()),
75+
null
76+
);
77+
var dataStream = DataStream.builder(
78+
randomAlphaOfLength(50),
79+
List.of(new Index(randomAlphaOfLength(10), randomAlphaOfLength(10)))
80+
)
81+
.setGeneration(randomLongBetween(1, 1000))
82+
.setFailureIndices(DataStream.DataStreamIndices.failureIndicesBuilder(List.of(failureIndex)).build())
83+
.build();
84+
var dataStreamInfo = new GetDataStreamAction.Response.DataStreamInfo(
85+
dataStream,
86+
randomBoolean(),
87+
randomFrom(ClusterHealthStatus.values()),
88+
null,
89+
null,
90+
null,
91+
Map.of(failureIndex, failureIndexProperties),
92+
randomBoolean(),
93+
null,
94+
null
95+
);
96+
Map<String, Object> failureStoreMap = (Map<String, Object>) getXContentMap(dataStreamInfo, null, null).get("failure_store");
97+
Map<String, Object> failureIndexMap = ((List<Map<String, Object>>) failureStoreMap.get("indices")).get(0);
98+
assertThat(failureIndexMap.get("index_name"), equalTo(failureIndex.getName()));
99+
assertThat(failureIndexMap.get("managed_by"), equalTo(failureIndexProperties.managedBy().displayValue));
100+
assertThat(failureIndexMap.get("prefer_ilm"), equalTo(failureIndexProperties.preferIlm()));
101+
assertThat(failureIndexMap.get("ilm_policy"), equalTo(failureIndexProperties.ilmPolicyName()));
102+
}
103+
}
104+
66105
/*
67106
* Calls toXContent on the given dataStreamInfo, and converts the response to a Map
68107
*/

0 commit comments

Comments
 (0)