Skip to content

Commit 30fe7df

Browse files
committed
Build: allow the amount of time we wait for a node to be configured (#28403)
This commit allows for configuration of the amount of time we wait for a node to startup. This is needed as some QA tests with plugins and tribe timeout when starting the tribe node. Even regular node startup time with plugins is starting to approach the limit of 30 seconds. Additionally, this commit provides better feedback when a wait has failed. The code checks to ensure all expected files exist for each node; if they do not then we consider the wait task as having failed. Prior to this change, when there was one or more missing file the build would continue and attempt to execute the wait condition that typically makes an HTTP request to the cluster. The output of this type of failure does include which files exist and which do not but this change makes it clearer that the actual HTTP call did not time out, but the failure was before the call was even made.
1 parent 7625c7a commit 30fe7df

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterConfiguration.groovy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ class ClusterConfiguration {
123123
return tmpFile.exists()
124124
}
125125

126+
/**
127+
* The maximum number of seconds to wait for nodes to complete startup, which includes writing
128+
* the ports files for the transports and the pid file. This wait time occurs before the wait
129+
* condition is executed.
130+
*/
131+
@Input
132+
int nodeStartupWaitSeconds = 30
133+
126134
public ClusterConfiguration(Project project) {
127135
this.project = project
128136
}

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import org.elasticsearch.gradle.LoggedExec
2424
import org.elasticsearch.gradle.Version
2525
import org.elasticsearch.gradle.VersionProperties
2626
import org.elasticsearch.gradle.plugin.MetaPluginBuildPlugin
27-
import org.elasticsearch.gradle.plugin.MetaPluginPropertiesExtension
2827
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
2928
import org.elasticsearch.gradle.plugin.PluginPropertiesExtension
3029
import org.gradle.api.AntBuilder
@@ -120,7 +119,7 @@ class ClusterFormationTasks {
120119
startTasks.add(configureNode(project, prefix, runner, dependsOn, node, config, distro, nodes.get(0)))
121120
}
122121

123-
Task wait = configureWaitTask("${prefix}#wait", project, nodes, startTasks)
122+
Task wait = configureWaitTask("${prefix}#wait", project, nodes, startTasks, config.nodeStartupWaitSeconds)
124123
runner.dependsOn(wait)
125124

126125
return nodes
@@ -581,10 +580,10 @@ class ClusterFormationTasks {
581580
return start
582581
}
583582

584-
static Task configureWaitTask(String name, Project project, List<NodeInfo> nodes, List<Task> startTasks) {
583+
static Task configureWaitTask(String name, Project project, List<NodeInfo> nodes, List<Task> startTasks, int waitSeconds) {
585584
Task wait = project.tasks.create(name: name, dependsOn: startTasks)
586585
wait.doLast {
587-
ant.waitfor(maxwait: '30', maxwaitunit: 'second', checkevery: '500', checkeveryunit: 'millisecond', timeoutproperty: "failed${name}") {
586+
ant.waitfor(maxwait: "${waitSeconds}", maxwaitunit: 'second', checkevery: '500', checkeveryunit: 'millisecond', timeoutproperty: "failed${name}") {
588587
or {
589588
for (NodeInfo node : nodes) {
590589
resourceexists {
@@ -614,6 +613,17 @@ class ClusterFormationTasks {
614613
waitFailed(project, nodes, logger, 'Failed to start elasticsearch')
615614
}
616615

616+
// make sure all files exist otherwise we haven't fully started up
617+
boolean missingFile = false
618+
for (NodeInfo node : nodes) {
619+
missingFile |= node.pidFile.exists() == false
620+
missingFile |= node.httpPortsFile.exists() == false
621+
missingFile |= node.transportPortsFile.exists() == false
622+
}
623+
if (missingFile) {
624+
waitFailed(project, nodes, logger, 'Elasticsearch did not complete startup in time allotted')
625+
}
626+
617627
// go through each node checking the wait condition
618628
for (NodeInfo node : nodes) {
619629
// first bind node info to the closure, then pass to the ant runner so we can get good logging

0 commit comments

Comments
 (0)