From 60fc5f1ec455bf65343dc51da4090589159c8112 Mon Sep 17 00:00:00 2001 From: Niels Bauman Date: Wed, 26 Mar 2025 13:40:44 +0000 Subject: [PATCH] Fix data stream retrieval in `DataStreamLifecycleServiceRuntimeSecurityIT` This test seemed to fail because we would index another document before the master processed the data stream rollover - which is possible because non-master nodes expose the next cluster state a little bit earlier than the master node. Caused by #122852 Fixes #124978 --- muted-tests.yml | 3 --- ...reamLifecycleServiceRuntimeSecurityIT.java | 24 ++++++++----------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/muted-tests.yml b/muted-tests.yml index 5d9c883f65196..6392cd731a87a 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -339,9 +339,6 @@ tests: - class: org.elasticsearch.xpack.esql.action.CrossClusterAsyncQueryStopIT method: testStopQuery issue: https://github.com/elastic/elasticsearch/issues/124977 -- class: org.elasticsearch.integration.DataStreamLifecycleServiceRuntimeSecurityIT - method: testRolloverLifecycleAndForceMergeAuthorized - issue: https://github.com/elastic/elasticsearch/issues/124978 - class: org.elasticsearch.packaging.test.BootstrapCheckTests method: test10Install issue: https://github.com/elastic/elasticsearch/issues/124957 diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/DataStreamLifecycleServiceRuntimeSecurityIT.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/DataStreamLifecycleServiceRuntimeSecurityIT.java index 9f24c5240d3fa..c1a031823a25b 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/DataStreamLifecycleServiceRuntimeSecurityIT.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/DataStreamLifecycleServiceRuntimeSecurityIT.java @@ -97,23 +97,19 @@ public void testRolloverLifecycleAndForceMergeAuthorized() throws Exception { // empty lifecycle contains the default rollover prepareDataStreamAndIndex(dataStreamName, DataStreamLifecycle.Template.DEFAULT); - assertBusy(() -> { - assertNoAuthzErrors(); - List backingIndices = getDataStreamBackingIndices(dataStreamName); - assertThat(backingIndices.size(), equalTo(2)); - String backingIndex = backingIndices.get(0).getName(); - assertThat(backingIndex, backingIndexEqualTo(dataStreamName, 1)); - String writeIndex = backingIndices.get(1).getName(); - assertThat(writeIndex, backingIndexEqualTo(dataStreamName, 2)); - }); + List backingIndices = waitForDataStreamBackingIndices(dataStreamName, 2); + String backingIndex = backingIndices.get(0); + assertThat(backingIndex, backingIndexEqualTo(dataStreamName, 1)); + String writeIndex = backingIndices.get(1); + assertThat(writeIndex, backingIndexEqualTo(dataStreamName, 2)); + + assertNoAuthzErrors(); // Index another doc to force another rollover and trigger an attempted force-merge. The force-merge may be a noop under // the hood but for authz purposes this doesn't matter, it only matters that the force-merge API was called indexDoc(dataStreamName); - assertBusy(() -> { - assertNoAuthzErrors(); - List backingIndices = getDataStreamBackingIndices(dataStreamName); - assertThat(backingIndices.size(), equalTo(3)); - }); + + waitForDataStreamBackingIndices(dataStreamName, 3); + assertNoAuthzErrors(); } public void testRolloverAndRetentionAuthorized() throws Exception {