From 352a688b041746a669879022b6b1934f8a011892 Mon Sep 17 00:00:00 2001 From: Keith Massey Date: Mon, 1 Aug 2022 13:42:34 -0500 Subject: [PATCH] Eliminating initial delay of CoordinationDiagnosticsService#beginPollingClusterFormationInfo for integration tests (#89001) --- .../coordination/CoordinationDiagnosticsServiceIT.java | 2 ++ .../coordination/CoordinationDiagnosticsService.java | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/CoordinationDiagnosticsServiceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/CoordinationDiagnosticsServiceIT.java index 9f4d1fad8eef3..1cf1b19359cbf 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/CoordinationDiagnosticsServiceIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/CoordinationDiagnosticsServiceIT.java @@ -11,6 +11,7 @@ import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.core.TimeValue; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.disruption.BlockClusterStateProcessing; import org.elasticsearch.threadpool.Scheduler; @@ -69,6 +70,7 @@ public void testBlockClusterStateProcessingOnOneNode() throws Exception { diagnosticsOnBlockedNode.clusterFormationResponses = nodeToClusterFormationStateMap; diagnosticsOnBlockedNode.clusterFormationInfoTasks = cancellables; + diagnosticsOnBlockedNode.remoteRequestInitialDelay = TimeValue.ZERO; diagnosticsOnBlockedNode.beginPollingClusterFormationInfo( nodesWithoutBlockedNode, nodeToClusterFormationStateMap::put, diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/CoordinationDiagnosticsService.java b/server/src/main/java/org/elasticsearch/cluster/coordination/CoordinationDiagnosticsService.java index 9e0b266697e69..3987550436ff0 100644 --- a/server/src/main/java/org/elasticsearch/cluster/coordination/CoordinationDiagnosticsService.java +++ b/server/src/main/java/org/elasticsearch/cluster/coordination/CoordinationDiagnosticsService.java @@ -99,6 +99,13 @@ public class CoordinationDiagnosticsService implements ClusterStateListener { // Non-private for testing volatile ConcurrentMap clusterFormationResponses = null; + /** + * This is the amount of time that we wait before scheduling a remote request to gather diagnostic information. It is not + * user-configurable, but is non-final so that integration tests don't have to waste 10 seconds. + */ + // Non-private for testing + TimeValue remoteRequestInitialDelay = new TimeValue(10, TimeUnit.SECONDS); + private static final Logger logger = LogManager.getLogger(CoordinationDiagnosticsService.class); /** @@ -804,7 +811,7 @@ private Scheduler.Cancellable fetchClusterFormationInfo( connectionListener ); } - }, new TimeValue(10, TimeUnit.SECONDS), ThreadPool.Names.SAME); + }, remoteRequestInitialDelay, ThreadPool.Names.SAME); } // Non-private for testing