فهرست منبع

Eliminating initial delay of CoordinationDiagnosticsService#beginPollingClusterFormationInfo for integration tests (#89001)

Keith Massey 3 سال پیش
والد
کامیت
352a688b04

+ 2 - 0
server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/CoordinationDiagnosticsServiceIT.java

@@ -11,6 +11,7 @@ package org.elasticsearch.cluster.coordination;
 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 class CoordinationDiagnosticsServiceIT extends ESIntegTestCase {
         diagnosticsOnBlockedNode.clusterFormationResponses = nodeToClusterFormationStateMap;
         diagnosticsOnBlockedNode.clusterFormationInfoTasks = cancellables;
 
+        diagnosticsOnBlockedNode.remoteRequestInitialDelay = TimeValue.ZERO;
         diagnosticsOnBlockedNode.beginPollingClusterFormationInfo(
             nodesWithoutBlockedNode,
             nodeToClusterFormationStateMap::put,

+ 8 - 1
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<DiscoveryNode, ClusterFormationStateOrException> 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 @@ public class CoordinationDiagnosticsService implements ClusterStateListener {
                     connectionListener
                 );
             }
-        }, new TimeValue(10, TimeUnit.SECONDS), ThreadPool.Names.SAME);
+        }, remoteRequestInitialDelay, ThreadPool.Names.SAME);
     }
 
     // Non-private for testing