From 3ecb1bfc40ef97c7bb00693219b601d8329d2ad5 Mon Sep 17 00:00:00 2001 From: gmarouli Date: Fri, 11 Apr 2025 14:46:00 +0300 Subject: [PATCH 1/2] Test fix: align timeouts in `testDataStreamLifecycleDownsampleRollingRestart` (#123769) --- muted-tests.yml | 3 --- .../test/ClusterServiceUtils.java | 19 ++++++++++++++++++- ...StreamLifecycleDownsampleDisruptionIT.java | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/muted-tests.yml b/muted-tests.yml index 7e93bb90d8413..177f03d00f19e 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -318,9 +318,6 @@ tests: - class: org.elasticsearch.xpack.core.common.notifications.AbstractAuditorTests method: testRecreateTemplateWhenDeleted issue: https://github.com/elastic/elasticsearch/issues/123232 -- class: org.elasticsearch.xpack.downsample.DataStreamLifecycleDownsampleDisruptionIT - method: testDataStreamLifecycleDownsampleRollingRestart - issue: https://github.com/elastic/elasticsearch/issues/123769 - class: org.elasticsearch.xpack.test.rest.XPackRestIT method: test {p0=ml/start_data_frame_analytics/Test start given dest index is not empty} issue: https://github.com/elastic/elasticsearch/issues/125909 diff --git a/test/framework/src/main/java/org/elasticsearch/test/ClusterServiceUtils.java b/test/framework/src/main/java/org/elasticsearch/test/ClusterServiceUtils.java index 52296f1d896cc..becb6aaa7de19 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ClusterServiceUtils.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ClusterServiceUtils.java @@ -273,6 +273,23 @@ public void clusterStateProcessed(ClusterState initialState, ClusterState newSta * completed exceptionally on the scheduler thread that belongs to {@code clusterService}. */ public static SubscribableListener addTemporaryStateListener(ClusterService clusterService, Predicate predicate) { + return addTemporaryStateListener(clusterService, predicate, ESTestCase.SAFE_AWAIT_TIMEOUT); + } + + /** + * Creates a {@link ClusterStateListener} which subscribes to the given {@link ClusterService} and waits for it to apply a cluster state + * that satisfies {@code predicate}, at which point it unsubscribes itself. + * + * @return A {@link SubscribableListener} which is completed when the first cluster state matching {@code predicate} is applied by the + * given {@code clusterService}. If the current cluster state already matches {@code predicate} then the returned listener is + * already complete. If no matching cluster state is seen within the provided {@code timeout} then the listener is + * completed exceptionally on the scheduler thread that belongs to {@code clusterService}. + */ + public static SubscribableListener addTemporaryStateListener( + ClusterService clusterService, + Predicate predicate, + TimeValue timeout + ) { final var listener = new SubscribableListener(); final ClusterStateListener clusterStateListener = new ClusterStateListener() { @Override @@ -296,7 +313,7 @@ public String toString() { if (predicate.test(clusterService.state())) { listener.onResponse(null); } else { - listener.addTimeout(ESTestCase.SAFE_AWAIT_TIMEOUT, clusterService.threadPool(), EsExecutors.DIRECT_EXECUTOR_SERVICE); + listener.addTimeout(timeout, clusterService.threadPool(), EsExecutors.DIRECT_EXECUTOR_SERVICE); } return listener; } diff --git a/x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DataStreamLifecycleDownsampleDisruptionIT.java b/x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DataStreamLifecycleDownsampleDisruptionIT.java index a96a7f20a815f..7cf49de8a5b42 100644 --- a/x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DataStreamLifecycleDownsampleDisruptionIT.java +++ b/x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DataStreamLifecycleDownsampleDisruptionIT.java @@ -115,7 +115,7 @@ private void ensureDownsamplingStatus(String downsampledIndex, IndexMetadata.Dow return true; } return false; - }); + }, timeout); safeAwait(listener, timeout.millis(), TimeUnit.MILLISECONDS); } } From 608fdeaa0ac3677b4719d67be1e17e09c47155d8 Mon Sep 17 00:00:00 2001 From: gmarouli Date: Mon, 14 Apr 2025 14:50:31 +0300 Subject: [PATCH 2/2] Revert merge error --- .../downsample/DataStreamLifecycleDownsampleDisruptionIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DataStreamLifecycleDownsampleDisruptionIT.java b/x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DataStreamLifecycleDownsampleDisruptionIT.java index e8fb278bb570a..470f13a2d8c2e 100644 --- a/x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DataStreamLifecycleDownsampleDisruptionIT.java +++ b/x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DataStreamLifecycleDownsampleDisruptionIT.java @@ -114,7 +114,7 @@ private void ensureDownsamplingStatus(String downsampledIndex, IndexMetadata.Dow return true; } return false; - }); + }, timeout); safeAwait(listener, timeout); } }