Skip to content

Commit fd6ae3d

Browse files
authored
Properly fix data stream retrieval in TimeSeriesDataStreamsIT (elastic#125815)
This test could still fail by consecutive API calls hitting different nodes with different versions of the cluster state. Follow-up of elastic#125621 Fixes elastic#125752
1 parent daec775 commit fd6ae3d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesDataStreamsIT.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import org.elasticsearch.client.Request;
1111
import org.elasticsearch.client.Response;
12+
import org.elasticsearch.client.ResponseException;
1213
import org.elasticsearch.client.WarningFailureException;
1314
import org.elasticsearch.cluster.metadata.IndexMetadata;
1415
import org.elasticsearch.cluster.metadata.Template;
@@ -82,8 +83,18 @@ public void testRolloverAction() throws Exception {
8283
assertBusy(() -> {
8384
final var backingIndices = getDataStreamBackingIndexNames(dataStream);
8485
assertEquals(2, backingIndices.size());
85-
assertTrue(Boolean.parseBoolean((String) getIndexSettingsAsMap(backingIndices.getLast()).get("index.hidden")));
86-
assertEquals(PhaseCompleteStep.finalStep("hot").getKey(), getStepKeyForIndex(client(), backingIndices.getFirst()));
86+
try {
87+
assertTrue(Boolean.parseBoolean((String) getIndexSettingsAsMap(backingIndices.getLast()).get("index.hidden")));
88+
assertEquals(PhaseCompleteStep.finalStep("hot").getKey(), getStepKeyForIndex(client(), backingIndices.getFirst()));
89+
} catch (ResponseException e) {
90+
// These API calls may hit different nodes and they might see slightly different versions of the cluster state,
91+
// potentially resulting in a 404 which means we just need to try again.
92+
if (e.getResponse().getStatusLine().getStatusCode() == 404) {
93+
fail(e);
94+
} else {
95+
throw e;
96+
}
97+
}
8798
});
8899
}
89100

0 commit comments

Comments
 (0)