From d606763301369a6723ef1d1af660e3d02c8326e3 Mon Sep 17 00:00:00 2001 From: Niels Bauman Date: Thu, 27 Mar 2025 21:47:26 +0000 Subject: [PATCH] Properly fix data stream retrieval in TimeSeriesDataStreamsIT This test could still fail by consecutive API calls hitting different nodes with different versions of the cluster state. Follow-up of #125621 Relates #125752 (but doesn't close it, as that issue includes two different failures) --- .../xpack/ilm/TimeSeriesDataStreamsIT.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesDataStreamsIT.java b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesDataStreamsIT.java index d4df28e5fc57f..f7df891ae5537 100644 --- a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesDataStreamsIT.java +++ b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesDataStreamsIT.java @@ -9,6 +9,7 @@ import org.elasticsearch.client.Request; import org.elasticsearch.client.Response; +import org.elasticsearch.client.ResponseException; import org.elasticsearch.client.WarningFailureException; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.Template; @@ -82,8 +83,18 @@ public void testRolloverAction() throws Exception { assertBusy(() -> { final var backingIndices = getDataStreamBackingIndexNames(dataStream); assertEquals(2, backingIndices.size()); - assertTrue(Boolean.parseBoolean((String) getIndexSettingsAsMap(backingIndices.getLast()).get("index.hidden"))); - assertEquals(PhaseCompleteStep.finalStep("hot").getKey(), getStepKeyForIndex(client(), backingIndices.getFirst())); + try { + assertTrue(Boolean.parseBoolean((String) getIndexSettingsAsMap(backingIndices.getLast()).get("index.hidden"))); + assertEquals(PhaseCompleteStep.finalStep("hot").getKey(), getStepKeyForIndex(client(), backingIndices.getFirst())); + } catch (ResponseException e) { + // These API calls may hit different nodes and they might see slightly different versions of the cluster state, + // potentially resulting in a 404 which means we just need to try again. + if (e.getResponse().getStatusLine().getStatusCode() == 404) { + fail(e); + } else { + throw e; + } + } }); }