Skip to content

Commit d851c3c

Browse files
authored
Adjust AutoFollowIT#testDataStreams_autoFollowAfterDataStreamCreated() test (#74541)
Backporting #74468 to 7.x 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 966b1e0 commit d851c3c

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
@@ -323,12 +323,21 @@ public void testDataStreams_autoFollowAfterDataStreamCreated() throws Exception
323323

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

335+
final String autoFollowPatternName = getTestName().toLowerCase(Locale.ROOT);
329336
try {
330337
// Initialize data stream prior to auto following
331338
try (RestClient leaderClient = buildLeaderClient()) {
339+
assertOK(leaderClient.performRequest(putComposableIndexTemplateRequest));
340+
332341
for (int i = 0; i < initialNumDocs; i++) {
333342
Request indexRequest = new Request("POST", "/" + dataStreamName + "/_doc");
334343
indexRequest.addParameter("refresh", "true");
@@ -340,7 +349,7 @@ public void testDataStreams_autoFollowAfterDataStreamCreated() throws Exception
340349
}
341350

342351
// Create auto follow pattern
343-
createAutoFollowPattern(client(), autoFollowPatternName, "logs-syslog-*", "leader_cluster");
352+
createAutoFollowPattern(client(), autoFollowPatternName, dataStreamName + "*", "leader_cluster");
344353

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

0 commit comments

Comments
 (0)