Skip to content

Commit 312dac4

Browse files
authored
Test fix: align timeouts in testDataStreamLifecycleDownsampleRollingRestart (#123769) (#126682) (#126816)
Recently we changed the implementation of `testDataStreamLifecycleDownsampleRollingRestart` to use a temporary state listener. We missed that the listener also had a timeout that was quite shorter than the `safeGet` timeout we were configuring. In this PR we align these two timeouts. Fixes: #123769 (cherry picked from commit e461717) # Conflicts: # muted-tests.yml
1 parent a967a8e commit 312dac4

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,6 @@ tests:
421421
- class: org.elasticsearch.packaging.test.DebPreservationTests
422422
method: test40RestartOnUpgrade
423423
issue: https://github.com/elastic/elasticsearch/issues/125821
424-
- class: org.elasticsearch.xpack.downsample.DataStreamLifecycleDownsampleDisruptionIT
425-
method: testDataStreamLifecycleDownsampleRollingRestart
426-
issue: https://github.com/elastic/elasticsearch/issues/123769
427424
- class: org.elasticsearch.repositories.blobstore.testkit.analyze.GCSRepositoryAnalysisRestIT
428425
method: testRepositoryAnalysis
429426
issue: https://github.com/elastic/elasticsearch/issues/125668

test/framework/src/main/java/org/elasticsearch/test/ClusterServiceUtils.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,23 @@ public void clusterStateProcessed(ClusterState initialState, ClusterState newSta
273273
* completed exceptionally on the scheduler thread that belongs to {@code clusterService}.
274274
*/
275275
public static SubscribableListener<Void> addTemporaryStateListener(ClusterService clusterService, Predicate<ClusterState> predicate) {
276+
return addTemporaryStateListener(clusterService, predicate, ESTestCase.SAFE_AWAIT_TIMEOUT);
277+
}
278+
279+
/**
280+
* Creates a {@link ClusterStateListener} which subscribes to the given {@link ClusterService} and waits for it to apply a cluster state
281+
* that satisfies {@code predicate}, at which point it unsubscribes itself.
282+
*
283+
* @return A {@link SubscribableListener} which is completed when the first cluster state matching {@code predicate} is applied by the
284+
* given {@code clusterService}. If the current cluster state already matches {@code predicate} then the returned listener is
285+
* already complete. If no matching cluster state is seen within the provided {@code timeout} then the listener is
286+
* completed exceptionally on the scheduler thread that belongs to {@code clusterService}.
287+
*/
288+
public static SubscribableListener<Void> addTemporaryStateListener(
289+
ClusterService clusterService,
290+
Predicate<ClusterState> predicate,
291+
TimeValue timeout
292+
) {
276293
final var listener = new SubscribableListener<Void>();
277294
final ClusterStateListener clusterStateListener = new ClusterStateListener() {
278295
@Override
@@ -296,7 +313,7 @@ public String toString() {
296313
if (predicate.test(clusterService.state())) {
297314
listener.onResponse(null);
298315
} else {
299-
listener.addTimeout(ESTestCase.SAFE_AWAIT_TIMEOUT, clusterService.threadPool(), EsExecutors.DIRECT_EXECUTOR_SERVICE);
316+
listener.addTimeout(timeout, clusterService.threadPool(), EsExecutors.DIRECT_EXECUTOR_SERVICE);
300317
}
301318
return listener;
302319
}

x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DataStreamLifecycleDownsampleDisruptionIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private void ensureDownsamplingStatus(String downsampledIndex, IndexMetadata.Dow
114114
return true;
115115
}
116116
return false;
117-
});
117+
}, timeout);
118118
safeAwait(listener, timeout);
119119
}
120120
}

0 commit comments

Comments
 (0)