Skip to content

Commit 5d9d619

Browse files
TESTS: Use File Based Discovery in REST Tests
* For 7.0 use file based discovery in REST tests * Relates elastic#33675
1 parent e0a1803 commit 5d9d619

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

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

+23-3
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,13 @@ class ClusterFormationTasks {
347347

348348
Task writeConfig = project.tasks.create(name: name, type: DefaultTask, dependsOn: setup)
349349
writeConfig.doFirst {
350-
String unicastTransportUri = node.config.unicastTransportUri(seedNode, node, project.ant)
351-
if (unicastTransportUri != null) {
352-
esConfig['discovery.zen.ping.unicast.hosts'] = "\"${unicastTransportUri}\""
350+
if (node.nodeVersion.onOrAfter("7.0.0-SNAPSHOT")) {
351+
esConfig['discovery.zen.hosts_provider'] = 'file'
352+
} else {
353+
String unicastTransportUri = node.config.unicastTransportUri(seedNode, node, project.ant)
354+
if (unicastTransportUri != null) {
355+
esConfig['discovery.zen.ping.unicast.hosts'] = "\"${unicastTransportUri}\""
356+
}
353357
}
354358
File configFile = new File(node.pathConf, 'elasticsearch.yml')
355359
logger.info("Configuring ${configFile}")
@@ -703,6 +707,22 @@ class ClusterFormationTasks {
703707
}
704708
}
705709
}
710+
711+
nodes.forEach {node ->
712+
if (node.nodeVersion.onOrAfter("7.0.0-SNAPSHOT")) {
713+
Collection<String> unicastHosts = new HashSet<>()
714+
nodes.forEach { otherNode ->
715+
String unicastHost = node.config.unicastTransportUri(otherNode, node, project.ant)
716+
if (unicastHost != null) {
717+
unicastHosts.add(unicastHost)
718+
}
719+
}
720+
node.pathConf.toPath().resolve("unicast_hosts.txt").setText(
721+
String.join("\n", unicastHosts)
722+
)
723+
}
724+
}
725+
706726
if (ant.properties.containsKey("failed${name}".toString())) {
707727
waitFailed(project, nodes, logger, "Failed to start elasticsearch: timed out after ${waitSeconds} seconds")
708728
}

0 commit comments

Comments
 (0)