Skip to content

Commit

Permalink
Adjust AutoFollowIT#testDataStreams_autoFollowAfterDataStreamCreated(…
Browse files Browse the repository at this point in the history
…) 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
  • Loading branch information
martijnvg committed Jun 24, 2021
1 parent 5ea91ac commit edfbb46
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,21 @@ public void testDataStreams_autoFollowAfterDataStreamCreated() throws Exception

final int initialNumDocs = 16;
int initialNumberOfSuccessfulFollowedIndices = getNumberOfSuccessfulFollowedIndices();
final String dataStreamName = "logs-syslog-prod";
final String autoFollowPatternName = getTestName().toLowerCase(Locale.ROOT);
// The data stream name shouldn't match with builtin ilm policies to avoid test instabilities.
// (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)
final String dataStreamName = getTestName().toLowerCase(Locale.ROOT) + "-logs-syslog-prod";
// Because the builtin logs template isn't used, a template should be defined here.
Request putComposableIndexTemplateRequest = new Request("POST", "/_index_template/" + getTestName().toLowerCase(Locale.ROOT));
putComposableIndexTemplateRequest.setJsonEntity("{\"index_patterns\":[\"" + dataStreamName + "*\"],\"data_stream\":{}}");
assertOK(client().performRequest(putComposableIndexTemplateRequest));

final String autoFollowPatternName = getTestName().toLowerCase(Locale.ROOT);
try {
// Initialize data stream prior to auto following
try (RestClient leaderClient = buildLeaderClient()) {
assertOK(leaderClient.performRequest(putComposableIndexTemplateRequest));

for (int i = 0; i < initialNumDocs; i++) {
Request indexRequest = new Request("POST", "/" + dataStreamName + "/_doc");
indexRequest.addParameter("refresh", "true");
Expand All @@ -326,7 +335,7 @@ public void testDataStreams_autoFollowAfterDataStreamCreated() throws Exception
}

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

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

0 comments on commit edfbb46

Please sign in to comment.