Skip to content

Commit edfbb46

Browse files
committed
Adjust AutoFollowIT#testDataStreams_autoFollowAfterDataStreamCreated() test (#74541)
Backporting #74468 to 7.13 branch. Adjust ccr data stream test that tests following a backing index after the data stream has been auto followed. Avoid that a data stream matches with a builtin template that uses ilm. The manual rollover that happens in this test, may cause ilm to add `index.lifecycle.indexing_complete` setting, which causes explicit follow index api call to fail in this test Closes #72062
1 parent 5ea91ac commit edfbb46

File tree

1 file changed

+12
-3
lines changed
  • x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr

1 file changed

+12
-3
lines changed

x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,21 @@ public void testDataStreams_autoFollowAfterDataStreamCreated() throws Exception
309309

310310
final int initialNumDocs = 16;
311311
int initialNumberOfSuccessfulFollowedIndices = getNumberOfSuccessfulFollowedIndices();
312-
final String dataStreamName = "logs-syslog-prod";
313-
final String autoFollowPatternName = getTestName().toLowerCase(Locale.ROOT);
312+
// The data stream name shouldn't match with builtin ilm policies to avoid test instabilities.
313+
// (the manual rollover that happens in this test, may cause ilm to add `index.lifecycle.indexing_complete` setting,
314+
// which causes explicit follow index api call to fail in this test)
315+
final String dataStreamName = getTestName().toLowerCase(Locale.ROOT) + "-logs-syslog-prod";
316+
// Because the builtin logs template isn't used, a template should be defined here.
317+
Request putComposableIndexTemplateRequest = new Request("POST", "/_index_template/" + getTestName().toLowerCase(Locale.ROOT));
318+
putComposableIndexTemplateRequest.setJsonEntity("{\"index_patterns\":[\"" + dataStreamName + "*\"],\"data_stream\":{}}");
319+
assertOK(client().performRequest(putComposableIndexTemplateRequest));
314320

321+
final String autoFollowPatternName = getTestName().toLowerCase(Locale.ROOT);
315322
try {
316323
// Initialize data stream prior to auto following
317324
try (RestClient leaderClient = buildLeaderClient()) {
325+
assertOK(leaderClient.performRequest(putComposableIndexTemplateRequest));
326+
318327
for (int i = 0; i < initialNumDocs; i++) {
319328
Request indexRequest = new Request("POST", "/" + dataStreamName + "/_doc");
320329
indexRequest.addParameter("refresh", "true");
@@ -326,7 +335,7 @@ public void testDataStreams_autoFollowAfterDataStreamCreated() throws Exception
326335
}
327336

328337
// Create auto follow pattern
329-
createAutoFollowPattern(client(), autoFollowPatternName, "logs-syslog-*", "leader_cluster");
338+
createAutoFollowPattern(client(), autoFollowPatternName, dataStreamName + "*", "leader_cluster");
330339

331340
// Rollover and ensure only second backing index is replicated:
332341
try (RestClient leaderClient = buildLeaderClient()) {

0 commit comments

Comments
 (0)